# tanishqsarkar/portfoliomanager architecture

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

- Interactive diagram: https://gitdiagram.com/tanishqsarkar/portfoliomanager
- Repository: https://github.com/tanishqsarkar/portfoliomanager

## Overview

NSE Portfolio Manager is a browser-based portfolio tracker: users authenticate, select or manage portfolios, then review and update holdings and see portfolio metrics. Supabase provides authentication and private persisted portfolio data; market quotes remain simulated in a client-side service. The graph covers the dashboard’s key views, stock entry, calculations, and documented database/RLS capability. Some page-to-component wiring is supported by the source index rather than full excerpts; unsampled details are not inferred.

Main entry points: [`src/pages/DashboardPage.tsx`](https://github.com/tanishqsarkar/portfoliomanager/blob/main/src/pages/DashboardPage.tsx) (Dashboard Orchestrator), [`src/context/PortfolioContext.tsx`](https://github.com/tanishqsarkar/portfoliomanager/blob/main/src/context/PortfolioContext.tsx) (Portfolio and Holding State), [`src/App.tsx`](https://github.com/tanishqsarkar/portfoliomanager/blob/main/src/App.tsx) (Routes and Guards), [`src/context/AuthContext.tsx`](https://github.com/tanishqsarkar/portfoliomanager/blob/main/src/context/AuthContext.tsx) (Authentication State)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App and Access"]
  node_app_router["Routes and Guards<br/>[App.tsx]"]
  node_login["Sign-in and Recovery<br/>[LoginPage.tsx]"]
  node_auth["Authentication State<br/>[AuthContext.tsx]"]
  node_setup["Setup Notice"]
end

subgraph group_portfolio["Portfolio Data"]
  node_client["Supabase Client<br/>[supabaseClient.ts]"]
  node_schema["Tables and RLS<br/>[schema.sql]"]
  node_portfolio_state["Portfolio and Holding State"]
  node_selection["Portfolio Selection"]
end

subgraph group_market["Market and Metrics"]
  node_market_service["Demo Quote Catalog"]
  node_calculations["Portfolio Calculations<br/>[calculations.ts]"]
  node_format["Number Formatting<br/>[format.ts]"]
end

subgraph group_dashboard["Portfolio Views"]
  node_dashboard_page["Dashboard Orchestrator<br/>[DashboardPage.tsx]"]
  node_summary["Summary Cards<br/>[SummaryCards.tsx]"]
  node_allocation["Allocation Chart"]
  node_holdings["Search and Sort Holdings<br/>[HoldingsList.tsx]"]
  node_gainers["Gainer and Loser Cards"]
  node_stock_modal["Add and Edit Stock<br/>[AddStockModal.tsx]"]
  node_portfolio_card["Portfolio Card<br/>[PortfolioCard.tsx]"]
  node_demo_banner["Demo Data Banner<br/>[DemoModeBanner.tsx]"]
end

node_investor(("Investor"))
node_supabase[("Supabase Auth and Postgres")]

node_investor -->|"opens app"| node_app_router
node_app_router -->|"routes to"| node_login
node_app_router -->|"routes to"| node_selection
node_app_router -->|"routes to"| node_dashboard_page
node_app_router -->|"shows when unconfigured"| node_setup
node_app_router -->|"provides auth"| node_auth
node_app_router -->|"provides state"| node_portfolio_state
node_login -->|"requests auth"| node_auth
node_auth -->|"uses client"| node_client
node_client -->|"connects to"| node_supabase
node_portfolio_state -->|"reads user"| node_auth
node_portfolio_state -->|"reads and writes"| node_client
node_portfolio_state -->|"loads and persists"| node_supabase
node_schema -->|"defines tables and RLS"| node_supabase
node_selection -->|"uses portfolio data"| node_portfolio_state
node_selection -->|"renders cards"| node_portfolio_card
node_dashboard_page -->|"reads user"| node_auth
node_dashboard_page -->|"reads and updates"| node_portfolio_state
node_portfolio_state -->|"enriches with quotes"| node_market_service
node_dashboard_page -->|"computes metrics"| node_calculations
node_dashboard_page -->|"renders"| node_summary
node_dashboard_page -->|"renders"| node_allocation
node_dashboard_page -->|"renders"| node_holdings
node_dashboard_page -->|"renders"| node_gainers
node_dashboard_page -->|"opens for edits"| node_stock_modal
node_holdings -->|"sorts with"| node_calculations
node_stock_modal -->|"searches catalog"| node_market_service
node_stock_modal -.->|"submits changes"| node_portfolio_state
node_portfolio_state -->|"refreshes quotes"| node_market_service
node_dashboard_page -->|"shows demo status"| node_demo_banner
node_holdings -->|"formats values"| node_format
node_allocation -->|"formats values"| node_format
node_gainers -->|"formats values"| node_format
node_portfolio_card -->|"computes summary"| node_calculations

click node_app_router "https://github.com/tanishqsarkar/portfoliomanager/blob/main/src/App.tsx"
click node_login "https://github.com/tanishqsarkar/portfoliomanager/blob/main/src/pages/LoginPage.tsx"
click node_auth "https://github.com/tanishqsarkar/portfoliomanager/blob/main/src/context/AuthContext.tsx"
click node_setup "https://github.com/tanishqsarkar/portfoliomanager/blob/main/src/pages/SupabaseSetupNotice.tsx"
click node_client "https://github.com/tanishqsarkar/portfoliomanager/blob/main/src/lib/supabaseClient.ts"
click node_schema "https://github.com/tanishqsarkar/portfoliomanager/blob/main/supabase/schema.sql"
click node_portfolio_state "https://github.com/tanishqsarkar/portfoliomanager/blob/main/src/context/PortfolioContext.tsx"
click node_selection "https://github.com/tanishqsarkar/portfoliomanager/blob/main/src/pages/PortfolioSelectionPage.tsx"
click node_market_service "https://github.com/tanishqsarkar/portfoliomanager/blob/main/src/services/marketDataService.ts"
click node_calculations "https://github.com/tanishqsarkar/portfoliomanager/blob/main/src/utils/calculations.ts"
click node_dashboard_page "https://github.com/tanishqsarkar/portfoliomanager/blob/main/src/pages/DashboardPage.tsx"
click node_summary "https://github.com/tanishqsarkar/portfoliomanager/blob/main/src/components/SummaryCards.tsx"
click node_allocation "https://github.com/tanishqsarkar/portfoliomanager/blob/main/src/components/AllocationChart.tsx"
click node_holdings "https://github.com/tanishqsarkar/portfoliomanager/blob/main/src/components/HoldingsList.tsx"
click node_gainers "https://github.com/tanishqsarkar/portfoliomanager/blob/main/src/components/GainerLoserCard.tsx"
click node_stock_modal "https://github.com/tanishqsarkar/portfoliomanager/blob/main/src/components/AddStockModal.tsx"
click node_portfolio_card "https://github.com/tanishqsarkar/portfoliomanager/blob/main/src/components/PortfolioCard.tsx"
click node_demo_banner "https://github.com/tanishqsarkar/portfoliomanager/blob/main/src/components/DemoModeBanner.tsx"
click node_format "https://github.com/tanishqsarkar/portfoliomanager/blob/main/src/utils/format.ts"

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_router,node_login,node_auth,node_setup toneBlue
class node_client,node_schema,node_portfolio_state,node_selection,node_supabase toneAmber
class node_market_service,node_calculations,node_format toneMint
class node_dashboard_page,node_summary,node_allocation,node_holdings,node_gainers,node_stock_modal,node_portfolio_card,node_demo_banner toneRose
class node_investor toneIndigo
```

## Components

### App and Access

- [Routes and Guards](https://github.com/tanishqsarkar/portfoliomanager/blob/main/src/App.tsx): `src/App.tsx`
- [Sign-in and Recovery](https://github.com/tanishqsarkar/portfoliomanager/blob/main/src/pages/LoginPage.tsx): `src/pages/LoginPage.tsx`
- [Authentication State](https://github.com/tanishqsarkar/portfoliomanager/blob/main/src/context/AuthContext.tsx): `src/context/AuthContext.tsx`
- [Setup Notice](https://github.com/tanishqsarkar/portfoliomanager/blob/main/src/pages/SupabaseSetupNotice.tsx): `src/pages/SupabaseSetupNotice.tsx`

### Portfolio Data

- [Supabase Client](https://github.com/tanishqsarkar/portfoliomanager/blob/main/src/lib/supabaseClient.ts): `src/lib/supabaseClient.ts`
- [Tables and RLS](https://github.com/tanishqsarkar/portfoliomanager/blob/main/supabase/schema.sql): `supabase/schema.sql`
- [Portfolio and Holding State](https://github.com/tanishqsarkar/portfoliomanager/blob/main/src/context/PortfolioContext.tsx): `src/context/PortfolioContext.tsx`
- [Portfolio Selection](https://github.com/tanishqsarkar/portfoliomanager/blob/main/src/pages/PortfolioSelectionPage.tsx): `src/pages/PortfolioSelectionPage.tsx`

### Market and Metrics

- [Demo Quote Catalog](https://github.com/tanishqsarkar/portfoliomanager/blob/main/src/services/marketDataService.ts): `src/services/marketDataService.ts`
- [Portfolio Calculations](https://github.com/tanishqsarkar/portfoliomanager/blob/main/src/utils/calculations.ts): `src/utils/calculations.ts`
- [Number Formatting](https://github.com/tanishqsarkar/portfoliomanager/blob/main/src/utils/format.ts): `src/utils/format.ts`

### Portfolio Views

- [Dashboard Orchestrator](https://github.com/tanishqsarkar/portfoliomanager/blob/main/src/pages/DashboardPage.tsx): `src/pages/DashboardPage.tsx`
- [Summary Cards](https://github.com/tanishqsarkar/portfoliomanager/blob/main/src/components/SummaryCards.tsx): `src/components/SummaryCards.tsx`
- [Allocation Chart](https://github.com/tanishqsarkar/portfoliomanager/blob/main/src/components/AllocationChart.tsx): `src/components/AllocationChart.tsx`
- [Search and Sort Holdings](https://github.com/tanishqsarkar/portfoliomanager/blob/main/src/components/HoldingsList.tsx): `src/components/HoldingsList.tsx`
- [Gainer and Loser Cards](https://github.com/tanishqsarkar/portfoliomanager/blob/main/src/components/GainerLoserCard.tsx): `src/components/GainerLoserCard.tsx`
- [Add and Edit Stock](https://github.com/tanishqsarkar/portfoliomanager/blob/main/src/components/AddStockModal.tsx): `src/components/AddStockModal.tsx`
- [Portfolio Card](https://github.com/tanishqsarkar/portfoliomanager/blob/main/src/components/PortfolioCard.tsx): `src/components/PortfolioCard.tsx`
- [Demo Data Banner](https://github.com/tanishqsarkar/portfoliomanager/blob/main/src/components/DemoModeBanner.tsx): `src/components/DemoModeBanner.tsx`

### Other components

- **Investor**
- **Supabase Auth and Postgres**

## Connections

- Investor → Routes and Guards: opens app (evidence: `README.md`)
- Routes and Guards → Sign-in and Recovery: routes to (evidence: `src/App.tsx`)
- Routes and Guards → Portfolio Selection: routes to (evidence: `src/App.tsx`)
- Routes and Guards → Dashboard Orchestrator: routes to (evidence: `src/App.tsx`)
- Routes and Guards → Setup Notice: shows when unconfigured (evidence: `src/App.tsx`)
- Routes and Guards → Authentication State: provides auth (evidence: `src/App.tsx`)
- Routes and Guards → Portfolio and Holding State: provides state (evidence: `src/App.tsx`)
- Sign-in and Recovery → Authentication State: requests auth (evidence: `src/pages/LoginPage.tsx`)
- Authentication State → Supabase Client: uses client (evidence: `src/context/AuthContext.tsx`)
- Supabase Client → Supabase Auth and Postgres: connects to (evidence: `src/lib/supabaseClient.ts`)
- Portfolio and Holding State → Authentication State: reads user (evidence: `src/context/PortfolioContext.tsx`)
- Portfolio and Holding State → Supabase Client: reads and writes (evidence: `src/context/PortfolioContext.tsx`)
- Portfolio and Holding State → Supabase Auth and Postgres: loads and persists (evidence: `README.md`)
- Tables and RLS → Supabase Auth and Postgres: defines tables and RLS (evidence: `README.md`)
- Portfolio Selection → Portfolio and Holding State: uses portfolio data (evidence: `src/pages/PortfolioSelectionPage.tsx`)
- Portfolio Selection → Portfolio Card: renders cards (evidence: `src/pages/PortfolioSelectionPage.tsx`)
- Dashboard Orchestrator → Authentication State: reads user (evidence: `src/pages/DashboardPage.tsx`)
- Dashboard Orchestrator → Portfolio and Holding State: reads and updates (evidence: `src/pages/DashboardPage.tsx`)
- Portfolio and Holding State → Demo Quote Catalog: enriches with quotes (evidence: `src/context/PortfolioContext.tsx`)
- Dashboard Orchestrator → Portfolio Calculations: computes metrics (evidence: `src/pages/DashboardPage.tsx`)
- Dashboard Orchestrator → Summary Cards: renders (evidence: `src/pages/DashboardPage.tsx`)
- Dashboard Orchestrator → Allocation Chart: renders (evidence: `src/pages/DashboardPage.tsx`)
- Dashboard Orchestrator → Search and Sort Holdings: renders (evidence: `src/pages/DashboardPage.tsx`)
- Dashboard Orchestrator → Gainer and Loser Cards: renders (evidence: `src/pages/DashboardPage.tsx`)
- Dashboard Orchestrator → Add and Edit Stock: opens for edits (evidence: `src/pages/DashboardPage.tsx`)
- Search and Sort Holdings → Portfolio Calculations: sorts with (evidence: `src/components/HoldingsList.tsx`)
- Add and Edit Stock → Demo Quote Catalog: searches catalog (evidence: `src/components/AddStockModal.tsx`)
- Add and Edit Stock → Portfolio and Holding State: submits changes
- Portfolio and Holding State → Demo Quote Catalog: refreshes quotes (evidence: `src/context/PortfolioContext.tsx`)
- Dashboard Orchestrator → Demo Data Banner: shows demo status (evidence: `src/App.tsx`)
- Search and Sort Holdings → Number Formatting: formats values (evidence: `src/components/HoldingsList.tsx`)
- Allocation Chart → Number Formatting: formats values (evidence: `src/components/AllocationChart.tsx`)
- Gainer and Loser Cards → Number Formatting: formats values (evidence: `src/components/GainerLoserCard.tsx`)
- Portfolio Card → Portfolio Calculations: computes summary (evidence: `src/components/PortfolioCard.tsx`)
