# vijish18/indian-regime-trader architecture

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

- Interactive diagram: https://gitdiagram.com/vijish18/indian-regime-trader
- Repository: https://github.com/vijish18/indian-regime-trader

## Overview

This is an India-focused, long-only NSE cash-equity trading system. Its main workflow is point-in-time market data → regime assessment and stock ranking → portfolio construction → independent risk checks → order execution, with orchestration coordinating trading sessions. Separate research paths provide walk-forward backtesting and performance analysis; paper trading, broker adapters, operational monitoring, and live-safety controls support deployment. Several subsystem paths and links are based on README documentation or source-index references rather than inspected implementations.

Main entry points: [`orchestration/orchestrator.py`](https://github.com/vijish18/indian-regime-trader/blob/master/orchestration/orchestrator.py) (Trading orchestration), [`execution/order_manager.py`](https://github.com/vijish18/indian-regime-trader/blob/master/execution/order_manager.py) (Order lifecycle), [`core/features/feature_engineering.py`](https://github.com/vijish18/indian-regime-trader/blob/master/core/features/feature_engineering.py) (Market features), [`core/regime/allocation.py`](https://github.com/vijish18/indian-regime-trader/blob/master/core/regime/allocation.py) (Exposure allocation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Market data"]
  node_data_layer["Ingestion and data<br/>[ingestion.py]"]
  node_market_store[("Local data storage<br/>[storage.py]")]
end

subgraph group_strategy["Strategy"]
  node_universe["Point-in-time universe<br/>[universe.py]"]
  node_selection["Stock selection<br/>[stock_selector.py]"]
  node_features["Market features"]
  node_hmm["Regime model<br/>[hmm_engine.py]"]
  node_allocation["Exposure allocation<br/>[allocation.py]"]
  node_portfolio["Portfolio construction"]
end

subgraph group_research["Backtesting"]
  node_backtest["Backtest engine<br/>[engine.py]"]
  node_walk_forward["Walk-forward analysis<br/>[walk_forward.py]"]
  node_costs["Indian trading costs<br/>[costs.py]"]
end

subgraph group_trading["Trading operations"]
  node_risk["Risk management<br/>[risk_manager.py]"]
  node_orchestrator["Trading orchestration<br/>[orchestrator.py]"]
  node_order_manager["Order lifecycle<br/>[order_manager.py]"]
  node_paper_broker["Paper broker<br/>[paper_broker.py]"]
  node_zerodha["Zerodha adapter<br/>[kite_broker.py]"]
  node_paper_runtime["Paper trading runtime<br/>[paper_runtime.py]"]
end

subgraph group_operations["Operations"]
  node_config["Configuration<br/>[models.py]"]
  node_monitoring["Monitoring and alerts<br/>[alerts.py]"]
  node_live_gate["Live safety gate<br/>[preflight.py]"]
end

node_operator(("Operator"))

node_operator -->|"runs sessions"| node_orchestrator
node_config -->|"configures"| node_orchestrator
node_data_layer -->|"persists data"| node_market_store
node_market_store -.->|"supplies observations"| node_features
node_data_layer -->|"supports eligibility"| node_universe
node_universe -->|"filters candidates"| node_selection
node_features -->|"provides features"| node_hmm
node_hmm -->|"classifies regime"| node_allocation
node_allocation -->|"sets exposure budget"| node_portfolio
node_selection -->|"provides rankings"| node_portfolio
node_portfolio -->|"submits proposed targets"| node_risk
node_orchestrator -->|"coordinates regime inputs"| node_features
node_orchestrator -->|"coordinates allocation"| node_allocation
node_orchestrator -->|"manages orders"| node_order_manager
node_risk -.->|"authorizes trades"| node_order_manager
node_order_manager -->|"dispatches orders"| node_paper_broker
node_order_manager -.->|"dispatches orders"| node_zerodha
node_paper_runtime -.->|"runs simulation"| node_paper_broker
node_walk_forward -->|"runs folds"| node_backtest
node_backtest -->|"prices trades"| node_costs
node_orchestrator -->|"emits operational alerts"| node_monitoring
node_operator -.->|"views status"| node_monitoring
node_live_gate -.->|"gates live trading"| node_zerodha

click node_config "https://github.com/vijish18/indian-regime-trader/blob/master/config/models.py"
click node_data_layer "https://github.com/vijish18/indian-regime-trader/blob/master/data/ingestion.py"
click node_market_store "https://github.com/vijish18/indian-regime-trader/blob/master/data/storage.py"
click node_universe "https://github.com/vijish18/indian-regime-trader/blob/master/universe/universe.py"
click node_selection "https://github.com/vijish18/indian-regime-trader/blob/master/universe/stock_selector.py"
click node_features "https://github.com/vijish18/indian-regime-trader/blob/master/core/features/feature_engineering.py"
click node_hmm "https://github.com/vijish18/indian-regime-trader/blob/master/core/regime/hmm_engine.py"
click node_allocation "https://github.com/vijish18/indian-regime-trader/blob/master/core/regime/allocation.py"
click node_portfolio "https://github.com/vijish18/indian-regime-trader/blob/master/portfolio/portfolio_constructor.py"
click node_risk "https://github.com/vijish18/indian-regime-trader/blob/master/risk/risk_manager.py"
click node_orchestrator "https://github.com/vijish18/indian-regime-trader/blob/master/orchestration/orchestrator.py"
click node_order_manager "https://github.com/vijish18/indian-regime-trader/blob/master/execution/order_manager.py"
click node_paper_broker "https://github.com/vijish18/indian-regime-trader/blob/master/broker/adapters/paper_broker.py"
click node_zerodha "https://github.com/vijish18/indian-regime-trader/blob/master/broker/zerodha/kite_broker.py"
click node_paper_runtime "https://github.com/vijish18/indian-regime-trader/blob/master/app/paper_runtime.py"
click node_backtest "https://github.com/vijish18/indian-regime-trader/blob/master/backtest/engine.py"
click node_walk_forward "https://github.com/vijish18/indian-regime-trader/blob/master/backtest/walk_forward.py"
click node_costs "https://github.com/vijish18/indian-regime-trader/blob/master/backtest/costs.py"
click node_monitoring "https://github.com/vijish18/indian-regime-trader/blob/master/monitoring/alerts.py"
click node_live_gate "https://github.com/vijish18/indian-regime-trader/blob/master/live/preflight.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_data_layer,node_market_store toneBlue
class node_universe,node_selection,node_features,node_hmm,node_allocation,node_portfolio toneAmber
class node_backtest,node_walk_forward,node_costs toneMint
class node_risk,node_orchestrator,node_order_manager,node_paper_broker,node_zerodha,node_paper_runtime toneRose
class node_config,node_monitoring,node_live_gate,node_operator toneIndigo
```

## Components

### Market data

- [Ingestion and data](https://github.com/vijish18/indian-regime-trader/blob/master/data/ingestion.py): `data/ingestion.py`
- [Local data storage](https://github.com/vijish18/indian-regime-trader/blob/master/data/storage.py): `data/storage.py`

### Strategy

- [Point-in-time universe](https://github.com/vijish18/indian-regime-trader/blob/master/universe/universe.py): `universe/universe.py`
- [Stock selection](https://github.com/vijish18/indian-regime-trader/blob/master/universe/stock_selector.py): `universe/stock_selector.py`
- [Market features](https://github.com/vijish18/indian-regime-trader/blob/master/core/features/feature_engineering.py): `core/features/feature_engineering.py`
- [Regime model](https://github.com/vijish18/indian-regime-trader/blob/master/core/regime/hmm_engine.py): `core/regime/hmm_engine.py`
- [Exposure allocation](https://github.com/vijish18/indian-regime-trader/blob/master/core/regime/allocation.py): `core/regime/allocation.py`
- [Portfolio construction](https://github.com/vijish18/indian-regime-trader/blob/master/portfolio/portfolio_constructor.py): `portfolio/portfolio_constructor.py`

### Backtesting

- [Backtest engine](https://github.com/vijish18/indian-regime-trader/blob/master/backtest/engine.py): `backtest/engine.py`
- [Walk-forward analysis](https://github.com/vijish18/indian-regime-trader/blob/master/backtest/walk_forward.py): `backtest/walk_forward.py`
- [Indian trading costs](https://github.com/vijish18/indian-regime-trader/blob/master/backtest/costs.py): `backtest/costs.py`

### Trading operations

- [Risk management](https://github.com/vijish18/indian-regime-trader/blob/master/risk/risk_manager.py): `risk/risk_manager.py`
- [Trading orchestration](https://github.com/vijish18/indian-regime-trader/blob/master/orchestration/orchestrator.py): `orchestration/orchestrator.py`
- [Order lifecycle](https://github.com/vijish18/indian-regime-trader/blob/master/execution/order_manager.py): `execution/order_manager.py`
- [Paper broker](https://github.com/vijish18/indian-regime-trader/blob/master/broker/adapters/paper_broker.py): `broker/adapters/paper_broker.py`
- [Zerodha adapter](https://github.com/vijish18/indian-regime-trader/blob/master/broker/zerodha/kite_broker.py): `broker/zerodha/kite_broker.py`
- [Paper trading runtime](https://github.com/vijish18/indian-regime-trader/blob/master/app/paper_runtime.py): `app/paper_runtime.py`

### Operations

- [Configuration](https://github.com/vijish18/indian-regime-trader/blob/master/config/models.py): `config/models.py`
- [Monitoring and alerts](https://github.com/vijish18/indian-regime-trader/blob/master/monitoring/alerts.py): `monitoring/alerts.py`
- [Live safety gate](https://github.com/vijish18/indian-regime-trader/blob/master/live/preflight.py): `live/preflight.py`

### Other components

- **Operator**

## Connections

- Operator → Trading orchestration: runs sessions
- Configuration → Trading orchestration: configures (evidence: `orchestration/orchestrator.py`)
- Ingestion and data → Local data storage: persists data (evidence: `data/ingestion.py`)
- Local data storage → Market features: supplies observations
- Ingestion and data → Point-in-time universe: supports eligibility
- Point-in-time universe → Stock selection: filters candidates (evidence: `universe/stock_selector.py`)
- Market features → Regime model: provides features (evidence: `core/regime/hmm_engine.py`)
- Regime model → Exposure allocation: classifies regime (evidence: `core/regime/allocation.py`)
- Exposure allocation → Portfolio construction: sets exposure budget (evidence: `portfolio/portfolio_constructor.py`)
- Stock selection → Portfolio construction: provides rankings (evidence: `portfolio/portfolio_constructor.py`)
- Portfolio construction → Risk management: submits proposed targets (evidence: `risk/risk_manager.py`)
- Trading orchestration → Market features: coordinates regime inputs (evidence: `orchestration/orchestrator.py`)
- Trading orchestration → Exposure allocation: coordinates allocation (evidence: `orchestration/orchestrator.py`)
- Trading orchestration → Order lifecycle: manages orders (evidence: `orchestration/orchestrator.py`)
- Risk management → Order lifecycle: authorizes trades
- Order lifecycle → Paper broker: dispatches orders (evidence: `broker/adapters/paper_broker.py`)
- Order lifecycle → Zerodha adapter: dispatches orders
- Paper trading runtime → Paper broker: runs simulation
- Walk-forward analysis → Backtest engine: runs folds (evidence: `backtest/walk_forward.py`)
- Backtest engine → Indian trading costs: prices trades (evidence: `backtest/engine.py`)
- Trading orchestration → Monitoring and alerts: emits operational alerts (evidence: `orchestration/orchestrator.py`)
- Operator → Monitoring and alerts: views status
- Live safety gate → Zerodha adapter: gates live trading
