Premium Full-Stack Stock Trading Simulator & Portfolio Manager
Execute orders • Match limit trades • Sync nightly settlements • Analyze portfolio allocations
Experience the complete stock trading and brokerage simulator, featuring margin balance accounts, limit order matching schedulers, endpoints validation, ledger auditing, and full security lifecycles.
Marketing Portal: https://stock-trading-platform-frontend-six.vercel.app
Console Dashboard: https://stock-trading-platform-dashboard-six.vercel.app
| Email Address | Password |
|---|---|
| demo@zerodha.com | password123 |
Note: Use this account to log in and immediately test limit order routing, cash ledger transactions, deposits, and EOD holding conversions.
Kite Console is a production-inspired stock trading simulator that replicates the core brokerage functionalities of modern exchanges. The application focuses on data consistency, transaction rollbacks, security authentication, and automated nightly settlements.
Built using an Express API backend, MongoDB Atlas, and dual React client origins (the marketing portal and console dashboard), the application simulates real-world brokerage rules: immediate asset locking for pending limit trades, nightly Cron settlement executing inside database session transactions, timezone-locked market hour validators, and bi-directional SSO logout synchronization.
- 🔐 Cross-Origin Session Sync: Bi-directional token synchronization and bfcache back-button navigation protection.
- 💰 Double-Spending Prevention: Real-time asset locks for active orders (blocking margin or shares immediately).
- 📈 Hybrid EOD Settlement: An automated nightly settlement engine running in Mongoose transactions with an "Active-on-Wake" dynamic fallback logic for cold-starting environments.
- ⚡ Asynchronous Order Matcher: Background schedulers evaluating pending limit orders against mock market ticks.
- 💳 Razorpay Sandbox Integration: Checkout workflows enabling mock deposits to load simulated capital.
- 📊 Dynamic Portfolio Analytics: Asset allocation breakdowns visualized via interactive Chart.js doughnut panels.
- 🛡️ Rate-Limiting & Security Headers: Helmet.js configurations and endpoint request throttling.
- 📖 About
- ⭐ Project Highlights
- 🎥 Demo GIF
- 📸 Project Showcase
- 🎬 Demo Video
- ✨ Features
- 🛠️ Technology Stack
- 🏗️ System Architecture
- 📁 Project Structure
- 🔌 REST API Directory
- ⚙️ Installation & Setup
- 🔐 Environment Variables
- 🚀 Deployment Overview
- 📈 Engineering Highlights (Deep Dives)
- 🔮 Future Improvements
- 🤝 Contributing
- 📄 License
- 👨💻 Author
A quick walkthrough of Kite Console, showcasing the complete user journey—from placing orders to checking daily asset migrations.
Experience the complete Kite Console ecosystem through the screenshots below. The walkthrough covers both the Marketing Website and the Trading Dashboard, taking you through the complete journey—from discovering the platform to securely managing investments.
The first impression of Kite Console, introducing the platform and guiding users toward account creation.
Learn about the platform's vision, mission, statistics, and core philosophy.
Explore the products and investment services available within the ecosystem.
View brokerage plans, pricing details, and the interactive nested-routing interface.
Interactive support center with categorized FAQs and expandable help sections.
Secure authentication before entering the trading dashboard.
Protected dashboard gateway after successful authentication.
Portfolio overview displaying investments, available balance, holdings, positions, and analytics.
Monitor market activity and place Market or Limit orders directly from the watchlist.
Review submitted orders together with execution status and transaction details.
Track active trading positions with invested value, current valuation, and unrealized profit or loss.
View permanently settled holdings after the End-of-Day settlement process.
Manage wallet balance, margin availability, deposits, and withdrawals.
Integrated applications available within the Kite Console ecosystem.
Optimized marketing website for mobile devices.
Fully responsive dashboard delivering the complete trading experience on mobile devices.
Watch the complete video walkthrough covering system architecture, session security syncs, transaction rollbacks, and portfolio analytics.
- Browse asset lists with real-time green/red visual ticker badges.
- Execute trades using MARKET or LIMIT execution routes.
- Lock available margin cash (for buy orders) or stock shares (for sell orders) instantly upon order placement.
- Automatically cancel outstanding limit orders after 24 hours, returning locked funds or shares.
- Log ledger updates containing margin parameters: Available Margin, Blocked Margin, and Realized P&L.
- Log bank transactions for simulated withdrawals and deposits.
- View asset allocations dynamically graphed on doughnut charts.
- Order Matching Engine: A background worker polling market prices and updating status.
- EOD Settlement: A daily script migrating positions to permanent holdings (calculating weighted average purchase costs).
- Market Hours Protection: Prevents transactions outside simulated US market hours (7:00 PM IST to 1:30 AM IST).
- JWT Session authentication.
- Single Sign-Out (SSO) cross-origin synchronization.
- Back-button browser (bfcache) session protection.
- Express-rate-limiter and Helmet security headers configuration.
- Joi input payload schema validation.
| Category | Technologies |
|---|---|
| Frontend | React 18, React Router v6, Axios, Chart.js, CSS3 (Vanilla) |
| Backend | Node.js, Express.js |
| Database | MongoDB Atlas, Mongoose |
| Asynchronous Scheduling | Node-Cron |
| Payment Sandbox | Razorpay Test Checkout API |
| Security & Logging | JWT, Bcrypt, Helmet, Express-Rate-Limit, Winston Logger |
Kite Console follows a secure, micro-routed architecture:
Client Browser (Port 3000 / 3001)
│
Express.js API (Port 3002)
┌───────────────────────┼───────────────────────┐
│ │ │
MongoDB Atlas Razorpay Checkout Finnhub Prices
- Isolated marketing origin (port 3000) and dashboard origin (port 3001).
- Unified Express.js API (port 3002).
- Node-Cron schedulers running price synchronization and EOD settlement scripts.
Stock-Trading-Platform/
│
├── Backend/ # Express.js Server
│ ├── config/ # Winston logging & DB configs
│ ├── controllers/ # Controller handlers
│ ├── cron/ # Schedulers (Matcher, price sync, EOD)
│ ├── middleware/ # JWT auth & security filters
│ ├── model/ # Mongoose models (Holdings, Orders)
│ ├── routes/ # Express API routes
│ └── services/ # Core logic (Settlement, Trading)
│
├── dashboard/ # Console Panel (React Web App)
│ ├── public/ # Pre-mount loaders
│ └── src/ # Views & Components
│
└── frontend/ # Marketing Portal (React Web App)
└── src/ # Landing page layouts
| Method | Endpoint | Description |
|---|---|---|
| POST | /signup |
Create user profile and pre-fund account |
| POST | /login |
Verify credentials and return JWT token |
| Method | Endpoint | Description |
|---|---|---|
| GET | /allHoldings |
Fetch settled holdings |
| GET | /allPositions |
Fetch active positions |
| POST | /newOrder |
Submit trade (Market/Limit) |
| GET | /allOrders |
Fetch order history |
| Method | Endpoint | Description |
|---|---|---|
| POST | /portfolio/funds |
Log withdrawal requests |
| POST | /portfolio/funds/order |
Initialize Razorpay payment intent |
| POST | /portfolio/funds/verify |
Verify payment check signature |
| GET | /portfolio/transactions |
Fetch audit logs |
Clone the project
git clone https://github.com/mihirgupta665/Stock-Trading-Platform-.git
cd Stock-Trading-Platform-Navigate to Backend and start
cd Backend
npm install
# Create a .env file (see variables template below)
npm startNavigate to Dashboard and start
cd ../dashboard
npm install
npm startNavigate to Frontend and start
cd ../frontend
npm install
npm startCreate a .env file in the project roots:
MONGO_URL=your_mongodb_connection_string
JWT_SECRET=your_jwt_secret_key
PORT=3002
TIMEZONE=Asia/Kolkata
SETTLEMENT_TIME=01:31
PRICE_REFRESH_INTERVAL=*/2 * * * *
FINNHUB_API_KEY=your_finnhub_key
RAZORPAY_KEY_ID=your_razorpay_key
RAZORPAY_KEY_SECRET=your_razorpay_secretPORT=3001
REACT_APP_API_URL=http://localhost:3002
REACT_APP_FRONTEND_URL=http://localhost:3000| Origin / Layer | Service Provider |
|---|---|
| Marketing Portal | Vercel (Static Web Hosting) |
| Console Dashboard | Vercel (Static Web Hosting) |
| API Engine | Render / Railway (Dynamic Server Host) |
| Database Cache | MongoDB Atlas (Cloud Cluster) |
When placing limit buy orders, funds are immediately locked to prevent over-purchasing. When selling, target asset quantities are deducted immediately.
- Deduction & Hold: Trade submissions verify available liquid cash or shares. If verified, funds or shares are deducted and stored in
"BLOCKED"status on the pending order, maintaining ledger consistency. - Rollback Safeties: If an order is canceled or expires, a transactional rollback runs, releasing the blocked assets back to the user's active wallet balance.
Positions represent active intraday exposure, while holdings are settled multi-day assets.
- Atomic Transactions: A daily cron job executes at
1:31 AM IST. It aggregates active user positions and migrates them into holdings (calculating weighted average purchase costs) in a single transaction. - Eventual Consistency Fallback Handler: Free-tier cloud instances sleep after inactivity, missing cron schedules. To ensure consistency, a fallback checks cutoff times on dashboard loads. If positions are older than 24 hours, the settlement executes dynamically before resolving statistics.
To prevent unauthorized navigation when accessing the console:
- SSO Sync: The dashboard and marketing portal coordinate tokens. If the token is cleared in one tab, the other origin detects the change and logs the user out.
- bfcache Protection: Browsers restore DOM states without hitting the network on backward clicks. An HTML5
pageshowlistener detects cache retrievals, checks active tokens, and redirects immediately on session deletion.
- WebSockets Engine: Deliver real-time stock tickers to the watchlist via socket streams.
- Candlestick Charts: Integrate interactive financial charts to display historical trade ranges.
- Trailing Stop Loss: Add advanced order triggers (
SLandSL-Mmodels).
Contributions are welcome! Please fork the repository, make changes in a feature branch, and open a Pull Request.
This project is made only for exploring and learning purpose.
B.Tech Computer Science Engineering (AI & ML)
Passionate developer focused on building scalable, transactional applications and low-latency APIs.
- GitHub: github.com/mihirgupta665
- LinkedIn: https://www.linkedin.com/in/mihir-gupta-980173299/
Thank you for visiting Kite Console! Happy Trading ❤️

















