Loading system design...
Design a stock trading and investment platform like Groww that enables users to buy/sell stocks and mutual funds in real-time. The system handles user onboarding with KYC, streams real-time market data to millions of concurrent users via WebSocket, manages order placement and routing to stock exchanges (NSE/BSE) via FIX protocol, maintains a double-entry funds ledger with T+1 settlement, computes real-time portfolio P&L, supports mutual fund investments with SIP scheduling, and ensures regulatory compliance (SEBI) with complete audit trails.
| Metric | Value |
|---|---|
| Registered users | 100 million |
| Daily active users | 10 million |
| Concurrent users (market hours) | 5 million |
| Orders per day | 50 million |
| Orders per second (peak, market open) | 100,000 |
| Listed instruments (equities + F&O) | 5,000+ |
| Real-time ticks per second (from exchange) | 50,000+ |
| WebSocket connections (concurrent) | 5 million |
| Mutual fund SIPs active | 20 million |
| Daily trading volume | ₹50,000 crore+ |
User onboarding and KYC: users sign up with mobile/email; complete KYC (Aadhaar, PAN verification, bank account linking, selfie verification); regulatory compliance (SEBI, broker registration); account activation within minutes for digital KYC
Stock market data feed: display real-time stock prices, bid/ask spreads, order book depth, and market indices (Nifty 50, Sensex) with < 500ms latency from the exchange; support 5,000+ listed instruments (equities, ETFs, futures, options)
Order placement: users place buy/sell orders — market orders (execute immediately at best price), limit orders (execute at specified price or better), stop-loss orders; validate order against user's available balance/holdings; orders routed to stock exchange (NSE/BSE) via gateway
Order matching and execution: orders sent to the exchange are matched by the exchange's matching engine; execution confirmation received within milliseconds; update user's portfolio, available balance, and order status in real-time; handle partial fills
Portfolio and holdings: display user's current holdings with real-time P&L (profit/loss), average buy price, current market value, total investment, day's gain/loss; historical portfolio performance charts
Funds management: add funds via UPI/net banking/NEFT; withdraw to linked bank account; maintain ledger of funds (credits, debits, blocked for open orders, settled); T+1 settlement cycle compliance
Watchlist: users create custom watchlists of tracked stocks; real-time price updates on watchlist; price alerts (notify when stock reaches target price); trending stocks and market movers
Mutual funds (MF): browse, compare, and invest in mutual funds; SIP (Systematic Investment Plan) scheduling; NAV tracking; portfolio view for MF holdings; one-click redemption
Market analytics: candlestick charts (1-min to monthly), technical indicators (RSI, MACD, Bollinger Bands, moving averages), company fundamentals (P/E ratio, revenue, earnings), news feed, analyst ratings
Regulatory reporting: generate contract notes for every trade; daily/monthly statements; tax reports (capital gains — STCG/LTCG, dividend income, STT); SEBI compliance reporting; audit trail for all transactions
Non-functional requirements define the system qualities critical to your users. Frame them as 'The system should be able to...' statements. These will guide your deep dives later.
Think about CAP theorem trade-offs, scalability limits, latency targets, durability guarantees, security requirements, fault tolerance, and compliance needs.
Frame NFRs for this specific system. 'Low latency search under 100ms' is far more valuable than just 'low latency'.
Add concrete numbers: 'P99 response time < 500ms', '99.9% availability', '10M DAU'. This drives architectural decisions.
Choose the 3-5 most critical NFRs. Every system should be 'scalable', but what makes THIS system's scaling uniquely challenging?