A full-stack MERN (MongoDB, Express, React, Node.js) application that simulates a stock trading platform. Users can manage a portfolio, trade stocks in real-time using Yahoo Finance data, track their performance, and manage a watchlist.
- Secure Access: User registration and login using JSON Web Tokens (JWT) and bcrypt encryption.
- Role-Based Access: Distinct interfaces for standard Users and Administrators.
- Developer Portal: Dedicated admin dashboard to view all users, search/filter user base, and inspect individual user portfolios and transaction histories. When first setting up the app locally, the first user would be prompted to become the admin of the app.
- Portfolio Overview: Real-time view of Total Equity, Buying Power, and Cash Balance.
- Visual Analytics:
- Allocation Chart: Pie chart visualizing portfolio distribution across different assets.
- Performance Chart: Line chart tracking portfolio value history over time.
- Holdings Management: Sortable list of current stock holdings (by Symbol, Value, Quantity, etc.).
- Fund Management: Easy-to-use mock interface for Depositing and Withdrawing funds (for testing purposes, user can just type any integer value when depositing and withdrawing cash).
- Real-Time Data: Live stock prices and company information fetched via Yahoo Finance API.
- Interactive Charts: Dynamic stock price charts with multiple timeframes (1D, 1W, 1M, 3M, YTD, 1Y).
- Flexible Trading:
- Buy and Sell stocks.
- Toggle between investing by Shares or Dollar Amount.
- Market Hours Implementation:
- Orders placed outside of market hours (9:30 AM - 4:00 PM ET) are automatically QUEUED.
- Automated cron job processes queued orders when the market opens.
- Watchlist: Personalized watchlist to track favorite stocks with real-time daily change indicators.
- Comprehensive Logs: Detailed record of all activities including Buys, Sells, Deposits, and Withdrawals.
- Status Tracking: Monitor the status of orders (COMPLETED, QUEUED, FAILED).
- Docker Integration: Simplified MongoDB setup using Docker containers.
- Automated Order Processing: Backend cron jobs handle queued orders to simulate realistic market execution.
- Dynamic Configuration: Environment variable support for custom ports, database URIs, and secrets.
Before you begin, ensure you have the following installed on your machine:
- Node.js (v14 or higher)
- npm (usually comes with Node.js)
- MongoDB (Local installation or MongoDB Atlas account)
If you haven't already, download/git clone the source code to your local machine.
If you prefer using Docker instead of a local MongoDB installation, make sure to first download Docker appropriate to your platform then start up a container quickly:
docker run -d -p 27017:27017 --name financial-mongo mongo:latestThis will start a MongoDB instance accessible at mongodb://localhost:27017.
Navigate to the server directory and install dependencies:
cd server
npm installCreate a .env file in the server directory with the following variables:
PORT=5001
MONGO_URI=mongodb://localhost:27017/financial-app
JWT_SECRET=your_jwt_secret_key- Note: If you used the Docker command above, the
MONGO_URIis already set correctly in the example. - Replace
your_jwt_secret_keywith a secure random string.
Open a new terminal, navigate to the client directory, and install dependencies:
cd client
npm installYou need to run both the backend server and the frontend client.
In the server directory:
npm run devThe server will start on http://localhost:5001.
In the client directory:
npm startThe application will open in your browser at http://localhost:3000.
- Frontend: React, Recharts, Context API, React Router
- Backend: Node.js, Express, Mongoose
- External API: yahoo-finance2
- Authentication: JSON Web Token (JWT), Bcryptjs





