# akshtx/finlearn architecture

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

- Interactive diagram: https://gitdiagram.com/akshtx/finlearn
- Repository: https://github.com/akshtx/finlearn

## Overview

FinLearn AI combines an Indian-equity research frontend with a backend valuation API. Users search for stocks and explore analysis, compare companies, screen candidates, manage portfolios, or inspect ML valuation. The main stock workflow gathers market data, enriches it with AI analysis, and presents a dashboard; the valuation workflow serves model predictions through API routes. The README documents the four-pillar scoring and classifier methodology. Some subsystems are represented from the tree and README because their implementation was not sampled; uncertain connections are omitted.

Main entry points: [`src/App.tsx`](https://github.com/akshtx/finlearn/blob/main/src/App.tsx) (Page router), [`src/services/geminiService.ts`](https://github.com/akshtx/finlearn/blob/main/src/services/geminiService.ts) (AI service), [`finlearn-backend/modules/ml_valuation/routes.py`](https://github.com/akshtx/finlearn/blob/main/finlearn-backend/modules/ml_valuation/routes.py) (Valuation routes), [`src/pages/ComparePage.tsx`](https://github.com/akshtx/finlearn/blob/main/src/pages/ComparePage.tsx) (Stock comparison)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Research frontend"]
  node_app["Page router<br/>[App.tsx]"]
  node_home["Stock discovery<br/>[HomePage.tsx]"]
  node_dashboard["Stock dashboard"]
  node_comparison["Stock comparison<br/>[ComparePage.tsx]"]
  node_screener["Stock screener<br/>[ScreenerPage.tsx]"]
  node_portfolio["Portfolio manager<br/>[PortfolioPage.tsx]"]
  node_ml_page["ML model explorer<br/>[MLModelPage.tsx]"]
end

subgraph group_market["Market research"]
  node_search["Stock search<br/>[SearchBar.tsx]"]
  node_marketdata["Market data service<br/>[stockService.ts]"]
  node_analysis_hook["Stock analysis state"]
  node_portfolio_state["Portfolio state<br/>[usePortfolio.ts]"]
end

subgraph group_ai["AI analysis"]
  node_chatbot["Stock chatbot<br/>[Chatbot.tsx]"]
  node_gemini_service["AI service<br/>[geminiService.ts]"]
  node_llm_compare["AI comparison engine<br/>[compare_engine.py]"]
  node_llm_search["AI search copilot<br/>[search_copilot.py]"]
  node_llm_portfolio["AI portfolio analyst"]
  node_llm_screener["AI screener parser<br/>[screener_parser.py]"]
end

subgraph group_valuation["ML valuation"]
  node_ml_client["Valuation client"]
  node_routes["Valuation routes<br/>[routes.py]"]
  node_model["Model loader<br/>[model_loader.py]"]
  node_features["Feature pipeline"]
  node_av["AV market client<br/>[av_client.py]"]
  node_india_pipeline["India data pipeline"]
  node_training_data["Training data pipeline<br/>[data_pipeline.py]"]
  node_training["Training workflow<br/>[train_pipeline.py]"]
end

subgraph group_backend["Backend runtime"]
  node_server["API server<br/>[server.py]"]
end

node_user(("Investor"))
node_gemini{{"Gemini API"}}

node_user -->|"uses"| node_app
node_app -->|"routes to"| node_home
node_app -->|"routes to"| node_dashboard
node_app -->|"routes to"| node_comparison
node_app -->|"routes to"| node_screener
node_app -->|"routes to"| node_portfolio
node_app -->|"routes to"| node_ml_page
node_home -->|"renders"| node_search
node_search -->|"searches"| node_marketdata
node_dashboard -->|"uses"| node_analysis_hook
node_analysis_hook -->|"fetches data"| node_marketdata
node_analysis_hook -->|"requests analysis"| node_gemini_service
node_comparison -->|"renders"| node_search
node_comparison -->|"requests comparison"| node_gemini_service
node_comparison -->|"requests valuations"| node_ml_client
node_portfolio -->|"uses"| node_portfolio_state
node_portfolio -->|"requests analysis"| node_gemini_service
node_screener -->|"requests analysis"| node_gemini_service
node_chatbot -.->|"sends prompts"| node_gemini_service
node_gemini_service -->|"generates content"| node_gemini
node_dashboard -->|"requests valuation"| node_ml_client
node_ml_client -->|"calls API"| node_routes
node_server -->|"registers routes"| node_routes
node_routes -->|"loads classifier"| node_model
node_routes -->|"prepares features"| node_features
node_routes -->|"fetches market data"| node_av
node_training -->|"loads dataset"| node_training_data
node_training_data -.->|"uses Indian stock data"| node_user
node_llm_compare -.->|"uses model"| node_gemini
node_llm_search -.->|"uses model"| node_gemini
node_portfolio_state -->|"fetches prices"| node_marketdata

click node_app "https://github.com/akshtx/finlearn/blob/main/src/App.tsx"
click node_home "https://github.com/akshtx/finlearn/blob/main/src/pages/HomePage.tsx"
click node_dashboard "https://github.com/akshtx/finlearn/blob/main/src/pages/StockDashboardPage.tsx"
click node_search "https://github.com/akshtx/finlearn/blob/main/src/components/search/SearchBar.tsx"
click node_marketdata "https://github.com/akshtx/finlearn/blob/main/src/services/stockService.ts"
click node_analysis_hook "https://github.com/akshtx/finlearn/blob/main/src/hooks/useStockAnalysis.ts"
click node_comparison "https://github.com/akshtx/finlearn/blob/main/src/pages/ComparePage.tsx"
click node_screener "https://github.com/akshtx/finlearn/blob/main/src/pages/ScreenerPage.tsx"
click node_portfolio "https://github.com/akshtx/finlearn/blob/main/src/pages/PortfolioPage.tsx"
click node_portfolio_state "https://github.com/akshtx/finlearn/blob/main/src/hooks/usePortfolio.ts"
click node_chatbot "https://github.com/akshtx/finlearn/blob/main/src/components/chatbot/Chatbot.tsx"
click node_gemini_service "https://github.com/akshtx/finlearn/blob/main/src/services/geminiService.ts"
click node_ml_page "https://github.com/akshtx/finlearn/blob/main/src/pages/MLModelPage.tsx"
click node_ml_client "https://github.com/akshtx/finlearn/blob/main/src/services/mlValuationService.ts"
click node_server "https://github.com/akshtx/finlearn/blob/main/finlearn-backend/server.py"
click node_routes "https://github.com/akshtx/finlearn/blob/main/finlearn-backend/modules/ml_valuation/routes.py"
click node_model "https://github.com/akshtx/finlearn/blob/main/finlearn-backend/modules/ml_valuation/model_loader.py"
click node_features "https://github.com/akshtx/finlearn/blob/main/finlearn-backend/modules/ml_valuation/feature_pipeline.py"
click node_av "https://github.com/akshtx/finlearn/blob/main/finlearn-backend/modules/ml_valuation/av_client.py"
click node_india_pipeline "https://github.com/akshtx/finlearn/blob/main/finlearn-backend/modules/ml_valuation/indian_market_pipeline.py"
click node_training_data "https://github.com/akshtx/finlearn/blob/main/finlearn-backend/modules/ml_valuation/data_pipeline.py"
click node_training "https://github.com/akshtx/finlearn/blob/main/finlearn-backend/modules/ml_valuation/train_pipeline.py"
click node_llm_compare "https://github.com/akshtx/finlearn/blob/main/finlearn-backend/modules/llm/compare_engine.py"
click node_llm_search "https://github.com/akshtx/finlearn/blob/main/finlearn-backend/modules/llm/search_copilot.py"
click node_llm_portfolio "https://github.com/akshtx/finlearn/blob/main/finlearn-backend/modules/llm/portfolio_analyst.py"
click node_llm_screener "https://github.com/akshtx/finlearn/blob/main/finlearn-backend/modules/llm/screener_parser.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_app,node_home,node_dashboard,node_comparison,node_screener,node_portfolio,node_ml_page toneBlue
class node_search,node_marketdata,node_analysis_hook,node_portfolio_state toneAmber
class node_chatbot,node_gemini_service,node_llm_compare,node_llm_search,node_llm_portfolio,node_llm_screener,node_gemini toneMint
class node_ml_client,node_routes,node_model,node_features,node_av,node_india_pipeline,node_training_data,node_training toneRose
class node_server,node_user toneIndigo
```

## Components

### Research frontend

- [Page router](https://github.com/akshtx/finlearn/blob/main/src/App.tsx): `src/App.tsx`
- [Stock discovery](https://github.com/akshtx/finlearn/blob/main/src/pages/HomePage.tsx): `src/pages/HomePage.tsx`
- [Stock dashboard](https://github.com/akshtx/finlearn/blob/main/src/pages/StockDashboardPage.tsx): `src/pages/StockDashboardPage.tsx`
- [Stock comparison](https://github.com/akshtx/finlearn/blob/main/src/pages/ComparePage.tsx): `src/pages/ComparePage.tsx`
- [Stock screener](https://github.com/akshtx/finlearn/blob/main/src/pages/ScreenerPage.tsx): `src/pages/ScreenerPage.tsx`
- [Portfolio manager](https://github.com/akshtx/finlearn/blob/main/src/pages/PortfolioPage.tsx): `src/pages/PortfolioPage.tsx`
- [ML model explorer](https://github.com/akshtx/finlearn/blob/main/src/pages/MLModelPage.tsx): `src/pages/MLModelPage.tsx`

### Market research

- [Stock search](https://github.com/akshtx/finlearn/blob/main/src/components/search/SearchBar.tsx): `src/components/search/SearchBar.tsx`
- [Market data service](https://github.com/akshtx/finlearn/blob/main/src/services/stockService.ts): `src/services/stockService.ts`
- [Stock analysis state](https://github.com/akshtx/finlearn/blob/main/src/hooks/useStockAnalysis.ts): `src/hooks/useStockAnalysis.ts`
- [Portfolio state](https://github.com/akshtx/finlearn/blob/main/src/hooks/usePortfolio.ts): `src/hooks/usePortfolio.ts`

### AI analysis

- [Stock chatbot](https://github.com/akshtx/finlearn/blob/main/src/components/chatbot/Chatbot.tsx): `src/components/chatbot/Chatbot.tsx`
- [AI service](https://github.com/akshtx/finlearn/blob/main/src/services/geminiService.ts): `src/services/geminiService.ts`
- [AI comparison engine](https://github.com/akshtx/finlearn/blob/main/finlearn-backend/modules/llm/compare_engine.py): `finlearn-backend/modules/llm/compare_engine.py`
- [AI search copilot](https://github.com/akshtx/finlearn/blob/main/finlearn-backend/modules/llm/search_copilot.py): `finlearn-backend/modules/llm/search_copilot.py`
- [AI portfolio analyst](https://github.com/akshtx/finlearn/blob/main/finlearn-backend/modules/llm/portfolio_analyst.py): `finlearn-backend/modules/llm/portfolio_analyst.py`
- [AI screener parser](https://github.com/akshtx/finlearn/blob/main/finlearn-backend/modules/llm/screener_parser.py): `finlearn-backend/modules/llm/screener_parser.py`

### ML valuation

- [Valuation client](https://github.com/akshtx/finlearn/blob/main/src/services/mlValuationService.ts): `src/services/mlValuationService.ts`
- [Valuation routes](https://github.com/akshtx/finlearn/blob/main/finlearn-backend/modules/ml_valuation/routes.py): `finlearn-backend/modules/ml_valuation/routes.py`
- [Model loader](https://github.com/akshtx/finlearn/blob/main/finlearn-backend/modules/ml_valuation/model_loader.py): `finlearn-backend/modules/ml_valuation/model_loader.py`
- [Feature pipeline](https://github.com/akshtx/finlearn/blob/main/finlearn-backend/modules/ml_valuation/feature_pipeline.py): `finlearn-backend/modules/ml_valuation/feature_pipeline.py`
- [AV market client](https://github.com/akshtx/finlearn/blob/main/finlearn-backend/modules/ml_valuation/av_client.py): `finlearn-backend/modules/ml_valuation/av_client.py`
- [India data pipeline](https://github.com/akshtx/finlearn/blob/main/finlearn-backend/modules/ml_valuation/indian_market_pipeline.py): `finlearn-backend/modules/ml_valuation/indian_market_pipeline.py`
- [Training data pipeline](https://github.com/akshtx/finlearn/blob/main/finlearn-backend/modules/ml_valuation/data_pipeline.py): `finlearn-backend/modules/ml_valuation/data_pipeline.py`
- [Training workflow](https://github.com/akshtx/finlearn/blob/main/finlearn-backend/modules/ml_valuation/train_pipeline.py): `finlearn-backend/modules/ml_valuation/train_pipeline.py`

### Backend runtime

- [API server](https://github.com/akshtx/finlearn/blob/main/finlearn-backend/server.py): `finlearn-backend/server.py`

### Other components

- **Investor**
- **Gemini API**

## Connections

- Investor → Page router: uses (evidence: `src/App.tsx`)
- Page router → Stock discovery: routes to (evidence: `src/App.tsx`)
- Page router → Stock dashboard: routes to (evidence: `src/App.tsx`)
- Page router → Stock comparison: routes to (evidence: `src/App.tsx`)
- Page router → Stock screener: routes to (evidence: `src/App.tsx`)
- Page router → Portfolio manager: routes to (evidence: `src/App.tsx`)
- Page router → ML model explorer: routes to (evidence: `src/App.tsx`)
- Stock discovery → Stock search: renders (evidence: `src/pages/HomePage.tsx`)
- Stock search → Market data service: searches (evidence: `src/components/search/SearchBar.tsx`)
- Stock dashboard → Stock analysis state: uses (evidence: `src/pages/StockDashboardPage.tsx`)
- Stock analysis state → Market data service: fetches data (evidence: `src/hooks/useStockAnalysis.ts`)
- Stock analysis state → AI service: requests analysis (evidence: `src/hooks/useStockAnalysis.ts`)
- Stock comparison → Stock search: renders (evidence: `src/pages/ComparePage.tsx`)
- Stock comparison → AI service: requests comparison (evidence: `src/pages/ComparePage.tsx`)
- Stock comparison → Valuation client: requests valuations (evidence: `src/pages/ComparePage.tsx`)
- Portfolio manager → Portfolio state: uses (evidence: `src/pages/PortfolioPage.tsx`)
- Portfolio manager → AI service: requests analysis
- Stock screener → AI service: requests analysis (evidence: `src/pages/ScreenerPage.tsx`)
- Stock chatbot → AI service: sends prompts
- AI service → Gemini API: generates content (evidence: `src/services/geminiService.ts`)
- Stock dashboard → Valuation client: requests valuation (evidence: `src/pages/StockDashboardPage.tsx`)
- Valuation client → Valuation routes: calls API (evidence: `src/services/mlValuationService.ts`)
- API server → Valuation routes: registers routes (evidence: `finlearn-backend/server.py`)
- Valuation routes → Model loader: loads classifier (evidence: `finlearn-backend/modules/ml_valuation/routes.py`)
- Valuation routes → Feature pipeline: prepares features (evidence: `finlearn-backend/modules/ml_valuation/routes.py`)
- Valuation routes → AV market client: fetches market data (evidence: `finlearn-backend/modules/ml_valuation/routes.py`)
- Training workflow → Training data pipeline: loads dataset (evidence: `finlearn-backend/modules/ml_valuation/train_pipeline.py`)
- Training data pipeline → Investor: uses Indian stock data
- AI comparison engine → Gemini API: uses model
- AI search copilot → Gemini API: uses model
- Portfolio state → Market data service: fetches prices (evidence: `src/hooks/usePortfolio.ts`)
