# abhy9393/zerodha-clone architecture

> Architecture diagram of the GitHub repository abhy9393/zerodha-clone, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/abhy9393/zerodha-clone
- Repository: https://github.com/abhy9393/zerodha-clone

## Overview

This repository combines a brokerage information site with a trading dashboard and an Express API. The intended user journey is to explore the public site, sign in, then view trading data and submit an order; the sampled dashboard entry reads a token from the URL or local storage. The backend implements authentication, protected holdings and positions reads, and buy/sell order updates. Dashboard-to-API wiring and most UI component behavior are not shown in the sampled source, so those links are omitted.

Main entry points: [`Zerodha/frontend/src/App.js`](https://github.com/abhy9393/zerodha-clone/blob/main/Zerodha/frontend/src/App.js) (Public site router), [`Zerodha/backend/index.js`](https://github.com/abhy9393/zerodha-clone/blob/main/Zerodha/backend/index.js) (Express API), [`Zerodha/dashboard/src/components/Home.js`](https://github.com/abhy9393/zerodha-clone/blob/main/Zerodha/dashboard/src/components/Home.js) (Trading workspace), [`Zerodha/dashboard/src/App.js`](https://github.com/abhy9393/zerodha-clone/blob/main/Zerodha/dashboard/src/App.js) (Dashboard entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_public["Public website"]
  node_site["Public site router<br/>[App.js]"]
  node_home["Home and company<br/>[HomePage.js]"]
  node_products["Products<br/>[ProductsPage.js]"]
  node_pricing["Pricing<br/>[PricingPage.js]"]
  node_support["Support<br/>[SupportPage.js]"]
  node_signup["Signup<br/>[Signup.js]"]
  node_login["Login<br/>[Login.js]"]
  node_public_shell["Navigation and footer<br/>[Navbar.js]"]
end

subgraph group_trading["Trading dashboard"]
  node_dashboard_app["Dashboard entry<br/>[App.js]"]
  node_dashboard_home["Trading workspace<br/>[Home.js]"]
  node_watchlist["Watchlist<br/>[WatchList.js]"]
  node_holdings_ui["Holdings<br/>[Holdings.js]"]
  node_positions_ui["Positions<br/>[Positions.js]"]
  node_orders_ui["Orders<br/>[Orders.js]"]
  node_funds_ui["Funds<br/>[Funds.js]"]
  node_buy_window["Buy / sell window<br/>[BuyActionWindow.js]"]
  node_trade_context["Trade window context<br/>[GeneralContext.js]"]
end

subgraph group_api["API and authentication"]
  node_api_server["Express API<br/>[index.js]"]
  node_auth_routes["Signup and login<br/>[authRoutes.js]"]
  node_dashboard_routes["Dashboard access<br/>[dashboardRoutes.js]"]
  node_auth_middleware["JWT verification<br/>[authMiddleware.js]"]
end

subgraph group_storage["Persistent data"]
  node_user_model["User records<br/>[UserModel.js]"]
  node_holdings_model["Holdings records<br/>[HoldingsModel.js]"]
  node_positions_model["Positions records<br/>[PositionsModel.js]"]
  node_orders_model["Order records<br/>[OrdersModel.js]"]
end

node_visitor(("Visitor / trader"))
node_mongo[("MongoDB")]

node_visitor -->|"browses"| node_site
node_site -->|"routes"| node_home
node_site -->|"routes"| node_products
node_site -->|"routes"| node_pricing
node_site -->|"routes"| node_support
node_site -->|"routes"| node_signup
node_site -->|"routes"| node_login
node_site -->|"renders"| node_public_shell
node_visitor -->|"opens"| node_dashboard_app
node_dashboard_app -->|"renders"| node_dashboard_home
node_dashboard_home --> node_watchlist
node_dashboard_home --> node_holdings_ui
node_dashboard_home --> node_positions_ui
node_dashboard_home --> node_orders_ui
node_dashboard_home --> node_funds_ui
node_trade_context -->|"opens"| node_buy_window
node_api_server -->|"mounts"| node_auth_routes
node_api_server -->|"mounts"| node_dashboard_routes
node_api_server -->|"protects data routes"| node_auth_middleware
node_auth_routes -->|"finds and saves"| node_user_model
node_dashboard_routes -->|"invokes"| node_auth_middleware
node_api_server -->|"reads and updates"| node_holdings_model
node_api_server -->|"reads"| node_positions_model
node_api_server -->|"creates orders"| node_orders_model
node_api_server -->|"connects"| node_mongo
node_user_model -->|"persists"| node_mongo
node_holdings_model -->|"persists"| node_mongo
node_positions_model -->|"persists"| node_mongo
node_orders_model -->|"persists"| node_mongo

click node_site "https://github.com/abhy9393/zerodha-clone/blob/main/Zerodha/frontend/src/App.js"
click node_home "https://github.com/abhy9393/zerodha-clone/blob/main/Zerodha/frontend/src/landing_page/home/HomePage.js"
click node_products "https://github.com/abhy9393/zerodha-clone/blob/main/Zerodha/frontend/src/landing_page/products/ProductsPage.js"
click node_pricing "https://github.com/abhy9393/zerodha-clone/blob/main/Zerodha/frontend/src/landing_page/pricing/PricingPage.js"
click node_support "https://github.com/abhy9393/zerodha-clone/blob/main/Zerodha/frontend/src/landing_page/support/SupportPage.js"
click node_signup "https://github.com/abhy9393/zerodha-clone/blob/main/Zerodha/frontend/src/landing_page/signup/Signup.js"
click node_login "https://github.com/abhy9393/zerodha-clone/blob/main/Zerodha/frontend/src/landing_page/signup/Login.js"
click node_public_shell "https://github.com/abhy9393/zerodha-clone/blob/main/Zerodha/frontend/src/landing_page/Navbar.js"
click node_dashboard_app "https://github.com/abhy9393/zerodha-clone/blob/main/Zerodha/dashboard/src/App.js"
click node_dashboard_home "https://github.com/abhy9393/zerodha-clone/blob/main/Zerodha/dashboard/src/components/Home.js"
click node_watchlist "https://github.com/abhy9393/zerodha-clone/blob/main/Zerodha/dashboard/src/components/WatchList.js"
click node_holdings_ui "https://github.com/abhy9393/zerodha-clone/blob/main/Zerodha/dashboard/src/components/Holdings.js"
click node_positions_ui "https://github.com/abhy9393/zerodha-clone/blob/main/Zerodha/dashboard/src/components/Positions.js"
click node_orders_ui "https://github.com/abhy9393/zerodha-clone/blob/main/Zerodha/dashboard/src/components/Orders.js"
click node_funds_ui "https://github.com/abhy9393/zerodha-clone/blob/main/Zerodha/dashboard/src/components/Funds.js"
click node_buy_window "https://github.com/abhy9393/zerodha-clone/blob/main/Zerodha/dashboard/src/components/BuyActionWindow.js"
click node_trade_context "https://github.com/abhy9393/zerodha-clone/blob/main/Zerodha/dashboard/src/components/GeneralContext.js"
click node_api_server "https://github.com/abhy9393/zerodha-clone/blob/main/Zerodha/backend/index.js"
click node_auth_routes "https://github.com/abhy9393/zerodha-clone/blob/main/Zerodha/backend/routes/authRoutes.js"
click node_dashboard_routes "https://github.com/abhy9393/zerodha-clone/blob/main/Zerodha/backend/routes/dashboardRoutes.js"
click node_auth_middleware "https://github.com/abhy9393/zerodha-clone/blob/main/Zerodha/backend/middleware/authMiddleware.js"
click node_user_model "https://github.com/abhy9393/zerodha-clone/blob/main/Zerodha/backend/model/UserModel.js"
click node_holdings_model "https://github.com/abhy9393/zerodha-clone/blob/main/Zerodha/backend/model/HoldingsModel.js"
click node_positions_model "https://github.com/abhy9393/zerodha-clone/blob/main/Zerodha/backend/model/PositionsModel.js"
click node_orders_model "https://github.com/abhy9393/zerodha-clone/blob/main/Zerodha/backend/model/OrdersModel.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_site,node_home,node_products,node_pricing,node_support,node_signup,node_login,node_public_shell toneBlue
class node_dashboard_app,node_dashboard_home,node_watchlist,node_holdings_ui,node_positions_ui,node_orders_ui,node_funds_ui,node_buy_window,node_trade_context,node_mongo toneAmber
class node_api_server,node_auth_routes,node_dashboard_routes,node_auth_middleware toneMint
class node_user_model,node_holdings_model,node_positions_model,node_orders_model toneRose
class node_visitor toneIndigo
```

## Components

### Public website

- [Public site router](https://github.com/abhy9393/zerodha-clone/blob/main/Zerodha/frontend/src/App.js): `Zerodha/frontend/src/App.js`
- [Home and company](https://github.com/abhy9393/zerodha-clone/blob/main/Zerodha/frontend/src/landing_page/home/HomePage.js): `Zerodha/frontend/src/landing_page/home/HomePage.js`
- [Products](https://github.com/abhy9393/zerodha-clone/blob/main/Zerodha/frontend/src/landing_page/products/ProductsPage.js): `Zerodha/frontend/src/landing_page/products/ProductsPage.js`
- [Pricing](https://github.com/abhy9393/zerodha-clone/blob/main/Zerodha/frontend/src/landing_page/pricing/PricingPage.js): `Zerodha/frontend/src/landing_page/pricing/PricingPage.js`
- [Support](https://github.com/abhy9393/zerodha-clone/blob/main/Zerodha/frontend/src/landing_page/support/SupportPage.js): `Zerodha/frontend/src/landing_page/support/SupportPage.js`
- [Signup](https://github.com/abhy9393/zerodha-clone/blob/main/Zerodha/frontend/src/landing_page/signup/Signup.js): `Zerodha/frontend/src/landing_page/signup/Signup.js`
- [Login](https://github.com/abhy9393/zerodha-clone/blob/main/Zerodha/frontend/src/landing_page/signup/Login.js): `Zerodha/frontend/src/landing_page/signup/Login.js`
- [Navigation and footer](https://github.com/abhy9393/zerodha-clone/blob/main/Zerodha/frontend/src/landing_page/Navbar.js): `Zerodha/frontend/src/landing_page/Navbar.js`

### Trading dashboard

- [Dashboard entry](https://github.com/abhy9393/zerodha-clone/blob/main/Zerodha/dashboard/src/App.js): `Zerodha/dashboard/src/App.js`
- [Trading workspace](https://github.com/abhy9393/zerodha-clone/blob/main/Zerodha/dashboard/src/components/Home.js): `Zerodha/dashboard/src/components/Home.js`
- [Watchlist](https://github.com/abhy9393/zerodha-clone/blob/main/Zerodha/dashboard/src/components/WatchList.js): `Zerodha/dashboard/src/components/WatchList.js`
- [Holdings](https://github.com/abhy9393/zerodha-clone/blob/main/Zerodha/dashboard/src/components/Holdings.js): `Zerodha/dashboard/src/components/Holdings.js`
- [Positions](https://github.com/abhy9393/zerodha-clone/blob/main/Zerodha/dashboard/src/components/Positions.js): `Zerodha/dashboard/src/components/Positions.js`
- [Orders](https://github.com/abhy9393/zerodha-clone/blob/main/Zerodha/dashboard/src/components/Orders.js): `Zerodha/dashboard/src/components/Orders.js`
- [Funds](https://github.com/abhy9393/zerodha-clone/blob/main/Zerodha/dashboard/src/components/Funds.js): `Zerodha/dashboard/src/components/Funds.js`
- [Buy / sell window](https://github.com/abhy9393/zerodha-clone/blob/main/Zerodha/dashboard/src/components/BuyActionWindow.js): `Zerodha/dashboard/src/components/BuyActionWindow.js`
- [Trade window context](https://github.com/abhy9393/zerodha-clone/blob/main/Zerodha/dashboard/src/components/GeneralContext.js): `Zerodha/dashboard/src/components/GeneralContext.js`

### API and authentication

- [Express API](https://github.com/abhy9393/zerodha-clone/blob/main/Zerodha/backend/index.js): `Zerodha/backend/index.js`
- [Signup and login](https://github.com/abhy9393/zerodha-clone/blob/main/Zerodha/backend/routes/authRoutes.js): `Zerodha/backend/routes/authRoutes.js`
- [Dashboard access](https://github.com/abhy9393/zerodha-clone/blob/main/Zerodha/backend/routes/dashboardRoutes.js): `Zerodha/backend/routes/dashboardRoutes.js`
- [JWT verification](https://github.com/abhy9393/zerodha-clone/blob/main/Zerodha/backend/middleware/authMiddleware.js): `Zerodha/backend/middleware/authMiddleware.js`

### Persistent data

- [User records](https://github.com/abhy9393/zerodha-clone/blob/main/Zerodha/backend/model/UserModel.js): `Zerodha/backend/model/UserModel.js`
- [Holdings records](https://github.com/abhy9393/zerodha-clone/blob/main/Zerodha/backend/model/HoldingsModel.js): `Zerodha/backend/model/HoldingsModel.js`
- [Positions records](https://github.com/abhy9393/zerodha-clone/blob/main/Zerodha/backend/model/PositionsModel.js): `Zerodha/backend/model/PositionsModel.js`
- [Order records](https://github.com/abhy9393/zerodha-clone/blob/main/Zerodha/backend/model/OrdersModel.js): `Zerodha/backend/model/OrdersModel.js`

### Other components

- **Visitor / trader**
- **MongoDB**

## Connections

- Visitor / trader → Public site router: browses
- Public site router → Home and company: routes
- Public site router → Products: routes
- Public site router → Pricing: routes
- Public site router → Support: routes
- Public site router → Signup: routes
- Public site router → Login: routes
- Public site router → Navigation and footer: renders
- Visitor / trader → Dashboard entry: opens
- Dashboard entry → Trading workspace: renders
- Trading workspace → Watchlist
- Trading workspace → Holdings
- Trading workspace → Positions
- Trading workspace → Orders
- Trading workspace → Funds
- Trade window context → Buy / sell window: opens
- Express API → Signup and login: mounts
- Express API → Dashboard access: mounts
- Express API → JWT verification: protects data routes
- Signup and login → User records: finds and saves
- Dashboard access → JWT verification: invokes
- Express API → Holdings records: reads and updates
- Express API → Positions records: reads
- Express API → Order records: creates orders
- Express API → MongoDB: connects
- User records → MongoDB: persists
- Holdings records → MongoDB: persists
- Positions records → MongoDB: persists
- Order records → MongoDB: persists
