# vighnesh-6/sector-rotation-regime-discovery- architecture

> Architecture diagram of the GitHub repository vighnesh-6/sector-rotation-regime-discovery-, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vighnesh-6/sector-rotation-regime-discovery-
- Repository: https://github.com/vighnesh-6/sector-rotation-regime-discovery-

## Overview

This repository combines an Indian-market regime-discovery research codebase with a deployed analytics dashboard and data-ingestion services. The research workflow spans loading and preparing market data, discovering and characterizing regimes, then evaluating portfolio strategies and robustness. Deployment adds market and macro-event ingestion, database-backed APIs, and dashboard views. The graph preserves these distinct product areas; links are limited to relationships visible in sampled source, the source index, or explicit documentation. Several deployment and research modules were not sampled, so their internal connections are left out.

Main entry points: [`src/regime_characterisation.py`](https://github.com/vighnesh-6/sector-rotation-regime-discovery-/blob/main/src/regime_characterisation.py) (Regime characterization), [`src/portfolio_backtest.py`](https://github.com/vighnesh-6/sector-rotation-regime-discovery-/blob/main/src/portfolio_backtest.py) (Portfolio backtest), [`deployment/events/database.py`](https://github.com/vighnesh-6/sector-rotation-regime-discovery-/blob/main/deployment/events/database.py) (Event database adapter), [`src/comparative_evaluation.py`](https://github.com/vighnesh-6/sector-rotation-regime-discovery-/blob/main/src/comparative_evaluation.py) (Comparative evaluation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_research_data["Research Data"]
  node_data_loader["Market data loader<br/>[data_loader.py]"]
  node_data_cleaning["Data cleaning<br/>[data_cleaning.py]"]
  node_normalization["Normalization<br/>[normalization.py]"]
  node_feature_engineering["Feature engineering"]
  node_event_analysis["Event analysis<br/>[event_analysis.py]"]
end

subgraph group_regimes["Regime Analysis"]
  node_regime_discovery["Regime discovery"]
  node_regime_characterisation["Regime characterization"]
  node_rotation_rules["Rotation rules"]
end

subgraph group_evaluation["Strategy Evaluation"]
  node_portfolio_construction["Portfolio construction"]
  node_portfolio_backtest["Portfolio backtest"]
  node_benchmark_backtest["Benchmark backtest"]
  node_comparative_evaluation["Comparative evaluation"]
  node_robustness["Robustness analysis"]
  node_statistical_validation["Statistical validation"]
end

subgraph group_deployment_data["Data Services"]
  node_catchup["Candle catch-up<br/>[catchup_fetcher.py]"]
  node_yfinance_client["Yahoo client<br/>[yfinance_client.py]"]
  node_market_database[("Market database<br/>[connection.py]")]
  node_event_collector["Macro event collection<br/>[daily_collector.py]"]
  node_event_storage["Event storage<br/>[storage.py]"]
  node_event_database["Event database adapter<br/>[database.py]"]
  node_automation["Workflow dispatcher<br/>[dispatcher.mjs]"]
end

subgraph group_dashboard["Analytics Dashboard"]
  node_web_pages["Analytics views"]
  node_api_routes["Analytics API routes"]
end

node_analyst(("Research user"))
node_yahoo(("Yahoo Finance"))
node_neon[("Neon database")]
node_github(("GitHub API"))

node_analyst -.->|"loads data"| node_data_loader
node_data_loader -.->|"supplies features"| node_regime_characterisation
node_regime_characterisation -->|"uses"| node_normalization
node_regime_discovery -.->|"produces regimes"| node_regime_characterisation
node_regime_characterisation -.->|"informs portfolios"| node_portfolio_construction
node_portfolio_construction -.->|"constructs inputs"| node_portfolio_backtest
node_portfolio_backtest -->|"evaluated by"| node_comparative_evaluation
node_benchmark_backtest -->|"compared by"| node_comparative_evaluation
node_portfolio_backtest -->|"sensitivity inputs"| node_robustness
node_benchmark_backtest -->|"sensitivity inputs"| node_robustness
node_comparative_evaluation -->|"sensitivity inputs"| node_robustness
node_yahoo -.->|"provides prices"| node_yfinance_client
node_catchup -->|"fetches candles"| node_yfinance_client
node_catchup -->|"queries and writes"| node_market_database
node_event_collector -.->|"stores events"| node_event_storage
node_event_storage -->|"queries and transacts"| node_event_database
node_event_database -->|"inherits client"| node_market_database
node_event_database -->|"runs SQL batches"| node_neon
node_analyst -.->|"views analytics"| node_web_pages
node_automation -->|"dispatches workflows"| node_github

click node_data_loader "https://github.com/vighnesh-6/sector-rotation-regime-discovery-/blob/main/src/data_loader.py"
click node_data_cleaning "https://github.com/vighnesh-6/sector-rotation-regime-discovery-/blob/main/src/data_cleaning.py"
click node_normalization "https://github.com/vighnesh-6/sector-rotation-regime-discovery-/blob/main/src/normalization.py"
click node_feature_engineering "https://github.com/vighnesh-6/sector-rotation-regime-discovery-/blob/main/src/feature_engineering.py"
click node_event_analysis "https://github.com/vighnesh-6/sector-rotation-regime-discovery-/blob/main/src/event_analysis.py"
click node_regime_discovery "https://github.com/vighnesh-6/sector-rotation-regime-discovery-/blob/main/src/regime_discovery.py"
click node_regime_characterisation "https://github.com/vighnesh-6/sector-rotation-regime-discovery-/blob/main/src/regime_characterisation.py"
click node_rotation_rules "https://github.com/vighnesh-6/sector-rotation-regime-discovery-/blob/main/src/regime_rotation_rules.py"
click node_portfolio_construction "https://github.com/vighnesh-6/sector-rotation-regime-discovery-/blob/main/src/portfolio_construction.py"
click node_portfolio_backtest "https://github.com/vighnesh-6/sector-rotation-regime-discovery-/blob/main/src/portfolio_backtest.py"
click node_benchmark_backtest "https://github.com/vighnesh-6/sector-rotation-regime-discovery-/blob/main/src/benchmark_backtest.py"
click node_comparative_evaluation "https://github.com/vighnesh-6/sector-rotation-regime-discovery-/blob/main/src/comparative_evaluation.py"
click node_robustness "https://github.com/vighnesh-6/sector-rotation-regime-discovery-/tree/main/src/robustness"
click node_statistical_validation "https://github.com/vighnesh-6/sector-rotation-regime-discovery-/blob/main/src/statistical_validation.py"
click node_catchup "https://github.com/vighnesh-6/sector-rotation-regime-discovery-/blob/main/deployment/ingestion/catchup_fetcher.py"
click node_yfinance_client "https://github.com/vighnesh-6/sector-rotation-regime-discovery-/blob/main/deployment/ingestion/yfinance_client.py"
click node_market_database "https://github.com/vighnesh-6/sector-rotation-regime-discovery-/blob/main/deployment/database/connection.py"
click node_event_collector "https://github.com/vighnesh-6/sector-rotation-regime-discovery-/blob/main/deployment/events/daily_collector.py"
click node_event_storage "https://github.com/vighnesh-6/sector-rotation-regime-discovery-/blob/main/deployment/events/storage.py"
click node_event_database "https://github.com/vighnesh-6/sector-rotation-regime-discovery-/blob/main/deployment/events/database.py"
click node_web_pages "https://github.com/vighnesh-6/sector-rotation-regime-discovery-/tree/main/deployment/web/app"
click node_api_routes "https://github.com/vighnesh-6/sector-rotation-regime-discovery-/tree/main/deployment/web/app/api/v1"
click node_automation "https://github.com/vighnesh-6/sector-rotation-regime-discovery-/blob/main/deployment/automation/lib/dispatcher.mjs"

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_loader,node_data_cleaning,node_normalization,node_feature_engineering,node_event_analysis,node_analyst toneBlue
class node_regime_discovery,node_regime_characterisation,node_rotation_rules,node_neon toneAmber
class node_portfolio_construction,node_portfolio_backtest,node_benchmark_backtest,node_comparative_evaluation,node_robustness,node_statistical_validation,node_github toneMint
class node_catchup,node_yfinance_client,node_market_database,node_event_collector,node_event_storage,node_event_database,node_automation toneRose
class node_web_pages,node_api_routes,node_yahoo toneIndigo
```

## Components

### Research Data

- [Market data loader](https://github.com/vighnesh-6/sector-rotation-regime-discovery-/blob/main/src/data_loader.py): `src/data_loader.py`
- [Data cleaning](https://github.com/vighnesh-6/sector-rotation-regime-discovery-/blob/main/src/data_cleaning.py): `src/data_cleaning.py`
- [Normalization](https://github.com/vighnesh-6/sector-rotation-regime-discovery-/blob/main/src/normalization.py): `src/normalization.py`
- [Feature engineering](https://github.com/vighnesh-6/sector-rotation-regime-discovery-/blob/main/src/feature_engineering.py): `src/feature_engineering.py`
- [Event analysis](https://github.com/vighnesh-6/sector-rotation-regime-discovery-/blob/main/src/event_analysis.py): `src/event_analysis.py`

### Regime Analysis

- [Regime discovery](https://github.com/vighnesh-6/sector-rotation-regime-discovery-/blob/main/src/regime_discovery.py): `src/regime_discovery.py`
- [Regime characterization](https://github.com/vighnesh-6/sector-rotation-regime-discovery-/blob/main/src/regime_characterisation.py): `src/regime_characterisation.py`
- [Rotation rules](https://github.com/vighnesh-6/sector-rotation-regime-discovery-/blob/main/src/regime_rotation_rules.py): `src/regime_rotation_rules.py`

### Strategy Evaluation

- [Portfolio construction](https://github.com/vighnesh-6/sector-rotation-regime-discovery-/blob/main/src/portfolio_construction.py): `src/portfolio_construction.py`
- [Portfolio backtest](https://github.com/vighnesh-6/sector-rotation-regime-discovery-/blob/main/src/portfolio_backtest.py): `src/portfolio_backtest.py`
- [Benchmark backtest](https://github.com/vighnesh-6/sector-rotation-regime-discovery-/blob/main/src/benchmark_backtest.py): `src/benchmark_backtest.py`
- [Comparative evaluation](https://github.com/vighnesh-6/sector-rotation-regime-discovery-/blob/main/src/comparative_evaluation.py): `src/comparative_evaluation.py`
- [Robustness analysis](https://github.com/vighnesh-6/sector-rotation-regime-discovery-/tree/main/src/robustness): `src/robustness`
- [Statistical validation](https://github.com/vighnesh-6/sector-rotation-regime-discovery-/blob/main/src/statistical_validation.py): `src/statistical_validation.py`

### Data Services

- [Candle catch-up](https://github.com/vighnesh-6/sector-rotation-regime-discovery-/blob/main/deployment/ingestion/catchup_fetcher.py): `deployment/ingestion/catchup_fetcher.py`
- [Yahoo client](https://github.com/vighnesh-6/sector-rotation-regime-discovery-/blob/main/deployment/ingestion/yfinance_client.py): `deployment/ingestion/yfinance_client.py`
- [Market database](https://github.com/vighnesh-6/sector-rotation-regime-discovery-/blob/main/deployment/database/connection.py): `deployment/database/connection.py`
- [Macro event collection](https://github.com/vighnesh-6/sector-rotation-regime-discovery-/blob/main/deployment/events/daily_collector.py): `deployment/events/daily_collector.py`
- [Event storage](https://github.com/vighnesh-6/sector-rotation-regime-discovery-/blob/main/deployment/events/storage.py): `deployment/events/storage.py`
- [Event database adapter](https://github.com/vighnesh-6/sector-rotation-regime-discovery-/blob/main/deployment/events/database.py): `deployment/events/database.py`
- [Workflow dispatcher](https://github.com/vighnesh-6/sector-rotation-regime-discovery-/blob/main/deployment/automation/lib/dispatcher.mjs): `deployment/automation/lib/dispatcher.mjs`

### Analytics Dashboard

- [Analytics views](https://github.com/vighnesh-6/sector-rotation-regime-discovery-/tree/main/deployment/web/app): `deployment/web/app`
- [Analytics API routes](https://github.com/vighnesh-6/sector-rotation-regime-discovery-/tree/main/deployment/web/app/api/v1): `deployment/web/app/api/v1`

### Other components

- **Research user**
- **Yahoo Finance**
- **Neon database**
- **GitHub API**

## Connections

- Research user → Market data loader: loads data
- Market data loader → Regime characterization: supplies features
- Regime characterization → Normalization: uses (evidence: `src/regime_characterisation.py`)
- Regime discovery → Regime characterization: produces regimes
- Regime characterization → Portfolio construction: informs portfolios
- Portfolio construction → Portfolio backtest: constructs inputs
- Portfolio backtest → Comparative evaluation: evaluated by (evidence: `src/robustness/execution_sensitivity.py`)
- Benchmark backtest → Comparative evaluation: compared by (evidence: `src/robustness/benchmark_sensitivity.py`)
- Portfolio backtest → Robustness analysis: sensitivity inputs (evidence: `src/robustness/execution_sensitivity.py`)
- Benchmark backtest → Robustness analysis: sensitivity inputs (evidence: `src/robustness/benchmark_sensitivity.py`)
- Comparative evaluation → Robustness analysis: sensitivity inputs (evidence: `src/robustness/benchmark_sensitivity.py`)
- Yahoo Finance → Yahoo client: provides prices
- Candle catch-up → Yahoo client: fetches candles (evidence: `deployment/ingestion/catchup_fetcher.py`)
- Candle catch-up → Market database: queries and writes (evidence: `deployment/ingestion/catchup_fetcher.py`)
- Macro event collection → Event storage: stores events
- Event storage → Event database adapter: queries and transacts (evidence: `deployment/events/storage.py`)
- Event database adapter → Market database: inherits client (evidence: `deployment/events/database.py`)
- Event database adapter → Neon database: runs SQL batches (evidence: `deployment/events/database.py`)
- Research user → Analytics views: views analytics
- Workflow dispatcher → GitHub API: dispatches workflows (evidence: `deployment/automation/lib/dispatcher.mjs`)
