# parthsurve07/phoenix__laser architecture

> Architecture diagram of the GitHub repository parthsurve07/phoenix__laser, 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/parthsurve07/phoenix__laser
- Repository: https://github.com/parthsurve07/phoenix__laser

## Overview

Fintrack is an Indian-equity portfolio dashboard: users sign in, import or sync holdings, then review portfolio valuation and allocation alongside market data, alerts, stock signals, and AI guidance. The frontend is a Next.js application and the backend exposes Express API routes backed by Prisma. Broker synchronization enriches holdings before saving them; portfolio reads combine stored holdings with live prices. The tree documents several additional route families whose implementations were not sampled, so their internal call relationships are not expanded here.

Main entry points: [`backend/src/routes/index.js`](https://github.com/parthsurve07/phoenix__laser/blob/main/backend/src/routes/index.js) (API router), [`backend/src/db.js`](https://github.com/parthsurve07/phoenix__laser/blob/main/backend/src/db.js) (Prisma database), [`backend/src/services/marketData.js`](https://github.com/parthsurve07/phoenix__laser/blob/main/backend/src/services/marketData.js) (Market data service), [`backend/src/routes/authRoutes.js`](https://github.com/parthsurve07/phoenix__laser/blob/main/backend/src/routes/authRoutes.js) (Authentication)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Fintrack interface"]
  node_webapp["Dashboard pages"]
  node_search["Stock search"]
  node_clientapi["API client<br/>[api.js]"]
  node_csvimport["CSV import endpoint<br/>[route.js]"]
  node_brokerplaceholder["Broker import placeholder<br/>[route.js]"]
  node_frontendai["AI insights endpoint<br/>[route.js]"]
end

subgraph group_api["API and identity"]
  node_expressapp["Express app<br/>[app.js]"]
  node_router["API router<br/>[index.js]"]
  node_authroutes["Authentication<br/>[authRoutes.js]"]
  node_authmiddleware["Session middleware<br/>[auth.js]"]
end

subgraph group_portfolio["Portfolio and market"]
  node_portfolio["Portfolio routes<br/>[portfolioRoutes.js]"]
  node_brokers["Broker sync routes<br/>[brokerRoutes.js]"]
  node_market["Market data service<br/>[marketData.js]"]
  node_sector["Sector mapping<br/>[sectorMap.js]"]
  node_db[("Prisma database<br/>[db.js]")]
  node_marketroutes["Market and stock routes"]
  node_watchroutes["Watchlist routes<br/>[watchlistRoutes.js]"]
end

subgraph group_insights["Insights and alerts"]
  node_alerts["Alert routes<br/>[alertRoutes.js]"]
  node_airoutes["AI routes<br/>[aiRoutes.js]"]
  node_gemini["AI service<br/>[geminiService.js]"]
  node_suggestions["Suggestions routes"]
end

subgraph group_integrations["External integrations"]
  node_email["OTP email<br/>[emailService.js]"]
  node_geminiservice{{"Gemini API"}}
  node_marketprovider{{"Market data provider"}}
  node_brokerproviders{{"Broker APIs"}}
  node_resend{{"Resend email"}}
  node_python{{"ML service"}}
end

node_user(("Investor"))

node_user -->|"uses"| node_webapp
node_webapp -->|"requests API"| node_clientapi
node_search -->|"searches stocks"| node_clientapi
node_user -->|"uploads CSV"| node_csvimport
node_csvimport -->|"normalizes holdings"| node_db
node_user -->|"selects broker"| node_brokerplaceholder
node_expressapp -->|"mounts API"| node_router
node_router -->|"dispatches"| node_authroutes
node_router -->|"dispatches"| node_portfolio
node_router -->|"dispatches"| node_brokers
node_router -->|"dispatches"| node_marketroutes
node_router -->|"dispatches"| node_watchroutes
node_router -->|"dispatches"| node_alerts
node_router -->|"dispatches"| node_airoutes
node_router -->|"dispatches"| node_suggestions
node_authroutes -->|"creates sessions"| node_authmiddleware
node_authroutes -->|"reads and writes users"| node_db
node_authroutes -->|"sends OTP"| node_email
node_email -.->|"sends email"| node_resend
node_portfolio -->|"reads and writes holdings"| node_db
node_portfolio -->|"fetches live prices"| node_market
node_portfolio -->|"maps sectors"| node_sector
node_brokers -.->|"syncs holdings"| node_brokerproviders
node_brokers -->|"enriches profiles"| node_market
node_brokers -->|"replaces source holdings"| node_db
node_market -.->|"fetches market data"| node_marketprovider
node_watchroutes -->|"reads and writes watchlists"| node_db
node_alerts -->|"reads and writes alerts"| node_db
node_alerts -->|"fetches live prices"| node_market
node_airoutes -->|"generates analysis"| node_gemini
node_airoutes -->|"fetches news and trends"| node_market
node_airoutes -->|"saves signals"| node_db
node_gemini -.->|"requests generation"| node_geminiservice
node_gemini -.->|"requests ML data"| node_python
node_suggestions -->|"gets trending stocks"| node_market
node_suggestions -->|"generates suggestions"| node_gemini
node_user -->|"requests insights"| node_frontendai
node_frontendai -.->|"generates insights"| node_geminiservice

click node_webapp "https://github.com/parthsurve07/phoenix__laser/tree/main/frontend/app"
click node_search "https://github.com/parthsurve07/phoenix__laser/blob/main/frontend/components/stock-search-bar.jsx"
click node_clientapi "https://github.com/parthsurve07/phoenix__laser/blob/main/frontend/lib/api.js"
click node_csvimport "https://github.com/parthsurve07/phoenix__laser/blob/main/frontend/app/api/portfolio-import/csv/route.js"
click node_brokerplaceholder "https://github.com/parthsurve07/phoenix__laser/blob/main/frontend/app/api/portfolio-import/broker/route.js"
click node_expressapp "https://github.com/parthsurve07/phoenix__laser/blob/main/backend/src/app.js"
click node_router "https://github.com/parthsurve07/phoenix__laser/blob/main/backend/src/routes/index.js"
click node_authroutes "https://github.com/parthsurve07/phoenix__laser/blob/main/backend/src/routes/authRoutes.js"
click node_authmiddleware "https://github.com/parthsurve07/phoenix__laser/blob/main/backend/src/middleware/auth.js"
click node_email "https://github.com/parthsurve07/phoenix__laser/blob/main/backend/src/services/emailService.js"
click node_portfolio "https://github.com/parthsurve07/phoenix__laser/blob/main/backend/src/routes/portfolioRoutes.js"
click node_brokers "https://github.com/parthsurve07/phoenix__laser/blob/main/backend/src/routes/brokerRoutes.js"
click node_market "https://github.com/parthsurve07/phoenix__laser/blob/main/backend/src/services/marketData.js"
click node_sector "https://github.com/parthsurve07/phoenix__laser/blob/main/backend/src/utils/sectorMap.js"
click node_db "https://github.com/parthsurve07/phoenix__laser/blob/main/backend/src/db.js"
click node_marketroutes "https://github.com/parthsurve07/phoenix__laser/tree/main/backend/src/routes"
click node_watchroutes "https://github.com/parthsurve07/phoenix__laser/blob/main/backend/src/routes/watchlistRoutes.js"
click node_alerts "https://github.com/parthsurve07/phoenix__laser/blob/main/backend/src/routes/alertRoutes.js"
click node_airoutes "https://github.com/parthsurve07/phoenix__laser/blob/main/backend/src/routes/aiRoutes.js"
click node_gemini "https://github.com/parthsurve07/phoenix__laser/blob/main/backend/src/services/geminiService.js"
click node_suggestions "https://github.com/parthsurve07/phoenix__laser/blob/main/backend/src/routes/suggestionRoutes.js"
click node_frontendai "https://github.com/parthsurve07/phoenix__laser/blob/main/frontend/app/api/ai-insights/route.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_webapp,node_search,node_clientapi,node_csvimport,node_brokerplaceholder,node_frontendai toneBlue
class node_expressapp,node_router,node_authroutes,node_authmiddleware toneAmber
class node_portfolio,node_brokers,node_market,node_sector,node_db,node_marketroutes,node_watchroutes toneMint
class node_alerts,node_airoutes,node_gemini,node_suggestions toneRose
class node_email,node_geminiservice,node_marketprovider,node_brokerproviders,node_resend,node_python,node_user toneIndigo
```

## Components

### Fintrack interface

- [Dashboard pages](https://github.com/parthsurve07/phoenix__laser/tree/main/frontend/app): `frontend/app`
- [Stock search](https://github.com/parthsurve07/phoenix__laser/blob/main/frontend/components/stock-search-bar.jsx): `frontend/components/stock-search-bar.jsx`
- [API client](https://github.com/parthsurve07/phoenix__laser/blob/main/frontend/lib/api.js): `frontend/lib/api.js`
- [CSV import endpoint](https://github.com/parthsurve07/phoenix__laser/blob/main/frontend/app/api/portfolio-import/csv/route.js): `frontend/app/api/portfolio-import/csv/route.js`
- [Broker import placeholder](https://github.com/parthsurve07/phoenix__laser/blob/main/frontend/app/api/portfolio-import/broker/route.js): `frontend/app/api/portfolio-import/broker/route.js`
- [AI insights endpoint](https://github.com/parthsurve07/phoenix__laser/blob/main/frontend/app/api/ai-insights/route.js): `frontend/app/api/ai-insights/route.js`

### API and identity

- [Express app](https://github.com/parthsurve07/phoenix__laser/blob/main/backend/src/app.js): `backend/src/app.js`
- [API router](https://github.com/parthsurve07/phoenix__laser/blob/main/backend/src/routes/index.js): `backend/src/routes/index.js`
- [Authentication](https://github.com/parthsurve07/phoenix__laser/blob/main/backend/src/routes/authRoutes.js): `backend/src/routes/authRoutes.js`
- [Session middleware](https://github.com/parthsurve07/phoenix__laser/blob/main/backend/src/middleware/auth.js): `backend/src/middleware/auth.js`

### Portfolio and market

- [Portfolio routes](https://github.com/parthsurve07/phoenix__laser/blob/main/backend/src/routes/portfolioRoutes.js): `backend/src/routes/portfolioRoutes.js`
- [Broker sync routes](https://github.com/parthsurve07/phoenix__laser/blob/main/backend/src/routes/brokerRoutes.js): `backend/src/routes/brokerRoutes.js`
- [Market data service](https://github.com/parthsurve07/phoenix__laser/blob/main/backend/src/services/marketData.js): `backend/src/services/marketData.js`
- [Sector mapping](https://github.com/parthsurve07/phoenix__laser/blob/main/backend/src/utils/sectorMap.js): `backend/src/utils/sectorMap.js`
- [Prisma database](https://github.com/parthsurve07/phoenix__laser/blob/main/backend/src/db.js): `backend/src/db.js`
- [Market and stock routes](https://github.com/parthsurve07/phoenix__laser/tree/main/backend/src/routes): `backend/src/routes`
- [Watchlist routes](https://github.com/parthsurve07/phoenix__laser/blob/main/backend/src/routes/watchlistRoutes.js): `backend/src/routes/watchlistRoutes.js`

### Insights and alerts

- [Alert routes](https://github.com/parthsurve07/phoenix__laser/blob/main/backend/src/routes/alertRoutes.js): `backend/src/routes/alertRoutes.js`
- [AI routes](https://github.com/parthsurve07/phoenix__laser/blob/main/backend/src/routes/aiRoutes.js): `backend/src/routes/aiRoutes.js`
- [AI service](https://github.com/parthsurve07/phoenix__laser/blob/main/backend/src/services/geminiService.js): `backend/src/services/geminiService.js`
- [Suggestions routes](https://github.com/parthsurve07/phoenix__laser/blob/main/backend/src/routes/suggestionRoutes.js): `backend/src/routes/suggestionRoutes.js`

### External integrations

- [OTP email](https://github.com/parthsurve07/phoenix__laser/blob/main/backend/src/services/emailService.js): `backend/src/services/emailService.js`
- **Gemini API**
- **Market data provider**
- **Broker APIs**
- **Resend email**
- **ML service**

### Other components

- **Investor**

## Connections

- Investor → Dashboard pages: uses
- Dashboard pages → API client: requests API
- Stock search → API client: searches stocks
- Investor → CSV import endpoint: uploads CSV
- CSV import endpoint → Prisma database: normalizes holdings
- Investor → Broker import placeholder: selects broker
- Express app → API router: mounts API
- API router → Authentication: dispatches
- API router → Portfolio routes: dispatches
- API router → Broker sync routes: dispatches
- API router → Market and stock routes: dispatches
- API router → Watchlist routes: dispatches
- API router → Alert routes: dispatches
- API router → AI routes: dispatches
- API router → Suggestions routes: dispatches
- Authentication → Session middleware: creates sessions
- Authentication → Prisma database: reads and writes users
- Authentication → OTP email: sends OTP
- OTP email → Resend email: sends email
- Portfolio routes → Prisma database: reads and writes holdings
- Portfolio routes → Market data service: fetches live prices
- Portfolio routes → Sector mapping: maps sectors
- Broker sync routes → Broker APIs: syncs holdings
- Broker sync routes → Market data service: enriches profiles
- Broker sync routes → Prisma database: replaces source holdings
- Market data service → Market data provider: fetches market data
- Watchlist routes → Prisma database: reads and writes watchlists
- Alert routes → Prisma database: reads and writes alerts
- Alert routes → Market data service: fetches live prices
- AI routes → AI service: generates analysis
- AI routes → Market data service: fetches news and trends
- AI routes → Prisma database: saves signals
- AI service → Gemini API: requests generation
- AI service → ML service: requests ML data
- Suggestions routes → Market data service: gets trending stocks
- Suggestions routes → AI service: generates suggestions
- Investor → AI insights endpoint: requests insights
- AI insights endpoint → Gemini API: generates insights
