# kbizme/nsemine architecture

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

- Interactive diagram: https://gitdiagram.com/kbizme/nsemine
- Repository: https://github.com/kbizme/nsemine

## Overview

nsemine is a Python interface for NSE India and NiftyIndices market data. Users call domain APIs for live quotes, historical charts, exchange statistics, derivatives, or archives; those modules request remote data, then return raw payloads or cleaned dictionaries/DataFrames. The internal path includes shared scraping/session management, request headers, endpoint definitions, and data transformations. README documents broad capabilities beyond the sampled excerpts; those are represented at module level. Arrows are limited to relationships shown in excerpts, the source index, or README; unsampled wiring is not inferred.

Main entry points: [`nsemine/bin/scraper.py`](https://github.com/kbizme/nsemine/blob/main/nsemine/bin/scraper.py) (HTTP scraper), [`nsemine/live.py`](https://github.com/kbizme/nsemine/blob/main/nsemine/live.py) (Live market data), [`nsemine/historical.py`](https://github.com/kbizme/nsemine/blob/main/nsemine/historical.py) (Historical charts), [`nsemine/fno.py`](https://github.com/kbizme/nsemine/blob/main/nsemine/fno.py) (F&O analytics)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Market APIs"]
  node_live["Live market data<br/>[live.py]"]
  node_history["Historical charts<br/>[historical.py]"]
  node_exchange["Exchange data<br/>[nse.py]"]
  node_derivatives["F&amp;O analytics<br/>[fno.py]"]
  node_archives["Market archives<br/>[archives.py]"]
  node_stock_object["Stock facade<br/>[generic.py]"]
end

subgraph group_transport["Request Infrastructure"]
  node_scraper["HTTP scraper<br/>[scraper.py]"]
  node_async_batch["Async batch engine<br/>[autils.py]"]
  node_auth[("Session cache<br/>[auth.py]")]
  node_headers["Request headers<br/>[header.py]"]
end

subgraph group_support["Shared Support"]
  node_endpoints["NSE endpoints<br/>[urls.py]"]
  node_transform["Data transformations<br/>[utils.py]"]
end

node_user(("Library caller"))
node_nse{{"NSE India"}}
node_nifty{{"NiftyIndices"}}

node_user -->|"requests quotes"| node_live
node_user -->|"requests history"| node_history
node_user -.->|"requests exchange data"| node_exchange
node_user -.->|"requests derivatives"| node_derivatives
node_user -.->|"requests archives"| node_archives
node_user -->|"creates facade"| node_stock_object
node_stock_object -->|"fetches quote"| node_live
node_live -->|"batches quotes"| node_async_batch
node_live -->|"fetches market data"| node_scraper
node_history -->|"fetches chart data"| node_scraper
node_exchange -->|"fetches exchange data"| node_scraper
node_derivatives -->|"fetches derivatives"| node_scraper
node_derivatives -->|"gets constituent quotes"| node_live
node_archives -->|"fetches archive data"| node_scraper
node_async_batch -->|"fetches concurrently"| node_scraper
node_async_batch -->|"builds headers"| node_headers
node_async_batch -->|"processes quotes"| node_transform
node_scraper -->|"reads and saves tokens"| node_auth
node_scraper -->|"uses headers"| node_headers
node_live -->|"normalizes responses"| node_transform
node_history -->|"processes chart data"| node_transform
node_exchange -->|"processes responses"| node_transform
node_derivatives -->|"processes responses"| node_transform
node_live -->|"uses endpoint definitions"| node_endpoints
node_history -->|"uses endpoint definitions"| node_endpoints
node_exchange -->|"uses endpoint definitions"| node_endpoints
node_derivatives -->|"uses endpoint definitions"| node_endpoints
node_archives -->|"uses endpoint definitions"| node_endpoints
node_scraper -->|"requests"| node_nse
node_history -.->|"requests index history"| node_nifty

click node_live "https://github.com/kbizme/nsemine/blob/main/nsemine/live.py"
click node_history "https://github.com/kbizme/nsemine/blob/main/nsemine/historical.py"
click node_exchange "https://github.com/kbizme/nsemine/blob/main/nsemine/nse.py"
click node_derivatives "https://github.com/kbizme/nsemine/blob/main/nsemine/fno.py"
click node_archives "https://github.com/kbizme/nsemine/blob/main/nsemine/archives.py"
click node_stock_object "https://github.com/kbizme/nsemine/blob/main/nsemine/generic.py"
click node_scraper "https://github.com/kbizme/nsemine/blob/main/nsemine/bin/scraper.py"
click node_async_batch "https://github.com/kbizme/nsemine/blob/main/nsemine/bin/autils.py"
click node_auth "https://github.com/kbizme/nsemine/blob/main/nsemine/bin/auth.py"
click node_headers "https://github.com/kbizme/nsemine/blob/main/nsemine/bin/header.py"
click node_endpoints "https://github.com/kbizme/nsemine/blob/main/nsemine/utilities/urls.py"
click node_transform "https://github.com/kbizme/nsemine/blob/main/nsemine/utilities/utils.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_live,node_history,node_exchange,node_derivatives,node_archives,node_stock_object toneBlue
class node_scraper,node_async_batch,node_auth,node_headers toneAmber
class node_endpoints,node_transform toneMint
class node_user,node_nse,node_nifty toneIndigo
```

## Components

### Market APIs

- [Live market data](https://github.com/kbizme/nsemine/blob/main/nsemine/live.py): `nsemine/live.py`
- [Historical charts](https://github.com/kbizme/nsemine/blob/main/nsemine/historical.py): `nsemine/historical.py`
- [Exchange data](https://github.com/kbizme/nsemine/blob/main/nsemine/nse.py): `nsemine/nse.py`
- [F&O analytics](https://github.com/kbizme/nsemine/blob/main/nsemine/fno.py): `nsemine/fno.py`
- [Market archives](https://github.com/kbizme/nsemine/blob/main/nsemine/archives.py): `nsemine/archives.py`
- [Stock facade](https://github.com/kbizme/nsemine/blob/main/nsemine/generic.py): `nsemine/generic.py`

### Request Infrastructure

- [HTTP scraper](https://github.com/kbizme/nsemine/blob/main/nsemine/bin/scraper.py): `nsemine/bin/scraper.py`
- [Async batch engine](https://github.com/kbizme/nsemine/blob/main/nsemine/bin/autils.py): `nsemine/bin/autils.py`
- [Session cache](https://github.com/kbizme/nsemine/blob/main/nsemine/bin/auth.py): `nsemine/bin/auth.py`
- [Request headers](https://github.com/kbizme/nsemine/blob/main/nsemine/bin/header.py): `nsemine/bin/header.py`

### Shared Support

- [NSE endpoints](https://github.com/kbizme/nsemine/blob/main/nsemine/utilities/urls.py): `nsemine/utilities/urls.py`
- [Data transformations](https://github.com/kbizme/nsemine/blob/main/nsemine/utilities/utils.py): `nsemine/utilities/utils.py`

### Other components

- **Library caller**
- **NSE India**
- **NiftyIndices**

## Connections

- Library caller → Live market data: requests quotes (evidence: `README.md`)
- Library caller → Historical charts: requests history (evidence: `README.md`)
- Library caller → Exchange data: requests exchange data (evidence: `README.md`)
- Library caller → F&O analytics: requests derivatives (evidence: `README.md`)
- Library caller → Market archives: requests archives (evidence: `README.md`)
- Library caller → Stock facade: creates facade (evidence: `nsemine/generic.py`)
- Stock facade → Live market data: fetches quote (evidence: `nsemine/generic.py`)
- Live market data → Async batch engine: batches quotes (evidence: `nsemine/live.py`)
- Live market data → HTTP scraper: fetches market data (evidence: `nsemine/live.py`)
- Historical charts → HTTP scraper: fetches chart data (evidence: `nsemine/historical.py`)
- Exchange data → HTTP scraper: fetches exchange data (evidence: `nsemine/nse.py`)
- F&O analytics → HTTP scraper: fetches derivatives (evidence: `nsemine/fno.py`)
- F&O analytics → Live market data: gets constituent quotes (evidence: `nsemine/fno.py`)
- Market archives → HTTP scraper: fetches archive data (evidence: `nsemine/archives.py`)
- Async batch engine → HTTP scraper: fetches concurrently (evidence: `nsemine/bin/autils.py`)
- Async batch engine → Request headers: builds headers (evidence: `nsemine/bin/autils.py`)
- Async batch engine → Data transformations: processes quotes (evidence: `nsemine/bin/autils.py`)
- HTTP scraper → Session cache: reads and saves tokens (evidence: `nsemine/bin/scraper.py`)
- HTTP scraper → Request headers: uses headers (evidence: `nsemine/bin/scraper.py`)
- Live market data → Data transformations: normalizes responses (evidence: `nsemine/live.py`)
- Historical charts → Data transformations: processes chart data (evidence: `nsemine/historical.py`)
- Exchange data → Data transformations: processes responses (evidence: `nsemine/nse.py`)
- F&O analytics → Data transformations: processes responses (evidence: `nsemine/fno.py`)
- Live market data → NSE endpoints: uses endpoint definitions (evidence: `nsemine/live.py`)
- Historical charts → NSE endpoints: uses endpoint definitions (evidence: `nsemine/historical.py`)
- Exchange data → NSE endpoints: uses endpoint definitions (evidence: `nsemine/nse.py`)
- F&O analytics → NSE endpoints: uses endpoint definitions (evidence: `nsemine/fno.py`)
- Market archives → NSE endpoints: uses endpoint definitions (evidence: `nsemine/archives.py`)
- HTTP scraper → NSE India: requests
- Historical charts → NiftyIndices: requests index history (evidence: `README.md`)
