How apna-college/zerodha-clone works
1. This repository is a three-part frontend/backoffice setup plus a small API backend. Each top-level folder is its own app with its own package.json, so the likely deployment boundary is:
- backend: server and persistence layer
- dashboard: trading/portfolio console
- frontend: public marketing site and onboarding pages
2. The backend folder is the data service for trading entities. Its domain is split into three objects:
- Holdings
- Orders
- Positions
The model/ and schemas/ pairs strongly suggest a document database layer with separate persistence definitions for each entity.
3. The backend’s architecture is domain-centric rather than feature-centric: holdings, orders, and positions are modeled separately, which matches the typical trading lifecycle:
- orders are created first
- filled orders affect positions
- holdings reflect current portfolio state
4. backend/index.js is the server entry point and likely exposes the API consumed by the dashboard. The .env file indicates runtime configuration is externalized, which usually means database connection details and server settings are injected at startup.
5. The dashboard app is the operational UI for portfolio management. Its component set shows the main screens and widgets:
- portfolio summary
- holdings table
- open positions
- orders list
- funds view
- watchlist
- top bar and side menu navigation
- buy action modal/window
6. The dashboard also contains charting/analytics components:
- DoughnoutChart.js
- VerticalGraph.js
These imply the UI is not just tabular; it also visualizes portfolio allocation and performance metrics.
7. dashboard/src/components/GeneralContext.js indicates shared client-side state is centralized, probably to coordinate watchlist, selected instrument, order entry, and portfolio data across multiple panels. That makes the dashboard a stateful single-page app rather than a set of isolated pages.
8. dashboard/src/data/data.js suggests some UI data is static or mocked locally, likely for watchlists or demo analytics. So the dashboard probably mixes backend-fetched account data with local reference data for UI rendering.
9. The frontend app is separate from the dashboard and reads like the public-facing website. It contains route/grouped sections for:
- home
- about
- products
- pricing
- support
- signup
- open account
This is a marketing and acquisition surface, not the trading console.
10. The frontend is organized by page-level folders with reusable subcomponents such as hero sections, navbar, footer, team, stats, education, brokerage, universe, and ticket creation. That structure indicates a content-heavy site with multiple landing pages and a small amount of interactive onboarding.
11. There is no visible shared code package between frontend and dashboard; they appear to be independently built React apps. Architecturally, that means the public site and the trading console can evolve and deploy separately, while sharing only the product/domain concept, not implementation code.
12. A good diagram for this repo would show:
- users entering through the frontend marketing site
- users moving into the dashboard trading app for account activity
- the dashboard calling the backend API for holdings/orders/positions data
- the backend persisting those entities in a database-backed model layer
13. The main architectural boundary is therefore between presentation and domain data:
- frontend = acquisition/onboarding content
- dashboard = authenticated operational UI
- backend = trading/account API and persistence
This separation is the key thing to preserve when drawing the system.
Main entry points: Dashboard.js Dashboard shell · Navbar.js Site shell · index.js API server · PositionsModel.js Positions model
Components 25
frontend
Public marketing and onboarding app
- Frontend app · Public site for acquisition and onboarding
frontend/src/index.js - Home page · Main marketing entry with hero, stats, education, and pricing
frontend/src/landing_page/home/HomePage.js - Products · Product overview and universe exploration pages
frontend/src/landing_page/products/ProductsPage.js - Pricing · Pricing and brokerage information pages
frontend/src/landing_page/pricing/PricingPage.js - Support · Help and ticket creation pages
frontend/src/landing_page/support/SupportPage.js - Signup · Account creation entry point
frontend/src/landing_page/signup/Signup.js - Site shell · Shared navbar and footer framing the public site
frontend/src/landing_page/Navbar.js
dashboard
Operational trading console
- Dashboard app · Authenticated trading and portfolio console
dashboard/src/index.js - Dashboard shell · Top bar, side menu, and main app composition
dashboard/src/components/Dashboard.js - Shared state · Centralized app state for panels and actions
dashboard/src/components/GeneralContext.js - Summary · Account snapshot and portfolio summary
dashboard/src/components/Summary.js - Holdings · Current holdings view
dashboard/src/components/Holdings.js - Positions · Open positions view
dashboard/src/components/Positions.js - Orders · Orders list and order status view
dashboard/src/components/Orders.js - Funds · Funding and balance panel
dashboard/src/components/Funds.js - Watchlist · Instrument watchlist and quick access
dashboard/src/components/WatchList.js - Buy ticket · Buy action window for order entry
dashboard/src/components/BuyActionWindow.js - Charts · Allocation and performance visualizations
dashboard/src/components/DoughnoutChart.js
backend
Trading API and persistence layer
- API server · Backend entry point serving trading data
backend/index.js - Holdings model · Document model for holdings
backend/model/HoldingsModel.js - Orders model · Document model for orders
backend/model/OrdersModel.js - Positions model · Document model for positions
backend/model/PositionsModel.js - Holdings schema · Schema for holdings documents
backend/schemas/HoldingsSchema.js - Orders schema · Schema for order documents
backend/schemas/OrdersSchema.js - Positions schema · Schema for position documents
backend/schemas/PositionsSchema.js
Connections 25
- Frontend app → Site shell: renders · Public app uses shared site layout
- Site shell → Home page: routes to · Primary landing experience
- Site shell → Products: routes to · Product discovery pages
- Site shell → Pricing: routes to · Pricing information pages
- Site shell → Support: routes to · Support and help pages
- Site shell → Signup: routes to · Account creation entry
- Dashboard app → Dashboard shell: renders · Dashboard app composition
- Dashboard shell → Shared state: shares state · Central app state for panels and actions
- Dashboard shell → Summary: shows · Portfolio overview panel
- Dashboard shell → Holdings: shows · Holdings panel
- Dashboard shell → Positions: shows · Positions panel
- Dashboard shell → Orders: shows · Orders panel
- Dashboard shell → Funds: shows · Funds panel
- Dashboard shell → Watchlist: shows · Watchlist panel
- Dashboard shell → Buy ticket: opens · Buy order entry modal
- Dashboard shell → Charts: visualizes · Portfolio charts and analytics
- Dashboard app → API server: consumes · Dashboard fetches trading/account data
- API server → Holdings model: serves · Holdings domain data
- API server → Orders model: serves · Orders domain data
- API server → Positions model: serves · Positions domain data
- Holdings model → Holdings schema: defined by · Holdings persistence schema
- Orders model → Orders schema: defined by · Orders persistence schema
- Positions model → Positions schema: defined by · Positions persistence schema
- Orders model → Positions model: affects · Filled orders update positions
- Positions model → Holdings model: rolls up · Positions contribute to current holdings state