# santhosh144awc/openalgo architecture

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

- Interactive diagram: https://gitdiagram.com/santhosh144awc/openalgo
- Repository: https://github.com/santhosh144awc/openalgo

## Overview

OpenAlgo is a self-hosted algorithmic trading platform: users connect a broker, then build or submit strategies, analyze market data, and test or execute orders. The README documents several distinct trading surfaces sharing broker sessions and market-data infrastructure. The graph preserves those capabilities and the sandbox/analyzer domain stages; unsampled routes and service wiring are represented only where the README explicitly documents their relationships.

Main entry points: [`app.py`](https://github.com/santhosh144awc/openalgo/blob/main/app.py) (Flask application), [`services/market_data_service.py`](https://github.com/santhosh144awc/openalgo/blob/main/services/market_data_service.py) (Market data service), [`blueprints/orders.py`](https://github.com/santhosh144awc/openalgo/blob/main/blueprints/orders.py) (Order workflows), [`broker`](https://github.com/santhosh144awc/openalgo/tree/main/broker) (Broker integrations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Trading surfaces"]
  node_api["Unified broker API<br/>[orders.py]"]
  node_python["Python strategy host<br/>[python_strategy.py]"]
  node_flow["Visual Flow builder<br/>[flow.py]"]
  node_agent["AI trading agent<br/>[agent.py]"]
end

subgraph group_execution["Orders and execution"]
  node_brokerplugins["Broker integrations"]
  node_orders["Order workflows<br/>[orders.py]"]
  node_analyzer["Analyzer sandbox<br/>[analyzer.py]"]
  node_sandbox["Sandbox execution engine"]
  node_sandboxws["WebSocket execution"]
end

subgraph group_market["Market data and analytics"]
  node_options["Options analytics suite"]
  node_analytics["Market analytics"]
  node_marketdata["Market data service"]
  node_search["Symbol search<br/>[search_service.py]"]
end

subgraph group_strategy["Strategy lifecycle"]
  node_strategyengine["Strategy module engine<br/>[engine.py]"]
  node_portfolio["Portfolio tools<br/>[engine.py]"]
end

subgraph group_platform["Platform services"]
  node_app["Flask application<br/>[app.py]"]
  node_sandboxdb[("Sandbox state store<br/>[sandbox_db.py]")]
  node_strategystore[("Strategy state store")]
  node_authstore[("Auth and broker sessions<br/>[auth_db.py]")]
end

node_trader(("Trader or client"))
node_broker{{"Broker services"}}

node_trader -->|"uses platform"| node_app
node_app -->|"serves API"| node_api
node_app -->|"serves strategy host"| node_python
node_app -->|"serves Flow"| node_flow
node_app -->|"serves agent"| node_agent
node_app -->|"serves tools"| node_options
node_api -->|"submits orders"| node_orders
node_python -->|"uses order workflows"| node_orders
node_flow -->|"executes orders"| node_orders
node_agent -->|"reads market data"| node_marketdata
node_agent -->|"requests approved orders"| node_orders
node_api -->|"uses normalized API"| node_brokerplugins
node_orders -.->|"dispatches orders"| node_brokerplugins
node_brokerplugins -.->|"calls broker APIs"| node_broker
node_brokerplugins -.->|"streams broker data"| node_marketdata
node_analyzer -->|"tests orders"| node_sandbox
node_sandbox -->|"reads and writes"| node_sandboxdb
node_sandbox -->|"fetches quotes"| node_marketdata
node_sandboxws -->|"subscribes to updates"| node_marketdata
node_options -->|"uses live broker data"| node_marketdata
node_analytics -.->|"uses market data"| node_marketdata
node_strategyengine -->|"manages strategy state"| node_strategystore
node_strategyengine -.->|"dispatches strategy orders"| node_orders
node_portfolio -.->|"uses broker portfolio data"| node_brokerplugins
node_app -->|"checks sessions"| node_authstore
node_search -.->|"checks user context"| node_authstore
node_search -.->|"resolves symbols"| node_marketdata

click node_app "https://github.com/santhosh144awc/openalgo/blob/main/app.py"
click node_api "https://github.com/santhosh144awc/openalgo/blob/main/blueprints/orders.py"
click node_python "https://github.com/santhosh144awc/openalgo/blob/main/blueprints/python_strategy.py"
click node_flow "https://github.com/santhosh144awc/openalgo/blob/main/blueprints/flow.py"
click node_agent "https://github.com/santhosh144awc/openalgo/blob/main/blueprints/agent.py"
click node_options "https://github.com/santhosh144awc/openalgo/tree/main/blueprints"
click node_analytics "https://github.com/santhosh144awc/openalgo/tree/main/blueprints"
click node_marketdata "https://github.com/santhosh144awc/openalgo/blob/main/services/market_data_service.py"
click node_brokerplugins "https://github.com/santhosh144awc/openalgo/tree/main/broker"
click node_orders "https://github.com/santhosh144awc/openalgo/blob/main/blueprints/orders.py"
click node_analyzer "https://github.com/santhosh144awc/openalgo/blob/main/blueprints/analyzer.py"
click node_sandbox "https://github.com/santhosh144awc/openalgo/blob/main/sandbox/execution_engine.py"
click node_sandboxws "https://github.com/santhosh144awc/openalgo/blob/main/sandbox/websocket_execution_engine.py"
click node_sandboxdb "https://github.com/santhosh144awc/openalgo/blob/main/database/sandbox_db.py"
click node_strategyengine "https://github.com/santhosh144awc/openalgo/blob/main/services/strategy_module/engine.py"
click node_strategystore "https://github.com/santhosh144awc/openalgo/blob/main/database/strategy_module_db.py"
click node_portfolio "https://github.com/santhosh144awc/openalgo/blob/main/portfolio/engine.py"
click node_authstore "https://github.com/santhosh144awc/openalgo/blob/main/database/auth_db.py"
click node_search "https://github.com/santhosh144awc/openalgo/blob/main/services/search_service.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_api,node_python,node_flow,node_agent,node_trader toneBlue
class node_brokerplugins,node_orders,node_analyzer,node_sandbox,node_sandboxws toneAmber
class node_options,node_analytics,node_marketdata,node_search toneMint
class node_strategyengine,node_portfolio toneRose
class node_app,node_sandboxdb,node_strategystore,node_authstore,node_broker toneIndigo
```

## Components

### Trading surfaces

- [Unified broker API](https://github.com/santhosh144awc/openalgo/blob/main/blueprints/orders.py): `blueprints/orders.py`
- [Python strategy host](https://github.com/santhosh144awc/openalgo/blob/main/blueprints/python_strategy.py): `blueprints/python_strategy.py`
- [Visual Flow builder](https://github.com/santhosh144awc/openalgo/blob/main/blueprints/flow.py): `blueprints/flow.py`
- [AI trading agent](https://github.com/santhosh144awc/openalgo/blob/main/blueprints/agent.py): `blueprints/agent.py`

### Orders and execution

- [Broker integrations](https://github.com/santhosh144awc/openalgo/tree/main/broker): `broker`
- [Order workflows](https://github.com/santhosh144awc/openalgo/blob/main/blueprints/orders.py): `blueprints/orders.py`
- [Analyzer sandbox](https://github.com/santhosh144awc/openalgo/blob/main/blueprints/analyzer.py): `blueprints/analyzer.py`
- [Sandbox execution engine](https://github.com/santhosh144awc/openalgo/blob/main/sandbox/execution_engine.py): `sandbox/execution_engine.py`
- [WebSocket execution](https://github.com/santhosh144awc/openalgo/blob/main/sandbox/websocket_execution_engine.py): `sandbox/websocket_execution_engine.py`

### Market data and analytics

- [Options analytics suite](https://github.com/santhosh144awc/openalgo/tree/main/blueprints): `blueprints`
- [Market analytics](https://github.com/santhosh144awc/openalgo/tree/main/blueprints): `blueprints`
- [Market data service](https://github.com/santhosh144awc/openalgo/blob/main/services/market_data_service.py): `services/market_data_service.py`
- [Symbol search](https://github.com/santhosh144awc/openalgo/blob/main/services/search_service.py): `services/search_service.py`

### Strategy lifecycle

- [Strategy module engine](https://github.com/santhosh144awc/openalgo/blob/main/services/strategy_module/engine.py): `services/strategy_module/engine.py`
- [Portfolio tools](https://github.com/santhosh144awc/openalgo/blob/main/portfolio/engine.py): `portfolio/engine.py`

### Platform services

- [Flask application](https://github.com/santhosh144awc/openalgo/blob/main/app.py): `app.py`
- [Sandbox state store](https://github.com/santhosh144awc/openalgo/blob/main/database/sandbox_db.py): `database/sandbox_db.py`
- [Strategy state store](https://github.com/santhosh144awc/openalgo/blob/main/database/strategy_module_db.py): `database/strategy_module_db.py`
- [Auth and broker sessions](https://github.com/santhosh144awc/openalgo/blob/main/database/auth_db.py): `database/auth_db.py`

### Other components

- **Trader or client**
- **Broker services**

## Connections

- Trader or client → Flask application: uses platform
- Flask application → Unified broker API: serves API (evidence: `app.py`)
- Flask application → Python strategy host: serves strategy host (evidence: `app.py`)
- Flask application → Visual Flow builder: serves Flow (evidence: `app.py`)
- Flask application → AI trading agent: serves agent (evidence: `app.py`)
- Flask application → Options analytics suite: serves tools (evidence: `app.py`)
- Unified broker API → Order workflows: submits orders
- Python strategy host → Order workflows: uses order workflows
- Visual Flow builder → Order workflows: executes orders
- AI trading agent → Market data service: reads market data
- AI trading agent → Order workflows: requests approved orders
- Unified broker API → Broker integrations: uses normalized API
- Order workflows → Broker integrations: dispatches orders
- Broker integrations → Broker services: calls broker APIs
- Broker integrations → Market data service: streams broker data
- Analyzer sandbox → Sandbox execution engine: tests orders
- Sandbox execution engine → Sandbox state store: reads and writes (evidence: `sandbox/execution_engine.py`)
- Sandbox execution engine → Market data service: fetches quotes (evidence: `sandbox/execution_engine.py`)
- WebSocket execution → Market data service: subscribes to updates (evidence: `sandbox/websocket_execution_engine.py`)
- Options analytics suite → Market data service: uses live broker data
- Market analytics → Market data service: uses market data
- Strategy module engine → Strategy state store: manages strategy state (evidence: `services/strategy_module/engine.py`)
- Strategy module engine → Order workflows: dispatches strategy orders
- Portfolio tools → Broker integrations: uses broker portfolio data
- Flask application → Auth and broker sessions: checks sessions (evidence: `app.py`)
- Symbol search → Auth and broker sessions: checks user context (evidence: `services/search_service.py`)
- Symbol search → Market data service: resolves symbols
