# dkmishra2407/growup architecture

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

- Interactive diagram: https://gitdiagram.com/dkmishra2407/growup
- Repository: https://github.com/dkmishra2407/growup

## Overview

1. **Repository shape**
   - This is a **three-service monorepo**: a React frontend, a Node/Express backend, and a separate FastAPI backend.
   - The architecture is split by responsibility: **UI**, **persistent app data / CRUD APIs**, and **market-data / simulation services**.

2. **Frontend: user-facing application**
   - The `frontend/` app is a **React 18 + TypeScript + Vite** SPA.
   - It is styled with **TailwindCSS** and organized into:
     - `pages/` for screens like Dashboard, Orders, Watchlist, StockList, StockDetail, Login, SignUp, etc.
     - `components/` for shared UI such as Navbar, Footer, PrivateRoute, and report generation.
     - `store/authStore.ts` for client-side auth/session state.
     - `services/api.ts` for all backend calls.
   - `App.tsx` and `main.tsx` likely define the route shell and app bootstrap.

3. **Frontend access control and navigation**
   - `PrivateRoute.tsx` indicates route-level protection for authenticated areas such as dashboard, holdings, orders, and watchlist.
   - The UI is centered around a trading workflow: browse stocks, view details, simulate trades, and inspect portfolio state.
   - The frontend is the orchestration layer that combines data from the backend APIs and renders the user journey.

4. **Node/Express backend: application data service**
   - The `backend/` service is structured as a classic **Express MVC API**:
     - `Routes/` exposes HTTP endpoints.
     - `Controller/` contains request handling and business logic.
     - `Models/` defines the data entities.
     - `dbconfig/` centralizes database connection setup.
   - The models present are `User`, `Holding`, and `Watchlist`, which strongly suggests the Node service owns **account data, portfolio holdings, and watchlist persistence**.
   - This backend is the main CRUD/API layer for user-centric application state.

5. **Node backend boundaries**
   - The Node service appears to be the bridge between the frontend and the database.
   - It likely handles:
     - registration/login-related user operations,
     - storing simulated buy/sell outcomes as holdings,
     - managing user watchlists.
   - The presence of `server.js` and a Dockerfile indicates it is deployed as an independent service.

6. **FastAPI backend: market-data and simulation engine**
   - The `fastapi_backend/` service is a separate Python API built with **FastAPI** and run via **Uvicorn**.
   - The README describes it as the high-performance backend for:
     - live NSE stock data,
     - real-time updates,
     - caching with TTL,
     - portfolio analysis and suggestions,
     - WebSocket-based streaming.
   - This service is the likely source of **market prices and analytical computations**, not user persistence.

7. **Real-time data flow**
   - The key runtime flow is:
     - frontend loads stock list/detail views,
     - it fetches persisted app state from the Node backend,
     - it subscribes to real-time market updates from the FastAPI service using **WebSockets / socket.io-client**,
     - the UI updates prices, charts, and summaries as data changes.
   - In other words, **persistent state and live market state come from different backends**.

8. **Data ownership and persistence**
   - The Node backend owns the durable entities represented in `Models/`: users, holdings, and watchlists.
   - The FastAPI backend appears to be more stateless or lightly stateful, using **TTL cache** to reduce repeated upstream stock-data lookups.
   - This split is important for architecture: **database-backed app state** is separated from **ephemeral/streaming market data**.

9. **Domain features mapped to components**
   - The repository supports a virtual trading domain:
     - stock discovery and stock detail pages,
     - simulated orders,
     - holdings and portfolio tracking,
     - watchlist management,
     - dashboard/reporting.
   - `reportgeneration.tsx` and the dashboard pages suggest portfolio summaries and analysis are surfaced directly in the frontend, likely using API results from the backend services.

10. **Deployment and containerization**
    - Each major service has its own Dockerfile, and there is a top-level `docker-compose.yml`, so the repo is intended to be run as **multiple containers**.
    - That implies clear service boundaries and independent scaling/deployment of frontend, Node API, and Python API.
    - The README mentions Render/AWS EC2 as deployment targets, but the repo itself is structured to support container-based local and cloud deployment.

11. **Integration points to note in a diagram**
    - Draw the frontend as the central consumer.
    - Connect it to:
      - the **Node/Express API** for authentication, holdings, watchlists, and other persisted user state,
      - the **FastAPI service** for live prices, WebSocket streams, and analysis.
    - Place the database behind the Node backend, since the repo structure strongly implies that service owns persistence.

12. **One important caveat**
    - The README mentions `Flask` and `combined_app.py`, but the actual tree shows a **FastAPI** service in `fastapi_backend/`. The architecture in the repository tree should be treated as the source of truth.

Main entry points: [`frontend/src/App.tsx`](https://github.com/dkmishra2407/growup/blob/main/frontend/src/App.tsx) (App shell), [`backend/Models`](https://github.com/dkmishra2407/growup/tree/main/backend/Models) (Models), [`fastapi_backend/app.py`](https://github.com/dkmishra2407/growup/blob/main/fastapi_backend/app.py) (FastAPI app), [`frontend/src/services/api.ts`](https://github.com/dkmishra2407/growup/blob/main/frontend/src/services/api.ts) (API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend"]
  node_frontend_app["App shell<br/>react-vite spa<br/>[App.tsx]"]
  node_frontend_main["Bootstrap<br/>entrypoint<br/>[main.tsx]"]
  node_frontend_pages["Screens<br/>routes/views"]
  node_frontend_components["Shared UI<br/>ui components"]
  node_frontend_store[("Auth store<br/>client state<br/>[authStore.ts]")]
  node_frontend_api["API client<br/>http client<br/>[api.ts]"]
end

subgraph group_node_backend["Node API"]
  node_node_server["Server<br/>express entrypoint<br/>[server.js]"]
  node_node_routes["Routes"]
  node_node_controllers["Controllers<br/>request logic"]
  node_node_models[("Models")]
  node_node_dbconfig["DB config<br/>database setup<br/>[dbconfig.js]"]
  node_node_users["Users<br/>model<br/>[UserModel.js]"]
  node_node_holdings["Holdings<br/>model<br/>[HoldingModel.js]"]
  node_node_watchlist["Watchlist<br/>model<br/>[WatchlistModel.js]"]
end

subgraph group_fastapi_backend["FastAPI Service"]
  node_fastapi_app["FastAPI app<br/>python api<br/>[app.py]"]
  node_fastapi_market["Market data<br/>live feed<br/>[app.py]"]
  node_fastapi_cache[("TTL cache<br/>ephemeral cache<br/>[app.py]")]
  node_fastapi_analysis["Analysis<br/>portfolio engine<br/>[app.py]"]
end

node_frontend_main -->|"bootstraps"| node_frontend_app
node_frontend_app -->|"routes to"| node_frontend_pages
node_frontend_app -->|"uses"| node_frontend_components
node_frontend_app -->|"reads auth"| node_frontend_store
node_frontend_app -->|"calls"| node_frontend_api
node_frontend_components -->|"guards routes"| node_frontend_store
node_frontend_components -->|"renders reports"| node_frontend_api
node_frontend_api -->|"CRUD API"| node_node_server
node_frontend_api -->|"market feed"| node_fastapi_app
node_node_server -->|"exposes"| node_node_routes
node_node_routes -->|"delegates"| node_node_controllers
node_node_controllers -->|"persists via"| node_node_models
node_node_models -->|"includes"| node_node_users
node_node_models -->|"includes"| node_node_holdings
node_node_models -->|"includes"| node_node_watchlist
node_node_models -->|"connects to"| node_node_dbconfig
node_fastapi_app -->|"serves"| node_fastapi_market
node_fastapi_app -->|"uses"| node_fastapi_cache
node_fastapi_app -->|"computes"| node_fastapi_analysis

click node_frontend_app "https://github.com/dkmishra2407/growup/blob/main/frontend/src/App.tsx"
click node_frontend_main "https://github.com/dkmishra2407/growup/blob/main/frontend/src/main.tsx"
click node_frontend_pages "https://github.com/dkmishra2407/growup/tree/main/frontend/src/pages"
click node_frontend_components "https://github.com/dkmishra2407/growup/tree/main/frontend/src/components"
click node_frontend_store "https://github.com/dkmishra2407/growup/blob/main/frontend/src/store/authStore.ts"
click node_frontend_api "https://github.com/dkmishra2407/growup/blob/main/frontend/src/services/api.ts"
click node_node_server "https://github.com/dkmishra2407/growup/blob/main/backend/server.js"
click node_node_routes "https://github.com/dkmishra2407/growup/tree/main/backend/Routes"
click node_node_controllers "https://github.com/dkmishra2407/growup/tree/main/backend/Controller"
click node_node_models "https://github.com/dkmishra2407/growup/tree/main/backend/Models"
click node_node_dbconfig "https://github.com/dkmishra2407/growup/blob/main/backend/dbconfig/dbconfig.js"
click node_node_users "https://github.com/dkmishra2407/growup/blob/main/backend/Models/UserModel.js"
click node_node_holdings "https://github.com/dkmishra2407/growup/blob/main/backend/Models/HoldingModel.js"
click node_node_watchlist "https://github.com/dkmishra2407/growup/blob/main/backend/Models/WatchlistModel.js"
click node_fastapi_app "https://github.com/dkmishra2407/growup/blob/main/fastapi_backend/app.py"
click node_fastapi_market "https://github.com/dkmishra2407/growup/blob/main/fastapi_backend/app.py"
click node_fastapi_cache "https://github.com/dkmishra2407/growup/blob/main/fastapi_backend/app.py"
click node_fastapi_analysis "https://github.com/dkmishra2407/growup/blob/main/fastapi_backend/app.py"

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_frontend_app,node_frontend_main,node_frontend_pages,node_frontend_components,node_frontend_store,node_frontend_api toneBlue
class node_node_server,node_node_routes,node_node_controllers,node_node_models,node_node_dbconfig,node_node_users,node_node_holdings,node_node_watchlist toneAmber
class node_fastapi_app,node_fastapi_market,node_fastapi_cache,node_fastapi_analysis toneMint
```

## Components

### Frontend

React SPA for trading workflow and user interaction.

- [App shell](https://github.com/dkmishra2407/growup/blob/main/frontend/src/App.tsx): react-vite spa · Top-level React application bootstrap and routing shell. · `frontend/src/App.tsx`
- [Bootstrap](https://github.com/dkmishra2407/growup/blob/main/frontend/src/main.tsx): entrypoint · Client entrypoint that mounts the SPA. · `frontend/src/main.tsx`
- [Screens](https://github.com/dkmishra2407/growup/tree/main/frontend/src/pages): routes/views · Primary user flows for dashboard, trading, login, and stock exploration. · `frontend/src/pages`
- [Shared UI](https://github.com/dkmishra2407/growup/tree/main/frontend/src/components): ui components · Reusable layout, navigation, access control, and reporting components. · `frontend/src/components`
- [Auth store](https://github.com/dkmishra2407/growup/blob/main/frontend/src/store/authStore.ts): client state · Client-side authentication and session state. · `frontend/src/store/authStore.ts`
- [API client](https://github.com/dkmishra2407/growup/blob/main/frontend/src/services/api.ts): http client · Frontend service layer for calling backend APIs. · `frontend/src/services/api.ts`

### Node API

Express service for authenticated app data and persistence.

- [Server](https://github.com/dkmishra2407/growup/blob/main/backend/server.js): express entrypoint · Node service startup and HTTP server wiring. · `backend/server.js`
- [Routes](https://github.com/dkmishra2407/growup/tree/main/backend/Routes): express routes · HTTP endpoint definitions for users, holdings, and watchlists. · `backend/Routes`
- [Controllers](https://github.com/dkmishra2407/growup/tree/main/backend/Controller): request logic · Request handling and business logic for CRUD operations. · `backend/Controller`
- [Models](https://github.com/dkmishra2407/growup/tree/main/backend/Models): data models · Persistent entities for users, holdings, and watchlists. · `backend/Models`
- [DB config](https://github.com/dkmishra2407/growup/blob/main/backend/dbconfig/dbconfig.js): database setup · Database connection and configuration layer. · `backend/dbconfig/dbconfig.js`
- [Users](https://github.com/dkmishra2407/growup/blob/main/backend/Models/UserModel.js): model · Account records and authentication-related user data. · `backend/Models/UserModel.js`
- [Holdings](https://github.com/dkmishra2407/growup/blob/main/backend/Models/HoldingModel.js): model · Portfolio positions and simulated trade outcomes. · `backend/Models/HoldingModel.js`
- [Watchlist](https://github.com/dkmishra2407/growup/blob/main/backend/Models/WatchlistModel.js): model · Saved symbols and user watchlist state. · `backend/Models/WatchlistModel.js`

### FastAPI Service

Python service for live market data and analysis.

- [FastAPI app](https://github.com/dkmishra2407/growup/blob/main/fastapi_backend/app.py): python api · Python API entrypoint for market-data and analysis services. · `fastapi_backend/app.py`
- [Market data](https://github.com/dkmishra2407/growup/blob/main/fastapi_backend/app.py): live feed · Live NSE stock data and real-time updates. · `fastapi_backend/app.py`
- [TTL cache](https://github.com/dkmishra2407/growup/blob/main/fastapi_backend/app.py): ephemeral cache · Short-lived caching to reduce repeated market-data fetches. · `fastapi_backend/app.py`
- [Analysis](https://github.com/dkmishra2407/growup/blob/main/fastapi_backend/app.py): portfolio engine · Portfolio analysis, suggestions, and computed insights. · `fastapi_backend/app.py`

## Connections

- Bootstrap → App shell: bootstraps · Client entrypoint mounts the React application.
- App shell → Screens: routes to · App shell renders the user-facing screens.
- App shell → Shared UI: uses · Shared layout and navigation are composed into the shell.
- App shell → Auth store: reads auth · Route protection and session state come from the auth store.
- App shell → API client: calls · The SPA uses a single API client for backend requests.
- Shared UI → Auth store: guards routes · PrivateRoute consults auth state before rendering protected areas.
- Shared UI → API client: renders reports · Shared UI can request and display backend-driven summaries.
- API client → Server: CRUD API · Frontend persisted-state requests go to the Node service.
- API client → FastAPI app: market feed · Frontend consumes live market data and analysis from FastAPI.
- Server → Routes: exposes · Server wires the route layer.
- Routes → Controllers: delegates · Routes hand off request handling to controllers.
- Controllers → Models: persists via · Controllers operate on the application data models.
- Models → Users: includes · User entity definition.
- Models → Holdings: includes · Holding entity definition.
- Models → Watchlist: includes · Watchlist entity definition.
- Models → DB config: connects to · Models are backed by the configured database connection.
- FastAPI app → Market data: serves · Core FastAPI responsibility is live stock data.
- FastAPI app → TTL cache: uses · Market-data requests are cached with TTL.
- FastAPI app → Analysis: computes · Service returns portfolio analysis and suggestions.
