# neuromancer-1984/nifty-options-analytics architecture

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

- Interactive diagram: https://gitdiagram.com/neuromancer-1984/nifty-options-analytics
- Repository: https://github.com/neuromancer-1984/nifty-options-analytics

## Overview

This repository provides NIFTY and BANKNIFTY options-chain analytics: a collector obtains daily NSE bhavcopy data, enriches and summarizes option contracts, persists snapshots, and trains a direction model; a Streamlit dashboard reads stored snapshots, metrics, and predictions to present charts and signals. The sampled source shows the daily bhavcopy collection path; although fetch.py implements a separate live NSE chain client, no caller is shown. The README is empty, so capability coverage is based on the dashboard and sampled modules.

Main entry points: [`collector.py`](https://github.com/neuromancer-1984/nifty-options-analytics/blob/main/collector.py) (Snapshot collector), [`db.py`](https://github.com/neuromancer-1984/nifty-options-analytics/blob/main/db.py) (Database access), [`ml.py`](https://github.com/neuromancer-1984/nifty-options-analytics/blob/main/ml.py) (Direction model), [`app.py`](https://github.com/neuromancer-1984/nifty-options-analytics/blob/main/app.py) (Analytics dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_collection["Collection"]
  node_collector["Snapshot collector<br/>[collector.py]"]
  node_bhavcopy["Bhavcopy loader<br/>[fetch_bhav.py]"]
  node_live_nse["Live chain client<br/>[fetch.py]"]
end

subgraph group_analytics["Analytics"]
  node_greeks["Greeks enrichment<br/>[greeks.py]"]
  node_metrics["Chain metrics<br/>[analysis.py]"]
  node_config["Market settings<br/>[config.py]"]
  node_model["Direction model<br/>[ml.py]"]
end

subgraph group_persistence["Persistence"]
  node_database[("PostgreSQL")]
  node_db_access["Database access<br/>[db.py]"]
  node_schema["Data schema<br/>[schema.sql]"]
end

subgraph group_presentation["Presentation"]
  node_dashboard["Analytics dashboard<br/>[app.py]"]
end

node_operator(("Operator"))
node_nse_archive(("NSE archive"))
node_dashboard_user(("Dashboard user"))

node_operator -->|"runs collection"| node_collector
node_collector -->|"loads daily data"| node_bhavcopy
node_bhavcopy -->|"downloads archive"| node_nse_archive
node_collector -->|"enriches contracts"| node_greeks
node_collector -->|"computes summaries"| node_metrics
node_collector -->|"stores snapshots"| node_db_access
node_collector -->|"trains after collection"| node_model
node_greeks -->|"reads rate"| node_config
node_collector -->|"reads collection settings"| node_config
node_db_access -->|"reads and writes"| node_database
node_db_access -->|"initializes from"| node_schema
node_model -->|"reads metrics; saves predictions"| node_db_access
node_model -->|"reads thresholds"| node_config
node_dashboard_user -->|"selects views"| node_dashboard
node_dashboard -->|"queries analytics data"| node_db_access
node_dashboard -->|"reads snapshots, metrics, predictions"| node_database

click node_collector "https://github.com/neuromancer-1984/nifty-options-analytics/blob/main/collector.py"
click node_bhavcopy "https://github.com/neuromancer-1984/nifty-options-analytics/blob/main/fetch_bhav.py"
click node_live_nse "https://github.com/neuromancer-1984/nifty-options-analytics/blob/main/fetch.py"
click node_greeks "https://github.com/neuromancer-1984/nifty-options-analytics/blob/main/greeks.py"
click node_metrics "https://github.com/neuromancer-1984/nifty-options-analytics/blob/main/analysis.py"
click node_config "https://github.com/neuromancer-1984/nifty-options-analytics/blob/main/config.py"
click node_db_access "https://github.com/neuromancer-1984/nifty-options-analytics/blob/main/db.py"
click node_schema "https://github.com/neuromancer-1984/nifty-options-analytics/blob/main/schema.sql"
click node_model "https://github.com/neuromancer-1984/nifty-options-analytics/blob/main/ml.py"
click node_dashboard "https://github.com/neuromancer-1984/nifty-options-analytics/blob/main/app.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_collector,node_bhavcopy,node_live_nse,node_dashboard_user toneBlue
class node_greeks,node_metrics,node_config,node_model toneAmber
class node_database,node_db_access,node_schema toneMint
class node_dashboard toneRose
class node_operator,node_nse_archive toneIndigo
```

## Components

### Collection

- [Snapshot collector](https://github.com/neuromancer-1984/nifty-options-analytics/blob/main/collector.py): `collector.py`
- [Bhavcopy loader](https://github.com/neuromancer-1984/nifty-options-analytics/blob/main/fetch_bhav.py): `fetch_bhav.py`
- [Live chain client](https://github.com/neuromancer-1984/nifty-options-analytics/blob/main/fetch.py): `fetch.py`

### Analytics

- [Greeks enrichment](https://github.com/neuromancer-1984/nifty-options-analytics/blob/main/greeks.py): `greeks.py`
- [Chain metrics](https://github.com/neuromancer-1984/nifty-options-analytics/blob/main/analysis.py): `analysis.py`
- [Market settings](https://github.com/neuromancer-1984/nifty-options-analytics/blob/main/config.py): `config.py`
- [Direction model](https://github.com/neuromancer-1984/nifty-options-analytics/blob/main/ml.py): `ml.py`

### Persistence

- **PostgreSQL**
- [Database access](https://github.com/neuromancer-1984/nifty-options-analytics/blob/main/db.py): `db.py`
- [Data schema](https://github.com/neuromancer-1984/nifty-options-analytics/blob/main/schema.sql): `schema.sql`

### Presentation

- [Analytics dashboard](https://github.com/neuromancer-1984/nifty-options-analytics/blob/main/app.py): `app.py`

### Other components

- **Operator**
- **NSE archive**
- **Dashboard user**

## Connections

- Operator → Snapshot collector: runs collection
- Snapshot collector → Bhavcopy loader: loads daily data
- Bhavcopy loader → NSE archive: downloads archive
- Snapshot collector → Greeks enrichment: enriches contracts
- Snapshot collector → Chain metrics: computes summaries
- Snapshot collector → Database access: stores snapshots
- Snapshot collector → Direction model: trains after collection
- Greeks enrichment → Market settings: reads rate
- Snapshot collector → Market settings: reads collection settings
- Database access → PostgreSQL: reads and writes
- Database access → Data schema: initializes from
- Direction model → Database access: reads metrics; saves predictions
- Direction model → Market settings: reads thresholds
- Dashboard user → Analytics dashboard: selects views
- Analytics dashboard → Database access: queries analytics data
- Analytics dashboard → PostgreSQL: reads snapshots, metrics, predictions
