# heysanjeevv/market-lab architecture

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

- Interactive diagram: https://gitdiagram.com/heysanjeevv/market-lab
- Repository: https://github.com/heysanjeevv/market-lab

## Overview

Market Lab is a locally run NSE dashboard. A browser user views the dashboard served by the app, which combines live Smart Money and Sector Map data with stock charts, research notes, and the Swing Lab. The two market-data engines provide live market views; the Lab separately fetches and analyzes historical bars for backtests and swing signals. Edges are limited to calls or references supported by the excerpts, SOURCE INDEX, or README; several documented capabilities have directory-level nodes because their implementation was not sampled.

Main entry points: [`lab/research.py`](https://github.com/heysanjeevv/market-lab/blob/main/lab/research.py) (Company research), [`app.py`](https://github.com/heysanjeevv/market-lab/blob/main/app.py) (Dashboard app), [`lab/bars.py`](https://github.com/heysanjeevv/market-lab/blob/main/lab/bars.py) (Historical bars), [`lab/live.py`](https://github.com/heysanjeevv/market-lab/blob/main/lab/live.py) (Live Lab panel)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Dashboard"]
  node_dashboard["Dashboard app<br/>[app.py]"]
  node_webui["Dashboard views<br/>[index.html]"]
end

subgraph group_smart["Smart Money"]
  node_smfeed["Live market feed<br/>[feed.py]"]
  node_smmarket["Market helpers<br/>[market.py]"]
  node_smsmc["Smart-money patterns<br/>[smc.py]"]
  node_smstructure["Market structure<br/>[structure.py]"]
end

subgraph group_sector["Sector Map"]
  node_sxlive["Sector live data<br/>[live.py]"]
  node_sxuniverse[("Stock universe<br/>[universe.py]")]
  node_sxnews["Sector headlines<br/>[news.py]"]
  node_sxsmc["Sector chart patterns<br/>[smc.py]"]
  node_sxstructure["Sector structure<br/>[structure.py]"]
  node_sxmarket["Sector market helpers<br/>[market.py]"]
end

subgraph group_lab["Strategy Lab"]
  node_bars[("Historical bars<br/>[bars.py]")]
  node_features["Indicators and features<br/>[features.py]"]
  node_strategies["Intraday strategies<br/>[strategies.py]"]
  node_engine["Backtest engine<br/>[engine.py]"]
  node_analyze["Results analysis<br/>[analyze.py]"]
  node_report["Lab reporting<br/>[report.py]"]
  node_lablive["Live Lab panel<br/>[live.py]"]
  node_swing["Swing backtest<br/>[swing.py]"]
  node_swinglive["Live swing signals<br/>[swing_live.py]"]
end

subgraph group_research["Research"]
  node_researchnote["Company research<br/>[research.py]"]
  node_industries["Industry context<br/>[industries.py]"]
end

node_user(("Browser user"))
node_nse(("NSE public data"))
node_yahoo(("Yahoo Finance"))
node_news(("Google News RSS"))
node_wiki(("Wikipedia"))

node_user -->|"views"| node_webui
node_webui -->|"requests data"| node_dashboard
node_dashboard -->|"uses feed"| node_smfeed
node_dashboard -->|"uses sector data"| node_sxlive
node_dashboard -->|"uses headlines"| node_sxnews
node_dashboard -->|"uses patterns"| node_sxsmc
node_dashboard -->|"uses Lab data"| node_lablive
node_dashboard -->|"uses swing data"| node_swinglive
node_dashboard -->|"uses research"| node_researchnote
node_smfeed -->|"uses helpers"| node_smmarket
node_smfeed -->|"uses patterns"| node_smsmc
node_smsmc -->|"uses structure"| node_smstructure
node_smsmc -->|"uses helpers"| node_smmarket
node_sxlive -->|"uses helpers"| node_sxmarket
node_sxlive -->|"reads universe"| node_sxuniverse
node_sxnews -->|"uses helpers"| node_sxmarket
node_sxsmc -->|"uses structure"| node_sxstructure
node_sxsmc -->|"uses helpers"| node_sxmarket
node_sxuniverse -->|"fetches data"| node_sxmarket
node_bars -->|"uses HTTP helpers"| node_smmarket
node_bars -->|"downloads prices"| node_yahoo
node_features -.->|"builds from bars"| node_bars
node_engine -->|"loads bars"| node_bars
node_engine -->|"builds features"| node_features
node_engine -->|"runs signals"| node_strategies
node_report -->|"uses engine"| node_engine
node_report -->|"uses filters"| node_analyze
node_report -->|"summarizes strategies"| node_strategies
node_lablive -->|"loads bars"| node_bars
node_lablive -->|"uses features"| node_features
node_lablive -->|"uses engine"| node_engine
node_lablive -->|"uses report"| node_report
node_swing -->|"loads bars"| node_bars
node_swing -->|"uses features"| node_features
node_swinglive -->|"loads bars"| node_bars
node_swinglive -->|"uses swing rules"| node_swing
node_researchnote -->|"fetches market data"| node_smmarket
node_researchnote -->|"uses classification"| node_sxuniverse
node_researchnote -->|"uses price history"| node_bars
node_researchnote -->|"uses industry context"| node_industries
node_researchnote -->|"uses swing results"| node_swing
node_researchnote -->|"reads filings"| node_nse
node_researchnote -->|"reads summaries"| node_wiki
node_researchnote -->|"fetches market series"| node_yahoo
node_sxnews -->|"fetches headlines"| node_news
node_sxuniverse -->|"fetches classification"| node_nse
node_smfeed -.->|"fetches live data"| node_nse

click node_dashboard "https://github.com/heysanjeevv/market-lab/blob/main/app.py"
click node_webui "https://github.com/heysanjeevv/market-lab/blob/main/web/index.html"
click node_smfeed "https://github.com/heysanjeevv/market-lab/blob/main/sm/feed.py"
click node_smmarket "https://github.com/heysanjeevv/market-lab/blob/main/sm/market.py"
click node_smsmc "https://github.com/heysanjeevv/market-lab/blob/main/sm/smc.py"
click node_smstructure "https://github.com/heysanjeevv/market-lab/blob/main/sm/structure.py"
click node_sxlive "https://github.com/heysanjeevv/market-lab/blob/main/sx/live.py"
click node_sxuniverse "https://github.com/heysanjeevv/market-lab/blob/main/sx/universe.py"
click node_sxnews "https://github.com/heysanjeevv/market-lab/blob/main/sx/news.py"
click node_sxsmc "https://github.com/heysanjeevv/market-lab/blob/main/sx/smc.py"
click node_sxstructure "https://github.com/heysanjeevv/market-lab/blob/main/sx/structure.py"
click node_sxmarket "https://github.com/heysanjeevv/market-lab/blob/main/sx/market.py"
click node_bars "https://github.com/heysanjeevv/market-lab/blob/main/lab/bars.py"
click node_features "https://github.com/heysanjeevv/market-lab/blob/main/lab/features.py"
click node_strategies "https://github.com/heysanjeevv/market-lab/blob/main/lab/strategies.py"
click node_engine "https://github.com/heysanjeevv/market-lab/blob/main/lab/engine.py"
click node_analyze "https://github.com/heysanjeevv/market-lab/blob/main/lab/analyze.py"
click node_report "https://github.com/heysanjeevv/market-lab/blob/main/lab/report.py"
click node_lablive "https://github.com/heysanjeevv/market-lab/blob/main/lab/live.py"
click node_swing "https://github.com/heysanjeevv/market-lab/blob/main/lab/swing.py"
click node_swinglive "https://github.com/heysanjeevv/market-lab/blob/main/lab/swing_live.py"
click node_researchnote "https://github.com/heysanjeevv/market-lab/blob/main/lab/research.py"
click node_industries "https://github.com/heysanjeevv/market-lab/blob/main/lab/industries.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_dashboard,node_webui,node_user toneBlue
class node_smfeed,node_smmarket,node_smsmc,node_smstructure toneAmber
class node_sxlive,node_sxuniverse,node_sxnews,node_sxsmc,node_sxstructure,node_sxmarket toneMint
class node_bars,node_features,node_strategies,node_engine,node_analyze,node_report,node_lablive,node_swing,node_swinglive toneRose
class node_researchnote,node_industries,node_nse,node_yahoo,node_news,node_wiki toneIndigo
```

## Components

### Dashboard

- [Dashboard app](https://github.com/heysanjeevv/market-lab/blob/main/app.py): `app.py`
- [Dashboard views](https://github.com/heysanjeevv/market-lab/blob/main/web/index.html): `web/index.html`

### Smart Money

- [Live market feed](https://github.com/heysanjeevv/market-lab/blob/main/sm/feed.py): `sm/feed.py`
- [Market helpers](https://github.com/heysanjeevv/market-lab/blob/main/sm/market.py): `sm/market.py`
- [Smart-money patterns](https://github.com/heysanjeevv/market-lab/blob/main/sm/smc.py): `sm/smc.py`
- [Market structure](https://github.com/heysanjeevv/market-lab/blob/main/sm/structure.py): `sm/structure.py`

### Sector Map

- [Sector live data](https://github.com/heysanjeevv/market-lab/blob/main/sx/live.py): `sx/live.py`
- [Stock universe](https://github.com/heysanjeevv/market-lab/blob/main/sx/universe.py): `sx/universe.py`
- [Sector headlines](https://github.com/heysanjeevv/market-lab/blob/main/sx/news.py): `sx/news.py`
- [Sector chart patterns](https://github.com/heysanjeevv/market-lab/blob/main/sx/smc.py): `sx/smc.py`
- [Sector structure](https://github.com/heysanjeevv/market-lab/blob/main/sx/structure.py): `sx/structure.py`
- [Sector market helpers](https://github.com/heysanjeevv/market-lab/blob/main/sx/market.py): `sx/market.py`

### Strategy Lab

- [Historical bars](https://github.com/heysanjeevv/market-lab/blob/main/lab/bars.py): `lab/bars.py`
- [Indicators and features](https://github.com/heysanjeevv/market-lab/blob/main/lab/features.py): `lab/features.py`
- [Intraday strategies](https://github.com/heysanjeevv/market-lab/blob/main/lab/strategies.py): `lab/strategies.py`
- [Backtest engine](https://github.com/heysanjeevv/market-lab/blob/main/lab/engine.py): `lab/engine.py`
- [Results analysis](https://github.com/heysanjeevv/market-lab/blob/main/lab/analyze.py): `lab/analyze.py`
- [Lab reporting](https://github.com/heysanjeevv/market-lab/blob/main/lab/report.py): `lab/report.py`
- [Live Lab panel](https://github.com/heysanjeevv/market-lab/blob/main/lab/live.py): `lab/live.py`
- [Swing backtest](https://github.com/heysanjeevv/market-lab/blob/main/lab/swing.py): `lab/swing.py`
- [Live swing signals](https://github.com/heysanjeevv/market-lab/blob/main/lab/swing_live.py): `lab/swing_live.py`

### Research

- [Company research](https://github.com/heysanjeevv/market-lab/blob/main/lab/research.py): `lab/research.py`
- [Industry context](https://github.com/heysanjeevv/market-lab/blob/main/lab/industries.py): `lab/industries.py`

### Other components

- **Browser user**
- **NSE public data**
- **Yahoo Finance**
- **Google News RSS**
- **Wikipedia**

## Connections

- Browser user → Dashboard views: views (evidence: `README.md`)
- Dashboard views → Dashboard app: requests data (evidence: `README.md`)
- Dashboard app → Live market feed: uses feed (evidence: `app.py`)
- Dashboard app → Sector live data: uses sector data (evidence: `app.py`)
- Dashboard app → Sector headlines: uses headlines (evidence: `app.py`)
- Dashboard app → Sector chart patterns: uses patterns (evidence: `app.py`)
- Dashboard app → Live Lab panel: uses Lab data (evidence: `app.py`)
- Dashboard app → Live swing signals: uses swing data (evidence: `app.py`)
- Dashboard app → Company research: uses research (evidence: `app.py`)
- Live market feed → Market helpers: uses helpers (evidence: `sm/feed.py`)
- Live market feed → Smart-money patterns: uses patterns (evidence: `sm/feed.py`)
- Smart-money patterns → Market structure: uses structure (evidence: `sm/smc.py`)
- Smart-money patterns → Market helpers: uses helpers (evidence: `sm/smc.py`)
- Sector live data → Sector market helpers: uses helpers (evidence: `sx/live.py`)
- Sector live data → Stock universe: reads universe (evidence: `sx/live.py`)
- Sector headlines → Sector market helpers: uses helpers (evidence: `sx/news.py`)
- Sector chart patterns → Sector structure: uses structure (evidence: `sx/smc.py`)
- Sector chart patterns → Sector market helpers: uses helpers (evidence: `sx/smc.py`)
- Stock universe → Sector market helpers: fetches data (evidence: `sx/universe.py`)
- Historical bars → Market helpers: uses HTTP helpers (evidence: `lab/bars.py`)
- Historical bars → Yahoo Finance: downloads prices (evidence: `lab/bars.py`)
- Indicators and features → Historical bars: builds from bars
- Backtest engine → Historical bars: loads bars (evidence: `lab/engine.py`)
- Backtest engine → Indicators and features: builds features (evidence: `lab/engine.py`)
- Backtest engine → Intraday strategies: runs signals (evidence: `lab/engine.py`)
- Lab reporting → Backtest engine: uses engine (evidence: `lab/report.py`)
- Lab reporting → Results analysis: uses filters (evidence: `lab/report.py`)
- Lab reporting → Intraday strategies: summarizes strategies (evidence: `lab/report.py`)
- Live Lab panel → Historical bars: loads bars (evidence: `lab/live.py`)
- Live Lab panel → Indicators and features: uses features (evidence: `lab/live.py`)
- Live Lab panel → Backtest engine: uses engine (evidence: `lab/live.py`)
- Live Lab panel → Lab reporting: uses report (evidence: `lab/live.py`)
- Swing backtest → Historical bars: loads bars (evidence: `lab/swing.py`)
- Swing backtest → Indicators and features: uses features (evidence: `lab/swing.py`)
- Live swing signals → Historical bars: loads bars (evidence: `lab/swing_live.py`)
- Live swing signals → Swing backtest: uses swing rules (evidence: `lab/swing_live.py`)
- Company research → Market helpers: fetches market data (evidence: `lab/research.py`)
- Company research → Stock universe: uses classification (evidence: `lab/research.py`)
- Company research → Historical bars: uses price history (evidence: `lab/research.py`)
- Company research → Industry context: uses industry context (evidence: `lab/research.py`)
- Company research → Swing backtest: uses swing results (evidence: `lab/research.py`)
- Company research → NSE public data: reads filings (evidence: `README.md`)
- Company research → Wikipedia: reads summaries (evidence: `README.md`)
- Company research → Yahoo Finance: fetches market series (evidence: `lab/research.py`)
- Sector headlines → Google News RSS: fetches headlines (evidence: `README.md`)
- Stock universe → NSE public data: fetches classification (evidence: `sx/universe.py`)
- Live market feed → NSE public data: fetches live data
