# bob0706/algolearn architecture

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

- Interactive diagram: https://gitdiagram.com/bob0706/algolearn
- Repository: https://github.com/bob0706/algolearn

## Overview

AlgoLearn India is an educational algorithmic-trading platform. Users learn trading concepts, create strategies from plain-English prompts or templates, test them against market history, and practice trades in a candle-by-candle simulator. The backtest path includes a distinct data-fetch stage and a strategy-execution/performance layer. The tree and sampled source confirm the Next.js frontend and TypeScript market/backtest paths; learning content, dashboard details, Firebase behavior, and blockchain logging are included as documented, but their implementation wiring is not fully visible.

Main entry points: [`lib/api.ts`](https://github.com/bob0706/algolearn/blob/main/lib/api.ts) (Frontend API client), [`app/builder/page.tsx`](https://github.com/bob0706/algolearn/blob/main/app/builder/page.tsx) (Strategy builder), [`app/simulator/page.tsx`](https://github.com/bob0706/algolearn/blob/main/app/simulator/page.tsx) (Trade simulator), [`app/api/generate-strategy/route.ts`](https://github.com/bob0706/algolearn/blob/main/app/api/generate-strategy/route.ts) (Strategy generation API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_learning["Learning and account"]
  node_lessons["Learning hub"]
  node_dashboard["User dashboard<br/>[page.tsx]"]
  node_firebase[("Firebase services<br/>[firebase.ts]")]
end

subgraph group_strategies["Strategy creation"]
  node_builder["Strategy builder<br/>[page.tsx]"]
  node_generate["Strategy generation API<br/>[route.ts]"]
  node_templates["Template API<br/>[route.ts]"]
end

subgraph group_market["Market and analysis"]
  node_marketdata["Market and templates<br/>[marketData.ts]"]
  node_backtest["Backtester<br/>[page.tsx]"]
  node_backtestapi["Backtest API<br/>[route.ts]"]
  node_engine["Backtest engine<br/>[backtestEngine.ts]"]
  node_stockapi["Stock data API<br/>[route.ts]"]
  node_stockservice["Stock data service<br/>[stockService.ts]"]
  node_symbolsapi["Symbols API<br/>[route.ts]"]
  node_api["Frontend API client<br/>[api.ts]"]
end

subgraph group_simulation["Simulation"]
  node_simulator["Trade simulator<br/>[page.tsx]"]
end

node_learner(("Learner"))
node_landing["Platform entry<br/>[page.tsx]"]
node_gemini{{"Gemini AI"}}
node_yahoo{{"Yahoo Finance"}}
node_wallet{{"MetaMask and chain"}}

node_learner -->|"opens"| node_landing
node_learner -->|"studies"| node_lessons
node_learner -->|"describes strategy"| node_builder
node_learner -->|"runs test"| node_backtest
node_learner -->|"practices trades"| node_simulator
node_builder -->|"requests generation"| node_api
node_builder -->|"loads templates"| node_api
node_builder -.->|"saves strategy"| node_firebase
node_api -->|"posts prompt"| node_generate
node_api -->|"gets templates"| node_templates
node_generate -.->|"generates code"| node_gemini
node_generate -->|"uses fallback templates"| node_marketdata
node_templates -->|"reads templates"| node_marketdata
node_backtest -->|"requests data and test"| node_api
node_api -->|"gets symbols"| node_symbolsapi
node_api -->|"gets prices"| node_stockapi
node_api -->|"submits strategy"| node_backtestapi
node_stockapi -->|"fetches bars"| node_stockservice
node_backtestapi -->|"fetches bars"| node_stockservice
node_stockservice -->|"requests history"| node_yahoo
node_backtestapi -->|"executes strategy"| node_engine
node_simulator -->|"loads symbols and bars"| node_api
node_simulator -.->|"updates progress"| node_firebase
node_simulator -.->|"logs results"| node_wallet
node_dashboard -.->|"reads account data"| node_firebase

click node_landing "https://github.com/bob0706/algolearn/blob/main/app/page.tsx"
click node_lessons "https://github.com/bob0706/algolearn/tree/main/app"
click node_dashboard "https://github.com/bob0706/algolearn/blob/main/app/dashboard/page.tsx"
click node_firebase "https://github.com/bob0706/algolearn/blob/main/lib/firebase.ts"
click node_builder "https://github.com/bob0706/algolearn/blob/main/app/builder/page.tsx"
click node_generate "https://github.com/bob0706/algolearn/blob/main/app/api/generate-strategy/route.ts"
click node_templates "https://github.com/bob0706/algolearn/blob/main/app/api/strategy-templates/route.ts"
click node_marketdata "https://github.com/bob0706/algolearn/blob/main/lib/marketData.ts"
click node_backtest "https://github.com/bob0706/algolearn/blob/main/app/backtest/page.tsx"
click node_backtestapi "https://github.com/bob0706/algolearn/blob/main/app/api/backtest/route.ts"
click node_engine "https://github.com/bob0706/algolearn/blob/main/lib/backtestEngine.ts"
click node_stockapi "https://github.com/bob0706/algolearn/blob/main/app/api/stock-data/route.ts"
click node_stockservice "https://github.com/bob0706/algolearn/blob/main/lib/stockService.ts"
click node_symbolsapi "https://github.com/bob0706/algolearn/blob/main/app/api/symbols/route.ts"
click node_api "https://github.com/bob0706/algolearn/blob/main/lib/api.ts"
click node_simulator "https://github.com/bob0706/algolearn/blob/main/app/simulator/page.tsx"

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_lessons,node_dashboard,node_firebase toneBlue
class node_builder,node_generate,node_templates toneAmber
class node_marketdata,node_backtest,node_backtestapi,node_engine,node_stockapi,node_stockservice,node_symbolsapi,node_api toneMint
class node_simulator toneRose
class node_learner,node_gemini,node_yahoo,node_wallet toneIndigo
class node_landing toneTeal
```

## Components

### Learning and account

- [Learning hub](https://github.com/bob0706/algolearn/tree/main/app): `app`
- [User dashboard](https://github.com/bob0706/algolearn/blob/main/app/dashboard/page.tsx): `app/dashboard/page.tsx`
- [Firebase services](https://github.com/bob0706/algolearn/blob/main/lib/firebase.ts): `lib/firebase.ts`

### Strategy creation

- [Strategy builder](https://github.com/bob0706/algolearn/blob/main/app/builder/page.tsx): `app/builder/page.tsx`
- [Strategy generation API](https://github.com/bob0706/algolearn/blob/main/app/api/generate-strategy/route.ts): `app/api/generate-strategy/route.ts`
- [Template API](https://github.com/bob0706/algolearn/blob/main/app/api/strategy-templates/route.ts): `app/api/strategy-templates/route.ts`

### Market and analysis

- [Market and templates](https://github.com/bob0706/algolearn/blob/main/lib/marketData.ts): `lib/marketData.ts`
- [Backtester](https://github.com/bob0706/algolearn/blob/main/app/backtest/page.tsx): `app/backtest/page.tsx`
- [Backtest API](https://github.com/bob0706/algolearn/blob/main/app/api/backtest/route.ts): `app/api/backtest/route.ts`
- [Backtest engine](https://github.com/bob0706/algolearn/blob/main/lib/backtestEngine.ts): `lib/backtestEngine.ts`
- [Stock data API](https://github.com/bob0706/algolearn/blob/main/app/api/stock-data/route.ts): `app/api/stock-data/route.ts`
- [Stock data service](https://github.com/bob0706/algolearn/blob/main/lib/stockService.ts): `lib/stockService.ts`
- [Symbols API](https://github.com/bob0706/algolearn/blob/main/app/api/symbols/route.ts): `app/api/symbols/route.ts`
- [Frontend API client](https://github.com/bob0706/algolearn/blob/main/lib/api.ts): `lib/api.ts`

### Simulation

- [Trade simulator](https://github.com/bob0706/algolearn/blob/main/app/simulator/page.tsx): `app/simulator/page.tsx`

### Other components

- **Learner**
- [Platform entry](https://github.com/bob0706/algolearn/blob/main/app/page.tsx): `app/page.tsx`
- **Gemini AI**
- **Yahoo Finance**
- **MetaMask and chain**

## Connections

- Learner → Platform entry: opens
- Learner → Learning hub: studies
- Learner → Strategy builder: describes strategy
- Learner → Backtester: runs test
- Learner → Trade simulator: practices trades
- Strategy builder → Frontend API client: requests generation
- Strategy builder → Frontend API client: loads templates
- Strategy builder → Firebase services: saves strategy
- Frontend API client → Strategy generation API: posts prompt
- Frontend API client → Template API: gets templates
- Strategy generation API → Gemini AI: generates code
- Strategy generation API → Market and templates: uses fallback templates
- Template API → Market and templates: reads templates
- Backtester → Frontend API client: requests data and test
- Frontend API client → Symbols API: gets symbols
- Frontend API client → Stock data API: gets prices
- Frontend API client → Backtest API: submits strategy
- Stock data API → Stock data service: fetches bars
- Backtest API → Stock data service: fetches bars
- Stock data service → Yahoo Finance: requests history
- Backtest API → Backtest engine: executes strategy
- Trade simulator → Frontend API client: loads symbols and bars
- Trade simulator → Firebase services: updates progress
- Trade simulator → MetaMask and chain: logs results
- User dashboard → Firebase services: reads account data
