# raazkhnl/nepsai architecture

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

- Interactive diagram: https://gitdiagram.com/raazkhnl/nepsai
- Repository: https://github.com/raazkhnl/nepsai

## Overview

NepsAi is a NEPSE market terminal with an automated end-of-day collection pipeline. The user-facing path is market data into the terminal, then search, charts, movers, sector views, comparison and quantitative/AI analysis. Admin tools expose authentication and pipeline management. The README documents five-provider reconciliation and historical backfill. Some UI data-fetch wiring and unsampled subsystems are not visible in the excerpts, so uncertain links are omitted; documented but unsampled capabilities are included with directory paths where supported.

Main entry points: [`src/App.tsx`](https://github.com/raazkhnl/nepsai/blob/main/src/App.tsx) (Terminal shell), [`src/server/nepseCollector.ts`](https://github.com/raazkhnl/nepsai/blob/main/src/server/nepseCollector.ts) (EOD reconciliation), [`src/utils/aiPrompt.ts`](https://github.com/raazkhnl/nepsai/blob/main/src/utils/aiPrompt.ts) (AI prompt providers), [`src/components/NepseAdminPortal.tsx`](https://github.com/raazkhnl/nepsai/blob/main/src/components/NepseAdminPortal.tsx) (Admin portal)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_terminal["Market terminal"]
  node_app["Terminal shell<br/>[App.tsx]"]
  node_marketdata["Market catalog<br/>[nepseStocks.ts]"]
  node_search["Scrip search"]
  node_ticker["Market ticker"]
  node_chart["TradingView charts"]
  node_details["Stock details"]
  node_movers["Market movers"]
end

subgraph group_analytics["Analysis tools"]
  node_heatmap["Sector heatmap<br/>[SectorHeatmap.tsx]"]
  node_comparison["Stock comparison"]
  node_visual["Visual analytics"]
  node_institutional["Institutional metrics"]
  node_indicators["Technical indicators"]
  node_analyticsutil["Market analytics<br/>[nepseAnalytics.ts]"]
  node_ai["AI analysis"]
  node_prompt["AI prompt providers<br/>[aiPrompt.ts]"]
end

subgraph group_collection["Data collection"]
  node_collector["EOD reconciliation<br/>[nepseCollector.ts]"]
  node_providers(("Market providers"))
  node_history["Historical backfill"]
  node_store[("Published market data")]
  node_npt["NPT time utilities<br/>[nepalTime.ts]"]
end

subgraph group_admin["Admin operations"]
  node_adminportal["Admin portal"]
  node_api["Application API<br/>[server.ts]"]
end

node_user(("Market user"))
node_gemini(("Gemini service"))
node_otherai(("Other AI providers"))

node_user -->|"uses"| node_app
node_app -->|"loads data"| node_marketdata
node_app -->|"renders"| node_search
node_app -->|"renders"| node_ticker
node_app -->|"renders"| node_chart
node_app -->|"renders"| node_details
node_app -->|"renders"| node_movers
node_app -->|"renders"| node_heatmap
node_app -->|"renders"| node_comparison
node_app -->|"renders"| node_visual
node_app -->|"renders"| node_institutional
node_app -->|"renders"| node_ai
node_app -->|"renders"| node_adminportal
node_chart -->|"calculates"| node_indicators
node_institutional -->|"uses metrics"| node_analyticsutil
node_ai -->|"requests analysis"| node_prompt
node_prompt -.->|"calls provider"| node_gemini
node_prompt -.->|"calls providers"| node_otherai
node_heatmap -->|"requests analysis"| node_prompt
node_providers -->|"supplies quotes"| node_collector
node_collector -->|"uses fallback bars"| node_marketdata
node_collector -->|"formats timestamps"| node_npt
node_collector -.->|"exports EOD data"| node_store
node_history -.->|"fetches historical bars"| node_providers
node_adminportal -.->|"manages pipeline"| node_api
node_api -->|"invokes collector"| node_collector
node_adminportal -->|"formats timestamps"| node_npt

click node_app "https://github.com/raazkhnl/nepsai/blob/main/src/App.tsx"
click node_marketdata "https://github.com/raazkhnl/nepsai/blob/main/src/data/nepseStocks.ts"
click node_search "https://github.com/raazkhnl/nepsai/blob/main/src/components/QuickSearchModal.tsx"
click node_ticker "https://github.com/raazkhnl/nepsai/blob/main/src/components/MarketTickerBar.tsx"
click node_chart "https://github.com/raazkhnl/nepsai/blob/main/src/components/TradingViewChart.tsx"
click node_details "https://github.com/raazkhnl/nepsai/blob/main/src/components/StockDetailsSidebar.tsx"
click node_movers "https://github.com/raazkhnl/nepsai/blob/main/src/components/MarketMoversView.tsx"
click node_heatmap "https://github.com/raazkhnl/nepsai/blob/main/src/components/SectorHeatmap.tsx"
click node_comparison "https://github.com/raazkhnl/nepsai/blob/main/src/components/StockComparison.tsx"
click node_visual "https://github.com/raazkhnl/nepsai/blob/main/src/components/VisualAnalyticsView.tsx"
click node_institutional "https://github.com/raazkhnl/nepsai/blob/main/src/components/InstitutionalAnalyticsPanel.tsx"
click node_indicators "https://github.com/raazkhnl/nepsai/blob/main/src/utils/technicalIndicators.ts"
click node_analyticsutil "https://github.com/raazkhnl/nepsai/blob/main/src/utils/nepseAnalytics.ts"
click node_ai "https://github.com/raazkhnl/nepsai/blob/main/src/components/AIAnalyticsView.tsx"
click node_prompt "https://github.com/raazkhnl/nepsai/blob/main/src/utils/aiPrompt.ts"
click node_collector "https://github.com/raazkhnl/nepsai/blob/main/src/server/nepseCollector.ts"
click node_history "https://github.com/raazkhnl/nepsai/tree/main/src/server"
click node_store "https://github.com/raazkhnl/nepsai/tree/main/data/eod"
click node_adminportal "https://github.com/raazkhnl/nepsai/blob/main/src/components/NepseAdminPortal.tsx"
click node_api "https://github.com/raazkhnl/nepsai/blob/main/server.ts"
click node_npt "https://github.com/raazkhnl/nepsai/blob/main/src/utils/nepalTime.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,node_marketdata,node_search,node_ticker,node_chart,node_details,node_movers,node_user toneBlue
class node_heatmap,node_comparison,node_visual,node_institutional,node_indicators,node_analyticsutil,node_ai,node_prompt toneAmber
class node_collector,node_providers,node_history,node_store,node_npt toneMint
class node_adminportal,node_api toneRose
class node_gemini,node_otherai toneIndigo
```

## Components

### Market terminal

- [Terminal shell](https://github.com/raazkhnl/nepsai/blob/main/src/App.tsx): `src/App.tsx`
- [Market catalog](https://github.com/raazkhnl/nepsai/blob/main/src/data/nepseStocks.ts): `src/data/nepseStocks.ts`
- [Scrip search](https://github.com/raazkhnl/nepsai/blob/main/src/components/QuickSearchModal.tsx): `src/components/QuickSearchModal.tsx`
- [Market ticker](https://github.com/raazkhnl/nepsai/blob/main/src/components/MarketTickerBar.tsx): `src/components/MarketTickerBar.tsx`
- [TradingView charts](https://github.com/raazkhnl/nepsai/blob/main/src/components/TradingViewChart.tsx): `src/components/TradingViewChart.tsx`
- [Stock details](https://github.com/raazkhnl/nepsai/blob/main/src/components/StockDetailsSidebar.tsx): `src/components/StockDetailsSidebar.tsx`
- [Market movers](https://github.com/raazkhnl/nepsai/blob/main/src/components/MarketMoversView.tsx): `src/components/MarketMoversView.tsx`

### Analysis tools

- [Sector heatmap](https://github.com/raazkhnl/nepsai/blob/main/src/components/SectorHeatmap.tsx): `src/components/SectorHeatmap.tsx`
- [Stock comparison](https://github.com/raazkhnl/nepsai/blob/main/src/components/StockComparison.tsx): `src/components/StockComparison.tsx`
- [Visual analytics](https://github.com/raazkhnl/nepsai/blob/main/src/components/VisualAnalyticsView.tsx): `src/components/VisualAnalyticsView.tsx`
- [Institutional metrics](https://github.com/raazkhnl/nepsai/blob/main/src/components/InstitutionalAnalyticsPanel.tsx): `src/components/InstitutionalAnalyticsPanel.tsx`
- [Technical indicators](https://github.com/raazkhnl/nepsai/blob/main/src/utils/technicalIndicators.ts): `src/utils/technicalIndicators.ts`
- [Market analytics](https://github.com/raazkhnl/nepsai/blob/main/src/utils/nepseAnalytics.ts): `src/utils/nepseAnalytics.ts`
- [AI analysis](https://github.com/raazkhnl/nepsai/blob/main/src/components/AIAnalyticsView.tsx): `src/components/AIAnalyticsView.tsx`
- [AI prompt providers](https://github.com/raazkhnl/nepsai/blob/main/src/utils/aiPrompt.ts): `src/utils/aiPrompt.ts`

### Data collection

- [EOD reconciliation](https://github.com/raazkhnl/nepsai/blob/main/src/server/nepseCollector.ts): `src/server/nepseCollector.ts`
- **Market providers**
- [Historical backfill](https://github.com/raazkhnl/nepsai/tree/main/src/server): `src/server`
- [Published market data](https://github.com/raazkhnl/nepsai/tree/main/data/eod): `data/eod`
- [NPT time utilities](https://github.com/raazkhnl/nepsai/blob/main/src/utils/nepalTime.ts): `src/utils/nepalTime.ts`

### Admin operations

- [Admin portal](https://github.com/raazkhnl/nepsai/blob/main/src/components/NepseAdminPortal.tsx): `src/components/NepseAdminPortal.tsx`
- [Application API](https://github.com/raazkhnl/nepsai/blob/main/server.ts): `server.ts`

### Other components

- **Market user**
- **Gemini service**
- **Other AI providers**

## Connections

- Market user → Terminal shell: uses (evidence: `README.md`)
- Terminal shell → Market catalog: loads data (evidence: `src/App.tsx`)
- Terminal shell → Scrip search: renders (evidence: `src/App.tsx`)
- Terminal shell → Market ticker: renders (evidence: `src/App.tsx`)
- Terminal shell → TradingView charts: renders (evidence: `src/App.tsx`)
- Terminal shell → Stock details: renders (evidence: `src/App.tsx`)
- Terminal shell → Market movers: renders (evidence: `src/App.tsx`)
- Terminal shell → Sector heatmap: renders (evidence: `src/App.tsx`)
- Terminal shell → Stock comparison: renders (evidence: `src/App.tsx`)
- Terminal shell → Visual analytics: renders (evidence: `src/App.tsx`)
- Terminal shell → Institutional metrics: renders (evidence: `src/App.tsx`)
- Terminal shell → AI analysis: renders (evidence: `src/App.tsx`)
- Terminal shell → Admin portal: renders (evidence: `src/App.tsx`)
- TradingView charts → Technical indicators: calculates (evidence: `src/components/TradingViewChart.tsx`)
- Institutional metrics → Market analytics: uses metrics (evidence: `src/components/InstitutionalAnalyticsPanel.tsx`)
- AI analysis → AI prompt providers: requests analysis (evidence: `src/components/AIAnalyticsView.tsx`)
- AI prompt providers → Gemini service: calls provider (evidence: `README.md`)
- AI prompt providers → Other AI providers: calls providers (evidence: `src/utils/aiPrompt.ts`)
- Sector heatmap → AI prompt providers: requests analysis (evidence: `src/components/SectorHeatmap.tsx`)
- Market providers → EOD reconciliation: supplies quotes (evidence: `README.md`)
- EOD reconciliation → Market catalog: uses fallback bars (evidence: `src/server/nepseCollector.ts`)
- EOD reconciliation → NPT time utilities: formats timestamps (evidence: `src/server/nepseCollector.ts`)
- EOD reconciliation → Published market data: exports EOD data (evidence: `README.md`)
- Historical backfill → Market providers: fetches historical bars (evidence: `README.md`)
- Admin portal → Application API: manages pipeline (evidence: `README.md`)
- Application API → EOD reconciliation: invokes collector (evidence: `server.ts`)
- Admin portal → NPT time utilities: formats timestamps (evidence: `src/components/NepseAdminPortal.tsx`)
