# keval101/trade-tracker architecture

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

- Interactive diagram: https://gitdiagram.com/keval101/trade-tracker
- Repository: https://github.com/keval101/trade-tracker

## Overview

1. **Repository shape**
   - This is a single-page Angular 16 application with a mostly client-side architecture.
   - The app is organized around business features in `src/app/components`, plus a small set of cross-cutting services, guards, and shared UI components.
   - There is no traditional long-running backend in the repo; the main server-side pieces are lightweight API endpoints under `api/` plus Firebase-managed backend services.

2. **Primary runtime and deployment model**
   - The frontend runs as an Angular SPA in the browser.
   - The repo is set up for modern deployment targets like Vercel and Firebase hosting/config (`vercel.json`, `firebase.json`).
   - Environment values are generated at build/start time by `scripts/generate-env.js`, which turns env variables into Angular environment configuration.

3. **Authentication boundary**
   - Firebase Authentication is the identity boundary for the app.
   - `src/app/service/auth.service.ts` centralizes login/signup/session logic.
   - `src/app/guards/auth.guard.ts` protects authenticated routes.
   - `src/app/interceptor/auth.interceptor.ts` adds auth-related request handling for outbound HTTP calls, so protected API access stays consistent across the app.

4. **Data persistence boundary**
   - Firebase is also the main persistence layer, likely through Firestore and Storage based on the README and file layout.
   - User profile, funds, trades, sheets, stocks, and related records appear to be managed through Angular services rather than a custom backend.
   - Profile image upload support in the account area suggests Firebase Storage is part of the storage path.

5. **Market-data integration boundary**
   - Live NSE market data is handled separately from the trading data model.
   - The `api/nse-index.ts` and `api/nse-search.ts` endpoints, together with `proxy.conf.json`, indicate a proxied API boundary for fetching index values and stock search/autocomplete data.
   - `src/app/service/market-data.service.ts` and `src/app/service/nse-data.service.ts` are the client-side abstraction layer for this external data.

6. **Application shell and global UI**
   - `AppComponent` plus shared components form the persistent shell around the feature pages.
   - `src/app/shared/sidenav` is the main navigation container.
   - `src/app/shared/loader` and `src/app/shared/screen-loader` indicate global loading states.
   - `src/app/shared/logo` is a reusable branding component.
   - The README’s “market ticker appears at the top of all pages” behavior is likely implemented in this shell layer.

7. **Feature area: dashboard and analytics**
   - `src/app/components/dashboard` is the landing/summary view for live market status, charts, and performance snapshots.
   - `src/app/components/overview` and `src/app/components/calculate-stoploss` support analytics and trading decision tools.
   - These screens likely combine internal financial data with external market data to render weekly performance and ROI views.

8. **Feature area: trade management**
   - `src/app/components/trades` handles the core trade ledger: add/delete and list trades.
   - The component split suggests a parent list page plus modal/dialog-style child workflows for create/delete actions.
   - This area is one of the main producers of financial metrics used elsewhere in the app.

9. **Feature area: trade sheets**
   - `src/app/components/trade-sheet` models planned trading campaigns or daily tracking sheets.
   - The sheet flow includes a form, entry dialog, and delete dialog, so the page likely supports creating a sheet and then appending daily P/L entries.
   - This subsystem is separate from raw trades and looks aimed at planning versus executed trade history.

10. **Feature area: account and funds**
    - `src/app/components/account` is the user profile and financial account workspace.
    - It includes profile editing, fund add/delete workflows, and a dedicated fund dialog.
    - This is where user-level metadata, deposits, withdrawals, and summary balances are maintained.

11. **Feature area: stock portfolio**
    - `src/app/components/stocks` manages a stock watch/holdings style portfolio.
    - Add/delete subcomponents and the README’s “quick search” imply integration with NSE search data for symbol lookup.
    - This area bridges internal portfolio records with live market identity data.

12. **Auxiliary feature areas**
    - `src/app/components/holiday-list` provides holiday/calendar awareness, likely used to determine market open/closed state.
    - `src/app/components/login` and `signup` are the entry points into the authenticated flow.
    - These are smaller, but they support the overall market-status and user onboarding story.

13. **Data flow through the app**
    - User actions start in routed feature components, move into Angular services, and then either:
      - persist to Firebase-backed data stores, or
      - fetch live NSE data via the `api/` endpoints.
    - The resulting data is then rendered by dashboard, overview, trades, sheets, stocks, and account screens.
    - Shared shell components keep navigation, loaders, and ticker-like UI consistent across routes.

14. **Styling, UI system, and build tooling**
    - The UI stack is Angular plus Tailwind CSS, with SCSS used per component for local styling.
    - `angular.json`, `tailwind.config.js`, and `postcss.config.js` define the front-end build pipeline.
    - The repo includes standard Angular testing setup, but the architecture is primarily driven by routed components and reusable services rather than a separate state-management library.

Main entry points: [`src/app/service/data.service.ts`](https://github.com/keval101/trade-tracker/blob/main/src/app/service/data.service.ts) (Data service), [`src/app/app.component.ts`](https://github.com/keval101/trade-tracker/blob/main/src/app/app.component.ts) (App shell), [`src/app/guards/auth.guard.ts`](https://github.com/keval101/trade-tracker/blob/main/src/app/guards/auth.guard.ts) (Auth guard), [`vercel.json`](https://github.com/keval101/trade-tracker/blob/main/vercel.json) (Deploy config)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Angular SPA"]
  node_app_component["App shell<br/>Angular root<br/>[app.component.ts]"]
  node_sidenav["Side nav<br/>navigation UI"]
  node_loader["Loader<br/>global UI"]
  node_screen_loader["Screen loader<br/>global UI"]
end

subgraph group_features["Business features"]
  node_login["Login<br/>auth page<br/>[login.component.ts]"]
  node_signup["Signup<br/>auth page"]
  node_dashboard["Dashboard<br/>summary view"]
  node_overview["Overview<br/>analytics view"]
  node_stoploss["Stoploss tool<br/>calculator"]
  node_trades["Trades<br/>trade ledger"]
  node_trade_sheet["Trade sheet<br/>planning ledger"]
  node_account["Account<br/>profile & funds"]
  node_stocks["Stocks<br/>portfolio view"]
  node_holidays["Holiday list<br/>calendar view"]
end

subgraph group_services["Core services"]
  node_auth_service["Auth service<br/>identity service<br/>[auth.service.ts]"]
  node_data_service["Data service<br/>[data.service.ts]"]
  node_market_service["Market data<br/>market service"]
  node_nse_service["NSE data<br/>nse service"]
  node_auth_guard["Auth guard<br/>route guard<br/>[auth.guard.ts]"]
  node_auth_interceptor["Auth interceptor<br/>http interceptor"]
end

subgraph group_platform["Platform"]
  node_nse_index_api["NSE index API<br/>serverless endpoint<br/>[nse-index.ts]"]
  node_nse_search_api["NSE search API<br/>serverless endpoint<br/>[nse-search.ts]"]
  node_env_gen["Env generator<br/>build script<br/>[generate-env.js]"]
  node_deployment["Deploy config<br/>hosting config<br/>[vercel.json]"]
end

node_app_component -->|"renders"| node_sidenav
node_app_component -->|"hosts"| node_loader
node_app_component -->|"hosts"| node_screen_loader
node_app_component -->|"routes to"| node_dashboard
node_app_component -->|"routes to"| node_login
node_app_component -->|"routes to"| node_signup
node_app_component -->|"routes to"| node_overview
node_auth_guard -->|"protects"| node_dashboard
node_auth_guard -->|"protects"| node_overview
node_auth_guard -->|"protects"| node_trades
node_auth_guard -->|"protects"| node_trade_sheet
node_auth_guard -->|"protects"| node_account
node_auth_guard -->|"protects"| node_stocks
node_auth_service -->|"drives"| node_login
node_auth_service -->|"drives"| node_signup
node_auth_interceptor -->|"secures"| node_data_service
node_data_service -->|"persists"| node_trades
node_data_service -->|"persists"| node_trade_sheet
node_data_service -->|"persists"| node_account
node_data_service -->|"persists"| node_stocks
node_market_service -->|"wraps"| node_nse_service
node_nse_service -->|"fetches"| node_nse_index_api
node_nse_service -->|"fetches"| node_nse_search_api
node_dashboard -->|"consumes"| node_market_service
node_overview -->|"analyzes"| node_data_service
node_stoploss -->|"consumes"| node_market_service
node_stocks -->|"searches"| node_nse_service
node_account -->|"updates"| node_data_service
node_trade_sheet -->|"updates"| node_data_service
node_trades -->|"updates"| node_data_service
node_env_gen -->|"feeds"| node_deployment
node_deployment -->|"hosts"| node_app_component
node_deployment -->|"routes"| node_nse_index_api
node_deployment -->|"routes"| node_nse_search_api
node_holidays -->|"supports"| node_dashboard

click node_app_component "https://github.com/keval101/trade-tracker/blob/main/src/app/app.component.ts"
click node_sidenav "https://github.com/keval101/trade-tracker/blob/main/src/app/shared/sidenav/sidenav.component.ts"
click node_loader "https://github.com/keval101/trade-tracker/blob/main/src/app/shared/loader/loader.component.ts"
click node_screen_loader "https://github.com/keval101/trade-tracker/blob/main/src/app/shared/screen-loader/screen-loader.component.ts"
click node_login "https://github.com/keval101/trade-tracker/blob/main/src/app/components/login/login.component.ts"
click node_signup "https://github.com/keval101/trade-tracker/blob/main/src/app/components/signup/signup.component.ts"
click node_dashboard "https://github.com/keval101/trade-tracker/blob/main/src/app/components/dashboard/dashboard.component.ts"
click node_overview "https://github.com/keval101/trade-tracker/blob/main/src/app/components/overview/overview.component.ts"
click node_stoploss "https://github.com/keval101/trade-tracker/blob/main/src/app/components/calculate-stoploss/calculate-stoploss.component.ts"
click node_trades "https://github.com/keval101/trade-tracker/blob/main/src/app/components/trades/trades.component.ts"
click node_trade_sheet "https://github.com/keval101/trade-tracker/blob/main/src/app/components/trade-sheet/trade-sheet.component.ts"
click node_account "https://github.com/keval101/trade-tracker/blob/main/src/app/components/account/account.component.ts"
click node_stocks "https://github.com/keval101/trade-tracker/blob/main/src/app/components/stocks/stocks.component.ts"
click node_holidays "https://github.com/keval101/trade-tracker/blob/main/src/app/components/holiday-list/holiday-list.component.ts"
click node_auth_service "https://github.com/keval101/trade-tracker/blob/main/src/app/service/auth.service.ts"
click node_data_service "https://github.com/keval101/trade-tracker/blob/main/src/app/service/data.service.ts"
click node_market_service "https://github.com/keval101/trade-tracker/blob/main/src/app/service/market-data.service.ts"
click node_nse_service "https://github.com/keval101/trade-tracker/blob/main/src/app/service/nse-data.service.ts"
click node_auth_guard "https://github.com/keval101/trade-tracker/blob/main/src/app/guards/auth.guard.ts"
click node_auth_interceptor "https://github.com/keval101/trade-tracker/blob/main/src/app/interceptor/auth.interceptor.ts"
click node_nse_index_api "https://github.com/keval101/trade-tracker/blob/main/api/nse-index.ts"
click node_nse_search_api "https://github.com/keval101/trade-tracker/blob/main/api/nse-search.ts"
click node_env_gen "https://github.com/keval101/trade-tracker/blob/main/scripts/generate-env.js"
click node_deployment "https://github.com/keval101/trade-tracker/blob/main/vercel.json"

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_app_component,node_sidenav,node_loader,node_screen_loader toneBlue
class node_login,node_signup,node_dashboard,node_overview,node_stoploss,node_trades,node_trade_sheet,node_account,node_stocks,node_holidays toneAmber
class node_auth_service,node_data_service,node_market_service,node_nse_service,node_auth_guard,node_auth_interceptor toneMint
class node_nse_index_api,node_nse_search_api,node_env_gen,node_deployment toneRose
```

## Components

### Angular SPA

Browser-based application shell and routed feature pages.

- [App shell](https://github.com/keval101/trade-tracker/blob/main/src/app/app.component.ts): Angular root · Persistent application frame around routed pages and global UI. · `src/app/app.component.ts`
- [Side nav](https://github.com/keval101/trade-tracker/blob/main/src/app/shared/sidenav/sidenav.component.ts): navigation UI · Primary navigation container used across the app. · `src/app/shared/sidenav/sidenav.component.ts`
- [Loader](https://github.com/keval101/trade-tracker/blob/main/src/app/shared/loader/loader.component.ts): global UI · Shared loading indicator for app-wide async states. · `src/app/shared/loader/loader.component.ts`
- [Screen loader](https://github.com/keval101/trade-tracker/blob/main/src/app/shared/screen-loader/screen-loader.component.ts): global UI · Full-screen loading state used during blocking transitions. · `src/app/shared/screen-loader/screen-loader.component.ts`

### Business features

Main user-facing workflows organized under app components.

- [Login](https://github.com/keval101/trade-tracker/blob/main/src/app/components/login/login.component.ts): auth page · Sign-in entry point for authenticated access. · `src/app/components/login/login.component.ts`
- [Signup](https://github.com/keval101/trade-tracker/blob/main/src/app/components/signup/signup.component.ts): auth page · Account creation entry point. · `src/app/components/signup/signup.component.ts`
- [Dashboard](https://github.com/keval101/trade-tracker/blob/main/src/app/components/dashboard/dashboard.component.ts): summary view · Landing page for market status, charts, and performance snapshots. · `src/app/components/dashboard/dashboard.component.ts`
- [Overview](https://github.com/keval101/trade-tracker/blob/main/src/app/components/overview/overview.component.ts): analytics view · Performance and ROI analysis screen for the trading history. · `src/app/components/overview/overview.component.ts`
- [Stoploss tool](https://github.com/keval101/trade-tracker/blob/main/src/app/components/calculate-stoploss/calculate-stoploss.component.ts): calculator · Trading decision aid for calculating stop-loss levels. · `src/app/components/calculate-stoploss/calculate-stoploss.component.ts`
- [Trades](https://github.com/keval101/trade-tracker/blob/main/src/app/components/trades/trades.component.ts): trade ledger · Core trade list and add/delete workflows. · `src/app/components/trades/trades.component.ts`
- [Trade sheet](https://github.com/keval101/trade-tracker/blob/main/src/app/components/trade-sheet/trade-sheet.component.ts): planning ledger · Planned trading campaigns and daily P/L entry flow. · `src/app/components/trade-sheet/trade-sheet.component.ts`
- [Account](https://github.com/keval101/trade-tracker/blob/main/src/app/components/account/account.component.ts): profile & funds · User profile, balances, and fund management workspace. · `src/app/components/account/account.component.ts`
- [Stocks](https://github.com/keval101/trade-tracker/blob/main/src/app/components/stocks/stocks.component.ts): portfolio view · Stock holdings/watchlist management with symbol lookup. · `src/app/components/stocks/stocks.component.ts`
- [Holiday list](https://github.com/keval101/trade-tracker/blob/main/src/app/components/holiday-list/holiday-list.component.ts): calendar view · Market holiday awareness for trading context. · `src/app/components/holiday-list/holiday-list.component.ts`

### Core services

Authentication, data access, and market-data integration boundaries.

- [Auth service](https://github.com/keval101/trade-tracker/blob/main/src/app/service/auth.service.ts): identity service · Centralized login, signup, and session handling. · `src/app/service/auth.service.ts`
- [Data service](https://github.com/keval101/trade-tracker/blob/main/src/app/service/data.service.ts): app data service · Shared persistence access for user and trading records. · `src/app/service/data.service.ts`
- [Market data](https://github.com/keval101/trade-tracker/blob/main/src/app/service/market-data.service.ts): market service · Client-side abstraction over live market data requests. · `src/app/service/market-data.service.ts`
- [NSE data](https://github.com/keval101/trade-tracker/blob/main/src/app/service/nse-data.service.ts): nse service · Specialized service for NSE index and search data. · `src/app/service/nse-data.service.ts`
- [Auth guard](https://github.com/keval101/trade-tracker/blob/main/src/app/guards/auth.guard.ts): route guard · Protects authenticated routes. · `src/app/guards/auth.guard.ts`
- [Auth interceptor](https://github.com/keval101/trade-tracker/blob/main/src/app/interceptor/auth.interceptor.ts): http interceptor · Adds auth-related handling to outbound HTTP calls. · `src/app/interceptor/auth.interceptor.ts`

### Platform

API endpoints, build-time env generation, and deployment config.

- [NSE index API](https://github.com/keval101/trade-tracker/blob/main/api/nse-index.ts): serverless endpoint · Proxied endpoint for index values. · `api/nse-index.ts`
- [NSE search API](https://github.com/keval101/trade-tracker/blob/main/api/nse-search.ts): serverless endpoint · Proxied endpoint for stock search and autocomplete. · `api/nse-search.ts`
- [Env generator](https://github.com/keval101/trade-tracker/blob/main/scripts/generate-env.js): build script · Generates Angular environment values from process env. · `scripts/generate-env.js`
- [Deploy config](https://github.com/keval101/trade-tracker/blob/main/vercel.json): hosting config · Platform configuration for hosting and proxying. · `vercel.json`

## Connections

- App shell → Side nav: renders · Shell includes persistent navigation.
- App shell → Loader: hosts · Global loading indicator lives in the shell.
- App shell → Screen loader: hosts · Blocking load state is part of the shell.
- App shell → Dashboard: routes to · Default landing view after navigation.
- App shell → Login: routes to · Unauthenticated entry page.
- App shell → Signup: routes to · Account creation page.
- App shell → Overview: routes to · Analytics page accessible from the shell.
- Auth guard → Dashboard: protects · Authenticated routes are guarded.
- Auth guard → Overview: protects · Authenticated routes are guarded.
- Auth guard → Trades: protects · Authenticated routes are guarded.
- Auth guard → Trade sheet: protects · Authenticated routes are guarded.
- Auth guard → Account: protects · Authenticated routes are guarded.
- Auth guard → Stocks: protects · Authenticated routes are guarded.
- Auth service → Login: drives · Login page uses centralized identity logic.
- Auth service → Signup: drives · Signup page uses centralized identity logic.
- Auth interceptor → Data service: secures · HTTP calls are decorated for authenticated access.
- Data service → Trades: persists · Trade ledger reads and writes shared records.
- Data service → Trade sheet: persists · Trade sheet data is stored through shared services.
- Data service → Account: persists · Profile and fund data are managed through services.
- Data service → Stocks: persists · Portfolio records are managed through shared services.
- Market data → NSE data: wraps · Market service builds on the NSE-specific abstraction.
- NSE data → NSE index API: fetches · Live index data comes through serverless endpoint.
- NSE data → NSE search API: fetches · Search/autocomplete data comes through serverless endpoint.
- Dashboard → Market data: consumes · Dashboard mixes internal and external market inputs.
- Overview → Data service: analyzes · Overview uses internal performance data.
- Stoploss tool → Market data: consumes · Stop-loss calculations use market inputs.
- Stocks → NSE data: searches · Stock lookup relies on live NSE search data.
- Account → Data service: updates · Profile edits and fund actions persist through services.
- Trade sheet → Data service: updates · Sheet entries and deletes persist through services.
- Trades → Data service: updates · Add and delete trade workflows persist through services.
- Env generator → Deploy config: feeds · Generated environment values support deployment targets.
- Deploy config → App shell: hosts · SPA is deployed through hosting configuration.
- Deploy config → NSE index API: routes · Proxy/configuration supports API boundary.
- Deploy config → NSE search API: routes · Proxy/configuration supports API boundary.
- Holiday list → Dashboard: supports · Holiday context informs market-status views.
