# iota-008/orb-strategy architecture

> Architecture diagram of the GitHub repository iota-008/orb-strategy, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/iota-008/orb-strategy
- Repository: https://github.com/iota-008/orb-strategy

## Overview

#### Purpose and entry points
IntraTrade is a real-time NSE intraday signal dashboard. The React SPA starts at `ORB Strategy/dashboard/src/index.js` and composes its UI in `ORB Strategy/dashboard/src/App.js`. The Node service starts from `ORB Strategy/server/index.js`, exposing REST APIs and a Socket.IO signal stream.

#### Frontend application
The dashboard presents market-open/closed state, Kite authentication callback flow, strategy selection, and live stock signals. Primary views/components are under:
- `ORB Strategy/dashboard/src/components/home.js`
- `ORB Strategy/dashboard/src/components/stocks.js`
- `ORB Strategy/dashboard/src/components/KiteCallback.js`

The browser calls `/api/*` for session, algorithm, watchlist, and market-status operations, then consumes Socket.IO broadcasts for incremental signal updates.

#### API and session boundary
Express routing separates API endpoints from engine orchestration:
- `ORB Strategy/server/routes/index.js`
- `ORB Strategy/server/routes/api.js`
- `ORB Strategy/server/controllers/method.js`

The controller is the integration boundary for Zerodha Kite Connect: it establishes/authenticates Kite access, obtains market status, manages subscriptions, and coordinates the ticker lifecycle with Socket.IO clients.

#### Streaming signal engine
KiteTicker delivers full-mode ticks for the selected NSE watchlist. On each tick, the engine retains instrument-specific state, invokes the active strategy, filters actionable Buy/Sell results, and broadcasts the resulting signal set. The strategy registry enables live switching without restarting the market stream:
- `ORB Strategy/server/controllers/method.js`
- `ORB Strategy/server/algos/index.js`
- `ORB Strategy/server/data/nse_symbols.js`

`nse_symbols.js` supplies the Nifty 50/100/500 subscription universes; environment configuration determines the active list and strategy thresholds.

#### Quantitative strategy boundary
Strategies are independent stateful-per-instrument calculation modules behind a common algorithm interface:
- `ORB Strategy/server/algos/orb.js`
- `ORB Strategy/server/algos/vwap.js`
- `ORB Strategy/server/algos/momentum.js`
- `ORB Strategy/server/algos/ema.js`

ORB captures an opening price range; VWAP and momentum compare LTP against intraday references; EMA detects crossover events. Each generates direction and stop-loss values, while the controller owns tick transport, strategy selection, and client broadcast.

#### Runtime and deployment
The system runs Node.js/Express plus Socket.IO and a separately built React static site. Docker builds the SPA into nginx and packages the backend:
- `ORB Strategy/dashboard/Dockerfile`
- `ORB Strategy/dashboard/nginx.conf`
- `ORB Strategy/server/Dockerfile`
- `docker-compose.yml`

Production traffic is intended to pass through Traefik with TLS: SPA requests go to nginx, `/api` and health traffic to Express, and `/socket.io` to the realtime server. Zerodha Kite Connect is the external market-data and authentication dependency.

#### Delivery boundary
GitHub Actions deploys the repository to a remote Docker Compose host:
- `.github/workflows/deploy.yml`
- `.env.production.example`

Secrets, Kite credentials, domain configuration, market hours, watchlist size, and strategy parameters are runtime/deployment concerns rather than application source state.

Main entry points: [`ORB Strategy/server/controllers/method.js`](https://github.com/iota-008/orb-strategy/blob/master/ORB%20Strategy/server/controllers/method.js) (Kite and stream controller), [`docker-compose.yml`](https://github.com/iota-008/orb-strategy/blob/master/docker-compose.yml) (Traefik TLS router), [`ORB Strategy/dashboard/src/App.js`](https://github.com/iota-008/orb-strategy/blob/master/ORB%20Strategy/dashboard/src/App.js) (Dashboard shell), [`ORB Strategy/dashboard/src/components/stocks.js`](https://github.com/iota-008/orb-strategy/blob/master/ORB%20Strategy/dashboard/src/components/stocks.js) (Live stocks view)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["React dashboard"]
  node_spa_entry["SPA entry<br/>React entry<br/>[index.js]"]
  node_app["Dashboard shell<br/>React app<br/>[App.js]"]
  node_views["Dashboard views<br/>React components<br/>[home.js]"]
  node_stocks["Live stocks view<br/>React component<br/>[stocks.js]"]
  node_kite_callback["Kite auth callback<br/>React component<br/>[KiteCallback.js]"]
end

subgraph group_backend["Signal service"]
  node_server_entry["Server entry<br/>Node runtime<br/>[index.js]"]
  node_express_routes["Express routes<br/>REST routing<br/>[index.js]"]
  node_api_routes["API endpoints<br/>REST API<br/>[api.js]"]
  node_controller["Kite and stream controller<br/>orchestrator<br/>[method.js]"]
  node_socketio["Signal stream<br/>Socket.IO server<br/>[index.js]"]
  node_strategy_registry["Strategy registry<br/>algorithm selector<br/>[index.js]"]
  node_strategies["Signal strategies<br/>stateful algorithms<br/>[orb.js]"]
end

subgraph group_market["Market integration"]
  node_watchlists["NSE watchlist universes<br/>instrument catalog<br/>[nse_symbols.js]"]
  node_kite{{"Zerodha Kite Connect<br/>external market API"}}
end

subgraph group_deployment["Production delivery"]
  node_nginx{{"Static-site nginx<br/>web server<br/>[nginx.conf]"}}
  node_traefik{{"Traefik TLS router<br/>edge proxy<br/>[docker-compose.yml]"}}
  node_compose["Docker Compose host<br/>container runtime<br/>[docker-compose.yml]"]
  node_deployment_workflow["GitHub deployment<br/>CI/CD workflow<br/>[deploy.yml]"]
end

node_spa_entry -->|"mounts"| node_app
node_app -->|"composes"| node_views
node_app -->|"composes"| node_stocks
node_app -->|"handles auth return"| node_kite_callback
node_views -->|"REST /api"| node_traefik
node_stocks -->|"Socket.IO"| node_traefik
node_traefik -->|"SPA traffic"| node_nginx
node_traefik -->|"API and realtime traffic"| node_server_entry
node_server_entry -->|"registers"| node_express_routes
node_express_routes -->|"dispatches"| node_api_routes
node_api_routes -->|"invokes"| node_controller
node_controller -->|"authenticates and subscribes"| node_kite
node_kite -->|"full-mode ticks"| node_controller
node_controller -->|"selects instruments"| node_watchlists
node_controller -->|"selects active strategy"| node_strategy_registry
node_strategy_registry -->|"resolves algorithm"| node_strategies
node_controller -->|"broadcasts signals"| node_socketio
node_socketio -->|"incremental updates"| node_stocks
node_deployment_workflow -->|"deploys"| node_compose
node_compose -->|"runs frontend image"| node_nginx
node_compose -->|"runs backend image"| node_server_entry
node_traefik -->|"routes to services"| node_compose

click node_spa_entry "https://github.com/iota-008/orb-strategy/blob/master/ORB%20Strategy/dashboard/src/index.js"
click node_app "https://github.com/iota-008/orb-strategy/blob/master/ORB%20Strategy/dashboard/src/App.js"
click node_views "https://github.com/iota-008/orb-strategy/blob/master/ORB%20Strategy/dashboard/src/components/home.js"
click node_stocks "https://github.com/iota-008/orb-strategy/blob/master/ORB%20Strategy/dashboard/src/components/stocks.js"
click node_kite_callback "https://github.com/iota-008/orb-strategy/blob/master/ORB%20Strategy/dashboard/src/components/KiteCallback.js"
click node_nginx "https://github.com/iota-008/orb-strategy/blob/master/ORB%20Strategy/dashboard/nginx.conf"
click node_traefik "https://github.com/iota-008/orb-strategy/blob/master/docker-compose.yml"
click node_server_entry "https://github.com/iota-008/orb-strategy/blob/master/ORB%20Strategy/server/index.js"
click node_express_routes "https://github.com/iota-008/orb-strategy/blob/master/ORB%20Strategy/server/routes/index.js"
click node_api_routes "https://github.com/iota-008/orb-strategy/blob/master/ORB%20Strategy/server/routes/api.js"
click node_controller "https://github.com/iota-008/orb-strategy/blob/master/ORB%20Strategy/server/controllers/method.js"
click node_socketio "https://github.com/iota-008/orb-strategy/blob/master/ORB%20Strategy/server/index.js"
click node_strategy_registry "https://github.com/iota-008/orb-strategy/blob/master/ORB%20Strategy/server/algos/index.js"
click node_strategies "https://github.com/iota-008/orb-strategy/blob/master/ORB%20Strategy/server/algos/orb.js"
click node_watchlists "https://github.com/iota-008/orb-strategy/blob/master/ORB%20Strategy/server/data/nse_symbols.js"
click node_compose "https://github.com/iota-008/orb-strategy/blob/master/docker-compose.yml"
click node_deployment_workflow "https://github.com/iota-008/orb-strategy/blob/master/.github/workflows/deploy.yml"

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_spa_entry,node_app,node_views,node_stocks,node_kite_callback toneBlue
class node_server_entry,node_express_routes,node_api_routes,node_controller,node_socketio,node_strategy_registry,node_strategies toneAmber
class node_watchlists,node_kite toneMint
class node_nginx,node_traefik,node_compose,node_deployment_workflow toneRose
```

## Components

### React dashboard

- [SPA entry](https://github.com/iota-008/orb-strategy/blob/master/ORB%20Strategy/dashboard/src/index.js): React entry · `ORB Strategy/dashboard/src/index.js`
- [Dashboard shell](https://github.com/iota-008/orb-strategy/blob/master/ORB%20Strategy/dashboard/src/App.js): React app · Composes authentication, market state, and live-signal UI. · `ORB Strategy/dashboard/src/App.js`
- [Dashboard views](https://github.com/iota-008/orb-strategy/blob/master/ORB%20Strategy/dashboard/src/components/home.js): React components · `ORB Strategy/dashboard/src/components/home.js`
- [Live stocks view](https://github.com/iota-008/orb-strategy/blob/master/ORB%20Strategy/dashboard/src/components/stocks.js): React component · `ORB Strategy/dashboard/src/components/stocks.js`
- [Kite auth callback](https://github.com/iota-008/orb-strategy/blob/master/ORB%20Strategy/dashboard/src/components/KiteCallback.js): React component · `ORB Strategy/dashboard/src/components/KiteCallback.js`

### Signal service

- [Server entry](https://github.com/iota-008/orb-strategy/blob/master/ORB%20Strategy/server/index.js): Node runtime · `ORB Strategy/server/index.js`
- [Express routes](https://github.com/iota-008/orb-strategy/blob/master/ORB%20Strategy/server/routes/index.js): REST routing · `ORB Strategy/server/routes/index.js`
- [API endpoints](https://github.com/iota-008/orb-strategy/blob/master/ORB%20Strategy/server/routes/api.js): REST API · Session, algorithm, watchlist, and market-status operations. · `ORB Strategy/server/routes/api.js`
- [Kite and stream controller](https://github.com/iota-008/orb-strategy/blob/master/ORB%20Strategy/server/controllers/method.js): orchestrator · Owns authentication, subscriptions, ticker lifecycle, and Socket.IO broadcasts. · `ORB Strategy/server/controllers/method.js`
- [Signal stream](https://github.com/iota-008/orb-strategy/blob/master/ORB%20Strategy/server/index.js): Socket.IO server · Publishes actionable signal sets to connected dashboards. · `ORB Strategy/server/index.js`
- [Strategy registry](https://github.com/iota-008/orb-strategy/blob/master/ORB%20Strategy/server/algos/index.js): algorithm selector · Enables live strategy switching without restarting the stream. · `ORB Strategy/server/algos/index.js`
- [Signal strategies](https://github.com/iota-008/orb-strategy/blob/master/ORB%20Strategy/server/algos/orb.js): stateful algorithms · ORB, VWAP, momentum, and EMA produce direction and stop-loss values per instrument. · `ORB Strategy/server/algos/orb.js`

### Market integration

- [NSE watchlist universes](https://github.com/iota-008/orb-strategy/blob/master/ORB%20Strategy/server/data/nse_symbols.js): instrument catalog · Supplies Nifty 50, 100, and 500 subscription lists. · `ORB Strategy/server/data/nse_symbols.js`
- **Zerodha Kite Connect**: external market API · Provides authentication and full-mode market ticks.

### Production delivery

- [Static-site nginx](https://github.com/iota-008/orb-strategy/blob/master/ORB%20Strategy/dashboard/nginx.conf): web server · Serves the built React SPA. · `ORB Strategy/dashboard/nginx.conf`
- [Traefik TLS router](https://github.com/iota-008/orb-strategy/blob/master/docker-compose.yml): edge proxy · Routes SPA, API, health, and Socket.IO traffic. · `docker-compose.yml`
- [Docker Compose host](https://github.com/iota-008/orb-strategy/blob/master/docker-compose.yml): container runtime · Runs the frontend and backend production services. · `docker-compose.yml`
- [GitHub deployment](https://github.com/iota-008/orb-strategy/blob/master/.github/workflows/deploy.yml): CI/CD workflow · Deploys the repository to the remote Compose host. · `.github/workflows/deploy.yml`

## Connections

- SPA entry → Dashboard shell: mounts
- Dashboard shell → Dashboard views: composes
- Dashboard shell → Live stocks view: composes
- Dashboard shell → Kite auth callback: handles auth return
- Dashboard views → Traefik TLS router: REST /api
- Live stocks view → Traefik TLS router: Socket.IO
- Traefik TLS router → Static-site nginx: SPA traffic
- Traefik TLS router → Server entry: API and realtime traffic
- Server entry → Express routes: registers
- Express routes → API endpoints: dispatches
- API endpoints → Kite and stream controller: invokes
- Kite and stream controller → Zerodha Kite Connect: authenticates and subscribes
- Zerodha Kite Connect → Kite and stream controller: full-mode ticks
- Kite and stream controller → NSE watchlist universes: selects instruments
- Kite and stream controller → Strategy registry: selects active strategy
- Strategy registry → Signal strategies: resolves algorithm
- Kite and stream controller → Signal stream: broadcasts signals
- Signal stream → Live stocks view: incremental updates
- GitHub deployment → Docker Compose host: deploys
- Docker Compose host → Static-site nginx: runs frontend image
- Docker Compose host → Server entry: runs backend image
- Traefik TLS router → Docker Compose host: routes to services
