# venkateshpabbati/kotak-neo-python architecture

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

- Interactive diagram: https://gitdiagram.com/venkateshpabbati/kotak-neo-python
- Repository: https://github.com/venkateshpabbati/kotak-neo-python

## Overview

Kotak Neo API is a Python trading SDK. Its main user flow is to create a NeoAPI client, authenticate with TOTP and MPIN, perform trading or account/market-data operations, and optionally log out. It also offers separate async market-data and order/position WebSocket feeds. The source index and excerpts support the facade, REST transport, and feed decoding relationships; several service implementations were not excerpted, so their internal call paths are not expanded.

Main entry points: [`neo_api_client/neo_api.py`](https://github.com/venkateshpabbati/kotak-neo-python/blob/main/neo_api_client/neo_api.py) (NeoAPI facade), [`neo_api_client/rest.py`](https://github.com/venkateshpabbati/kotak-neo-python/blob/main/neo_api_client/rest.py) (HTTP REST transport), [`neo_api_client/websocket/feed/client.py`](https://github.com/venkateshpabbati/kotak-neo-python/blob/main/neo_api_client/websocket/feed/client.py) (SFeed WebSocket), [`neo_api_client/websocket/orderfeed/client.py`](https://github.com/venkateshpabbati/kotak-neo-python/blob/main/neo_api_client/websocket/orderfeed/client.py) (Order feed WebSocket)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client and transport"]
  node_facade["NeoAPI facade<br/>[neo_api.py]"]
  node_config["Session configuration<br/>[neo_utility.py]"]
  node_validation["Request validation"]
  node_api_client["API client<br/>[api_client.py]"]
  node_rest["HTTP REST transport<br/>[rest.py]"]
end

subgraph group_trading["Trading and account"]
  node_auth["TOTP authentication<br/>[totp.py]"]
  node_logout["Logout<br/>[logout.py]"]
  node_orders["Order placement<br/>[order.py]"]
  node_order_changes["Order changes<br/>[modify_order.py]"]
  node_order_reports["Order and trade reports<br/>[order_report.py]"]
  node_account_data["Portfolio and positions<br/>[portfolio.py]"]
  node_account_limits["Limits and margin<br/>[limits.py]"]
end

subgraph group_market["Market data"]
  node_quotes["Quotes and scrip master<br/>[quotes.py]"]
  node_scrip_search["Scrip search<br/>[scrip_search.py]"]
  node_scrip_cache[("Scrip cache<br/>[scrip_cache.py]")]
end

subgraph group_streaming["Streaming feeds"]
  node_market_feed["SFeed WebSocket<br/>[client.py]"]
  node_feed_decode["Feed protocol and models<br/>[protocol.py]"]
  node_order_feed["Order feed WebSocket<br/>[client.py]"]
  node_order_models["Order feed models<br/>[models.py]"]
end

subgraph group_crosscut["Shared utilities"]
  node_logger["Structured logging<br/>[logger.py]"]
  node_errors["Error handling<br/>[exceptions.py]"]
  node_reliability["Reliability helpers<br/>[retry.py]"]
end

node_developer(("SDK user"))
node_kotak_rest{{"Kotak REST API"}}

node_developer -->|"creates client"| node_facade
node_facade -->|"authenticates"| node_auth
node_facade -->|"places orders"| node_orders
node_facade -->|"requests quotes"| node_quotes
node_facade -->|"logs out"| node_logout
node_facade -->|"exposes order changes"| node_order_changes
node_facade -->|"exposes reports"| node_order_reports
node_facade -->|"exposes account data"| node_account_data
node_facade -->|"exposes limits"| node_account_limits
node_facade -->|"exposes search"| node_scrip_search
node_facade -->|"uses validation"| node_validation
node_facade -->|"configures session"| node_config
node_facade -->|"initializes API client"| node_api_client
node_api_client -->|"creates transport"| node_rest
node_rest -->|"sends REST requests"| node_kotak_rest
node_scrip_search -->|"reads and writes"| node_scrip_cache
node_developer -->|"subscribes to feed"| node_market_feed
node_market_feed -->|"decodes frames"| node_feed_decode
node_developer -->|"opens order feed"| node_order_feed
node_order_feed -->|"creates updates"| node_order_models
node_rest -->|"logs requests"| node_logger
node_market_feed -->|"logs feed events"| node_logger
node_order_feed -->|"logs feed events"| node_logger

click node_facade "https://github.com/venkateshpabbati/kotak-neo-python/blob/main/neo_api_client/neo_api.py"
click node_config "https://github.com/venkateshpabbati/kotak-neo-python/blob/main/neo_api_client/utils/neo_utility.py"
click node_validation "https://github.com/venkateshpabbati/kotak-neo-python/blob/main/neo_api_client/req_data_validation.py"
click node_api_client "https://github.com/venkateshpabbati/kotak-neo-python/blob/main/neo_api_client/api_client.py"
click node_rest "https://github.com/venkateshpabbati/kotak-neo-python/blob/main/neo_api_client/rest.py"
click node_auth "https://github.com/venkateshpabbati/kotak-neo-python/blob/main/neo_api_client/services/totp.py"
click node_logout "https://github.com/venkateshpabbati/kotak-neo-python/blob/main/neo_api_client/services/logout.py"
click node_orders "https://github.com/venkateshpabbati/kotak-neo-python/blob/main/neo_api_client/services/order.py"
click node_order_changes "https://github.com/venkateshpabbati/kotak-neo-python/blob/main/neo_api_client/services/modify_order.py"
click node_order_reports "https://github.com/venkateshpabbati/kotak-neo-python/blob/main/neo_api_client/services/order_report.py"
click node_account_data "https://github.com/venkateshpabbati/kotak-neo-python/blob/main/neo_api_client/services/portfolio.py"
click node_account_limits "https://github.com/venkateshpabbati/kotak-neo-python/blob/main/neo_api_client/services/limits.py"
click node_quotes "https://github.com/venkateshpabbati/kotak-neo-python/blob/main/neo_api_client/services/quotes.py"
click node_scrip_search "https://github.com/venkateshpabbati/kotak-neo-python/blob/main/neo_api_client/services/scrip_search.py"
click node_scrip_cache "https://github.com/venkateshpabbati/kotak-neo-python/blob/main/neo_api_client/utils/scrip_cache.py"
click node_market_feed "https://github.com/venkateshpabbati/kotak-neo-python/blob/main/neo_api_client/websocket/feed/client.py"
click node_feed_decode "https://github.com/venkateshpabbati/kotak-neo-python/blob/main/neo_api_client/websocket/feed/protocol.py"
click node_order_feed "https://github.com/venkateshpabbati/kotak-neo-python/blob/main/neo_api_client/websocket/orderfeed/client.py"
click node_order_models "https://github.com/venkateshpabbati/kotak-neo-python/blob/main/neo_api_client/websocket/orderfeed/models.py"
click node_logger "https://github.com/venkateshpabbati/kotak-neo-python/blob/main/neo_api_client/logger.py"
click node_errors "https://github.com/venkateshpabbati/kotak-neo-python/blob/main/neo_api_client/exceptions.py"
click node_reliability "https://github.com/venkateshpabbati/kotak-neo-python/blob/main/neo_api_client/retry.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_facade,node_config,node_validation,node_api_client,node_rest,node_developer toneBlue
class node_auth,node_logout,node_orders,node_order_changes,node_order_reports,node_account_data,node_account_limits toneAmber
class node_quotes,node_scrip_search,node_scrip_cache,node_kotak_rest toneMint
class node_market_feed,node_feed_decode,node_order_feed,node_order_models toneRose
class node_logger,node_errors,node_reliability toneIndigo
```

## Components

### Client and transport

- [NeoAPI facade](https://github.com/venkateshpabbati/kotak-neo-python/blob/main/neo_api_client/neo_api.py): `neo_api_client/neo_api.py`
- [Session configuration](https://github.com/venkateshpabbati/kotak-neo-python/blob/main/neo_api_client/utils/neo_utility.py): `neo_api_client/utils/neo_utility.py`
- [Request validation](https://github.com/venkateshpabbati/kotak-neo-python/blob/main/neo_api_client/req_data_validation.py): `neo_api_client/req_data_validation.py`
- [API client](https://github.com/venkateshpabbati/kotak-neo-python/blob/main/neo_api_client/api_client.py): `neo_api_client/api_client.py`
- [HTTP REST transport](https://github.com/venkateshpabbati/kotak-neo-python/blob/main/neo_api_client/rest.py): `neo_api_client/rest.py`

### Trading and account

- [TOTP authentication](https://github.com/venkateshpabbati/kotak-neo-python/blob/main/neo_api_client/services/totp.py): `neo_api_client/services/totp.py`
- [Logout](https://github.com/venkateshpabbati/kotak-neo-python/blob/main/neo_api_client/services/logout.py): `neo_api_client/services/logout.py`
- [Order placement](https://github.com/venkateshpabbati/kotak-neo-python/blob/main/neo_api_client/services/order.py): `neo_api_client/services/order.py`
- [Order changes](https://github.com/venkateshpabbati/kotak-neo-python/blob/main/neo_api_client/services/modify_order.py): `neo_api_client/services/modify_order.py`
- [Order and trade reports](https://github.com/venkateshpabbati/kotak-neo-python/blob/main/neo_api_client/services/order_report.py): `neo_api_client/services/order_report.py`
- [Portfolio and positions](https://github.com/venkateshpabbati/kotak-neo-python/blob/main/neo_api_client/services/portfolio.py): `neo_api_client/services/portfolio.py`
- [Limits and margin](https://github.com/venkateshpabbati/kotak-neo-python/blob/main/neo_api_client/services/limits.py): `neo_api_client/services/limits.py`

### Market data

- [Quotes and scrip master](https://github.com/venkateshpabbati/kotak-neo-python/blob/main/neo_api_client/services/quotes.py): `neo_api_client/services/quotes.py`
- [Scrip search](https://github.com/venkateshpabbati/kotak-neo-python/blob/main/neo_api_client/services/scrip_search.py): `neo_api_client/services/scrip_search.py`
- [Scrip cache](https://github.com/venkateshpabbati/kotak-neo-python/blob/main/neo_api_client/utils/scrip_cache.py): `neo_api_client/utils/scrip_cache.py`

### Streaming feeds

- [SFeed WebSocket](https://github.com/venkateshpabbati/kotak-neo-python/blob/main/neo_api_client/websocket/feed/client.py): `neo_api_client/websocket/feed/client.py`
- [Feed protocol and models](https://github.com/venkateshpabbati/kotak-neo-python/blob/main/neo_api_client/websocket/feed/protocol.py): `neo_api_client/websocket/feed/protocol.py`
- [Order feed WebSocket](https://github.com/venkateshpabbati/kotak-neo-python/blob/main/neo_api_client/websocket/orderfeed/client.py): `neo_api_client/websocket/orderfeed/client.py`
- [Order feed models](https://github.com/venkateshpabbati/kotak-neo-python/blob/main/neo_api_client/websocket/orderfeed/models.py): `neo_api_client/websocket/orderfeed/models.py`

### Shared utilities

- [Structured logging](https://github.com/venkateshpabbati/kotak-neo-python/blob/main/neo_api_client/logger.py): `neo_api_client/logger.py`
- [Error handling](https://github.com/venkateshpabbati/kotak-neo-python/blob/main/neo_api_client/exceptions.py): `neo_api_client/exceptions.py`
- [Reliability helpers](https://github.com/venkateshpabbati/kotak-neo-python/blob/main/neo_api_client/retry.py): `neo_api_client/retry.py`

### Other components

- **SDK user**
- **Kotak REST API**

## Connections

- SDK user → NeoAPI facade: creates client (evidence: `README.md`)
- NeoAPI facade → TOTP authentication: authenticates (evidence: `neo_api_client/neo_api.py`)
- NeoAPI facade → Order placement: places orders (evidence: `README.md`)
- NeoAPI facade → Quotes and scrip master: requests quotes (evidence: `README.md`)
- NeoAPI facade → Logout: logs out (evidence: `README.md`)
- NeoAPI facade → Order changes: exposes order changes (evidence: `neo_api_client/neo_api.py`)
- NeoAPI facade → Order and trade reports: exposes reports (evidence: `neo_api_client/neo_api.py`)
- NeoAPI facade → Portfolio and positions: exposes account data (evidence: `neo_api_client/neo_api.py`)
- NeoAPI facade → Limits and margin: exposes limits (evidence: `neo_api_client/neo_api.py`)
- NeoAPI facade → Scrip search: exposes search (evidence: `neo_api_client/neo_api.py`)
- NeoAPI facade → Request validation: uses validation (evidence: `neo_api_client/neo_api.py`)
- NeoAPI facade → Session configuration: configures session (evidence: `neo_api_client/neo_api.py`)
- NeoAPI facade → API client: initializes API client (evidence: `neo_api_client/neo_api.py`)
- API client → HTTP REST transport: creates transport (evidence: `neo_api_client/api_client.py`)
- HTTP REST transport → Kotak REST API: sends REST requests (evidence: `README.md`)
- Scrip search → Scrip cache: reads and writes (evidence: `neo_api_client/services/scrip_search.py`)
- SDK user → SFeed WebSocket: subscribes to feed (evidence: `README.md`)
- SFeed WebSocket → Feed protocol and models: decodes frames (evidence: `neo_api_client/websocket/feed/client.py`)
- SDK user → Order feed WebSocket: opens order feed (evidence: `README.md`)
- Order feed WebSocket → Order feed models: creates updates (evidence: `neo_api_client/websocket/orderfeed/client.py`)
- HTTP REST transport → Structured logging: logs requests (evidence: `neo_api_client/rest.py`)
- SFeed WebSocket → Structured logging: logs feed events (evidence: `neo_api_client/websocket/feed/client.py`)
- Order feed WebSocket → Structured logging: logs feed events (evidence: `neo_api_client/websocket/orderfeed/client.py`)
