# rehankwatla/market-lab architecture

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

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

## Overview

Market Lab is a locally run NSE dashboard: a user opens the browser UI, which presents live Smart Money and Sector Map views, charts and research notes, plus a Swing Lab. The main paths combine public market data with analysis: the Smart Money and Sector engines supply live views; sector data supports sector comparisons and news; historical bars feed intraday and swing strategy analysis; research combines company filings, market data and industry context. The README documents these capabilities and data sources. Some internal wiring is supported only by the source index, so uncertain links are omitted or marked dashed.

Main entry points: [`app.py`](https://github.com/rehankwatla/market-lab/blob/main/app.py) (Dashboard server), [`lab/swing_live.py`](https://github.com/rehankwatla/market-lab/blob/main/lab/swing_live.py) (Swing signals), [`lab/research.py`](https://github.com/rehankwatla/market-lab/blob/main/lab/research.py) (Company research), [`lab/engine.py`](https://github.com/rehankwatla/market-lab/blob/main/lab/engine.py) (Intraday backtest)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_dashboard["Dashboard"]
  node_browser["Web dashboard<br/>[index.html]"]
  node_server["Dashboard server<br/>[app.py]"]
end

subgraph group_smart["Smart Money"]
  node_smartfeed["Live market feed<br/>[feed.py]"]
  node_smartmarket["Market helpers<br/>[market.py]"]
  node_smartstructure["Structure analysis<br/>[structure.py]"]
  node_smartmoney["Smart Money signals<br/>[smc.py]"]
end

subgraph group_sector["Sector Map"]
  node_sectorlive["Sector live data<br/>[live.py]"]
  node_sectoruniverse[("Stock universe<br/>[universe.py]")]
  node_sectormarket["Sector market data<br/>[market.py]"]
  node_sectornews["Sector news<br/>[news.py]"]
  node_sectorstructure["Sector structure<br/>[structure.py]"]
  node_sectorsmc["Sector SMC<br/>[smc.py]"]
end

subgraph group_lab["Strategy Lab"]
  node_history[("Historical bars<br/>[bars.py]")]
  node_indicators["Indicator features<br/>[features.py]"]
  node_intradaystrategies["Intraday strategies<br/>[strategies.py]"]
  node_backtest["Intraday backtest<br/>[engine.py]"]
  node_labanalysis["Results analysis<br/>[analyze.py]"]
  node_labreport["Lab report<br/>[report.py]"]
  node_swingrules["Swing strategies<br/>[swing.py]"]
  node_swinglive["Swing signals<br/>[swing_live.py]"]
  node_swinganalysis["Swing analysis<br/>[swing_an.py]"]
  node_swingportfolio["Swing portfolio<br/>[swing_pf.py]"]
end

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

node_user(("Dashboard user"))
node_nse(("NSE public data"))
node_yahoo(("Yahoo Finance"))
node_google(("Google News RSS"))
node_wikipedia(("Wikipedia"))

node_user -->|"opens"| node_browser
node_browser -.->|"requests views"| node_server
node_server -.->|"serves live data"| node_smartfeed
node_server -.->|"serves sector views"| node_sectorlive
node_server -.->|"serves swing data"| node_swinglive
node_server -.->|"serves notes"| node_researchnote
node_smartfeed -.->|"uses helpers"| node_smartmarket
node_smartfeed -.->|"uses signals"| node_smartmoney
node_smartmoney -.->|"uses structure"| node_smartstructure
node_sectorlive -.->|"uses universe"| node_sectoruniverse
node_sectorlive -.->|"uses market data"| node_sectormarket
node_sectorlive -.->|"includes headlines"| node_sectornews
node_sectorsmc -.->|"uses structure"| node_sectorstructure
node_history -->|"fetches bars"| node_yahoo
node_history -->|"fetches universe"| node_nse
node_backtest -.->|"loads bars"| node_history
node_backtest -->|"builds features"| node_indicators
node_backtest -->|"runs signals"| node_intradaystrategies
node_labanalysis -.->|"analyzes trades"| node_backtest
node_labreport -->|"summarizes results"| node_labanalysis
node_labreport -->|"reads results"| node_backtest
node_swingrules -.->|"uses bars"| node_history
node_swinglive -.->|"loads bars"| node_history
node_swinglive -->|"scans setups"| node_swingrules
node_swinglive -.->|"uses analysis"| node_swinganalysis
node_swinglive -.->|"uses portfolio"| node_swingportfolio
node_researchnote -.->|"uses context"| node_industries
node_researchnote -->|"fetches filings"| node_nse
node_researchnote -->|"fetches prices"| node_yahoo
node_researchnote -->|"fetches summaries"| node_wikipedia
node_sectornews -->|"fetches headlines"| node_google
node_sectoruniverse -->|"fetches classification"| node_nse
node_sectoruniverse -.->|"fetches history"| node_yahoo

click node_browser "https://github.com/rehankwatla/market-lab/blob/main/web/index.html"
click node_server "https://github.com/rehankwatla/market-lab/blob/main/app.py"
click node_smartfeed "https://github.com/rehankwatla/market-lab/blob/main/sm/feed.py"
click node_smartmarket "https://github.com/rehankwatla/market-lab/blob/main/sm/market.py"
click node_smartstructure "https://github.com/rehankwatla/market-lab/blob/main/sm/structure.py"
click node_smartmoney "https://github.com/rehankwatla/market-lab/blob/main/sm/smc.py"
click node_sectorlive "https://github.com/rehankwatla/market-lab/blob/main/sx/live.py"
click node_sectoruniverse "https://github.com/rehankwatla/market-lab/blob/main/sx/universe.py"
click node_sectormarket "https://github.com/rehankwatla/market-lab/blob/main/sx/market.py"
click node_sectornews "https://github.com/rehankwatla/market-lab/blob/main/sx/news.py"
click node_sectorstructure "https://github.com/rehankwatla/market-lab/blob/main/sx/structure.py"
click node_sectorsmc "https://github.com/rehankwatla/market-lab/blob/main/sx/smc.py"
click node_history "https://github.com/rehankwatla/market-lab/blob/main/lab/bars.py"
click node_indicators "https://github.com/rehankwatla/market-lab/blob/main/lab/features.py"
click node_intradaystrategies "https://github.com/rehankwatla/market-lab/blob/main/lab/strategies.py"
click node_backtest "https://github.com/rehankwatla/market-lab/blob/main/lab/engine.py"
click node_labanalysis "https://github.com/rehankwatla/market-lab/blob/main/lab/analyze.py"
click node_labreport "https://github.com/rehankwatla/market-lab/blob/main/lab/report.py"
click node_swingrules "https://github.com/rehankwatla/market-lab/blob/main/lab/swing.py"
click node_swinglive "https://github.com/rehankwatla/market-lab/blob/main/lab/swing_live.py"
click node_swinganalysis "https://github.com/rehankwatla/market-lab/blob/main/lab/swing_an.py"
click node_swingportfolio "https://github.com/rehankwatla/market-lab/blob/main/lab/swing_pf.py"
click node_researchnote "https://github.com/rehankwatla/market-lab/blob/main/lab/research.py"
click node_industries "https://github.com/rehankwatla/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_browser,node_server,node_user toneBlue
class node_smartfeed,node_smartmarket,node_smartstructure,node_smartmoney toneAmber
class node_sectorlive,node_sectoruniverse,node_sectormarket,node_sectornews,node_sectorstructure,node_sectorsmc toneMint
class node_history,node_indicators,node_intradaystrategies,node_backtest,node_labanalysis,node_labreport,node_swingrules,node_swinglive,node_swinganalysis,node_swingportfolio toneRose
class node_researchnote,node_industries,node_nse,node_yahoo,node_google,node_wikipedia toneIndigo
```

## Components

### Dashboard

- [Web dashboard](https://github.com/rehankwatla/market-lab/blob/main/web/index.html): `web/index.html`
- [Dashboard server](https://github.com/rehankwatla/market-lab/blob/main/app.py): `app.py`

### Smart Money

- [Live market feed](https://github.com/rehankwatla/market-lab/blob/main/sm/feed.py): `sm/feed.py`
- [Market helpers](https://github.com/rehankwatla/market-lab/blob/main/sm/market.py): `sm/market.py`
- [Structure analysis](https://github.com/rehankwatla/market-lab/blob/main/sm/structure.py): `sm/structure.py`
- [Smart Money signals](https://github.com/rehankwatla/market-lab/blob/main/sm/smc.py): `sm/smc.py`

### Sector Map

- [Sector live data](https://github.com/rehankwatla/market-lab/blob/main/sx/live.py): `sx/live.py`
- [Stock universe](https://github.com/rehankwatla/market-lab/blob/main/sx/universe.py): `sx/universe.py`
- [Sector market data](https://github.com/rehankwatla/market-lab/blob/main/sx/market.py): `sx/market.py`
- [Sector news](https://github.com/rehankwatla/market-lab/blob/main/sx/news.py): `sx/news.py`
- [Sector structure](https://github.com/rehankwatla/market-lab/blob/main/sx/structure.py): `sx/structure.py`
- [Sector SMC](https://github.com/rehankwatla/market-lab/blob/main/sx/smc.py): `sx/smc.py`

### Strategy Lab

- [Historical bars](https://github.com/rehankwatla/market-lab/blob/main/lab/bars.py): `lab/bars.py`
- [Indicator features](https://github.com/rehankwatla/market-lab/blob/main/lab/features.py): `lab/features.py`
- [Intraday strategies](https://github.com/rehankwatla/market-lab/blob/main/lab/strategies.py): `lab/strategies.py`
- [Intraday backtest](https://github.com/rehankwatla/market-lab/blob/main/lab/engine.py): `lab/engine.py`
- [Results analysis](https://github.com/rehankwatla/market-lab/blob/main/lab/analyze.py): `lab/analyze.py`
- [Lab report](https://github.com/rehankwatla/market-lab/blob/main/lab/report.py): `lab/report.py`
- [Swing strategies](https://github.com/rehankwatla/market-lab/blob/main/lab/swing.py): `lab/swing.py`
- [Swing signals](https://github.com/rehankwatla/market-lab/blob/main/lab/swing_live.py): `lab/swing_live.py`
- [Swing analysis](https://github.com/rehankwatla/market-lab/blob/main/lab/swing_an.py): `lab/swing_an.py`
- [Swing portfolio](https://github.com/rehankwatla/market-lab/blob/main/lab/swing_pf.py): `lab/swing_pf.py`

### Research

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

### Other components

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

## Connections

- Dashboard user → Web dashboard: opens (evidence: `README.md`)
- Web dashboard → Dashboard server: requests views
- Dashboard server → Live market feed: serves live data (evidence: `app.py`)
- Dashboard server → Sector live data: serves sector views (evidence: `app.py`)
- Dashboard server → Swing signals: serves swing data (evidence: `app.py`)
- Dashboard server → Company research: serves notes (evidence: `app.py`)
- Live market feed → Market helpers: uses helpers (evidence: `sm/feed.py`)
- Live market feed → Smart Money signals: uses signals (evidence: `sm/feed.py`)
- Smart Money signals → Structure analysis: uses structure (evidence: `sm/smc.py`)
- Sector live data → Stock universe: uses universe (evidence: `sx/live.py`)
- Sector live data → Sector market data: uses market data (evidence: `sx/live.py`)
- Sector live data → Sector news: includes headlines
- Sector SMC → Sector structure: uses structure (evidence: `sx/smc.py`)
- Historical bars → Yahoo Finance: fetches bars (evidence: `lab/bars.py`)
- Historical bars → NSE public data: fetches universe (evidence: `lab/bars.py`)
- Intraday backtest → Historical bars: loads bars (evidence: `lab/engine.py`)
- Intraday backtest → Indicator features: builds features (evidence: `lab/engine.py`)
- Intraday backtest → Intraday strategies: runs signals (evidence: `lab/engine.py`)
- Results analysis → Intraday backtest: analyzes trades (evidence: `lab/analyze.py`)
- Lab report → Results analysis: summarizes results (evidence: `lab/report.py`)
- Lab report → Intraday backtest: reads results (evidence: `lab/report.py`)
- Swing strategies → Historical bars: uses bars (evidence: `lab/swing.py`)
- Swing signals → Historical bars: loads bars (evidence: `lab/swing_live.py`)
- Swing signals → Swing strategies: scans setups (evidence: `lab/swing_live.py`)
- Swing signals → Swing analysis: uses analysis (evidence: `lab/swing_live.py`)
- Swing signals → Swing portfolio: uses portfolio (evidence: `lab/swing_live.py`)
- Company research → Industry context: uses context (evidence: `lab/research.py`)
- Company research → NSE public data: fetches filings (evidence: `lab/research.py`)
- Company research → Yahoo Finance: fetches prices (evidence: `lab/research.py`)
- Company research → Wikipedia: fetches summaries (evidence: `README.md`)
- Sector news → Google News RSS: fetches headlines (evidence: `README.md`)
- Stock universe → NSE public data: fetches classification (evidence: `sx/universe.py`)
- Stock universe → Yahoo Finance: fetches history
