A full-stack web application for managing and tracking your stock market investments. This application allows users to create and manage their stock portfolios, track real-time stock prices, and analyze their investment performance.
- Real-time stock price tracking using WebSocket connections
- Portfolio management with multiple portfolio support
- Live stock search functionality
- Interactive price charts with historical data
- User authentication and profile management
- Automated price updates via background services
- Real-time portfolio value calculations
- Cash balance management with top-up functionality
- Node.js & Express: RESTful API server
- MongoDB: Database for storing user, portfolio, and stock data
- WebSocket Server: Real-time price updates and portfolio changes
- Background Services:
- Automated stock price updates
- Market data synchronization
- Portfolio value calculations
- React.js: Single page application
- Material-UI: Modern and responsive UI components
- Chart.js: Interactive price and portfolio charts
- WebSocket Client: Real-time data updates
- Axios: HTTP client for API communication
- Node.js
- Express.js
- MongoDB
- WebSocket (ws)
- JWT Authentication
- React.js
- Material-UI
- Chart.js for data visualization
- Axios for API calls
- React Context for state management
- Node.js (v14 or higher)
- MongoDB
- npm or yarn
To install all required dependencies, run:
# Install backend dependencies
cd backend
npm install
# Install frontend dependencies
cd frontend
npm install
-
Backend Setup
cd backend npm install # Create a .env file with necessary configurations npm run dev
-
Frontend Setup
cd frontend npm install npm start
Create a .env
file in the backend directory with the following variables:
PORT=5000
MONGODB_URI=your_mongodb_connection_string
NODE_ENV=development
JWT_SECRET=your_jwt_secret
STOCK_API_KEY=your_stock_api_key
WEBSOCKET_PORT=5001
The API endpoints are available at http://localhost:5000/api
POST /api/auth/register
- Register new userPOST /api/auth/login
- User loginGET /api/auth/profile
- Get user profile
GET /api/stocks/search
- Search for stocksGET /api/stocks/:symbol
- Get stock detailsGET /api/stocks/:symbol/history
- Get historical prices
GET /api/portfolio
- Get user portfoliosPOST /api/portfolio
- Create new portfolioPUT /api/portfolio/:id
- Update portfolioDELETE /api/portfolio/:id
- Delete portfolioPOST /api/portfolio/:id/buy
- Buy stocksPOST /api/portfolio/:id/sell
- Sell stocks
PUT /api/users/topup
- Add funds to accountGET /api/users/balance
- Get account balancePUT /api/users/profile
- Update user profile
The application uses WebSocket for real-time updates:
price_update
- Real-time stock price updatesportfolio_update
- Portfolio value changestrade_confirmation
- Trade execution confirmations
- JWT-based authentication
- Password hashing using bcrypt
- Protected API endpoints
- Input validation and sanitization
- Rate limiting on API endpoints
# Run backend tests
cd backend
npm test
# Run frontend tests
cd frontend
npm test
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Thanks to all contributors who have helped with the development
- Built with modern web technologies