# marketcalls/openalgo architecture

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

- Interactive diagram: https://gitdiagram.com/marketcalls/openalgo
- Repository: https://github.com/marketcalls/openalgo
- Video tour (about a minute): https://gitdiagram.com/marketcalls/openalgo/video

## Overview

OpenAlgo is a self-hosted algorithmic trading platform spanning broker integrations, strategy authoring, market analysis, and execution. The documented user journey is to connect a broker, submit trades or strategy signals through one of several trading surfaces, optionally validate orders in Analyzer Mode, and execute against the active broker; options tools and real-time streaming provide additional market-data workflows. README statements establish most product-level links below. Source excerpts additionally show sandbox execution and strategy lifecycle behavior; unsampled implementation details are not inferred.

Main entry points: [`services/market_data_service.py`](https://github.com/marketcalls/openalgo/blob/main/services/market_data_service.py) (Market Data Service), [`sandbox/execution_engine.py`](https://github.com/marketcalls/openalgo/blob/main/sandbox/execution_engine.py) (Analyzer Sandbox), [`broker`](https://github.com/marketcalls/openalgo/tree/main/broker) (Broker Plugins), [`blueprints/core.py`](https://github.com/marketcalls/openalgo/blob/main/blueprints/core.py) (Unified Broker API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_surfaces["Trading Surfaces"]
  node_web_app["Web Application<br/>[App.tsx]"]
  node_unified_api["Unified Broker API<br/>[core.py]"]
  node_python_host["Python Strategy Host<br/>[python_strategy.py]"]
  node_flow_builder["Flow Builder<br/>[flow.py]"]
  node_flow_executor["Flow Executor"]
  node_ai_agent["AI Agent<br/>[agent.py]"]
  node_mcp["MCP Interface<br/>[client.py]"]
end

subgraph group_market["Market Data and Analysis"]
  node_options_tools["Options Tools<br/>[strategy_chart.py]"]
  node_analytics["Market Analytics"]
  node_market_data["Market Data Service"]
end

subgraph group_execution["Execution and Brokers"]
  node_analyzer["Analyzer Sandbox"]
  node_sandbox_orders["Sandbox Order Manager<br/>[order_manager.py]"]
  node_broker_plugins["Broker Plugins"]
  node_websocket_proxy["WebSocket Proxy<br/>[server.py]"]
  node_strategy_engine["Strategy Engine<br/>[engine.py]"]
end

subgraph group_platform["Platform Services"]
  node_symbol_store[("Symbol and Token Data")]
  node_sandbox_store[("Sandbox Store<br/>[sandbox_db.py]")]
  node_auth_store[("Auth and Broker Sessions<br/>[auth_db.py]")]
  node_app["Flask Application<br/>[app.py]"]
end

node_trader(("Trader or Client"))

node_trader -->|"uses"| node_web_app
node_trader -->|"submits signals"| node_unified_api
node_trader -->|"hosts strategies"| node_python_host
node_trader -->|"builds strategies"| node_flow_builder
node_trader -->|"requests analysis"| node_ai_agent
node_trader -->|"explores options"| node_options_tools
node_flow_builder -->|"executes flows"| node_flow_executor
node_ai_agent -->|"reads market data"| node_market_data
node_ai_agent -->|"offers MCP"| node_mcp
node_options_tools -->|"streams data"| node_market_data
node_analytics -.->|"uses shared feed"| node_market_data
node_unified_api -->|"routes orders"| node_broker_plugins
node_python_host -->|"executes trades"| node_broker_plugins
node_flow_executor -->|"executes orders"| node_broker_plugins
node_unified_api -->|"tests orders"| node_analyzer
node_python_host -->|"tests orders"| node_analyzer
node_flow_executor -->|"tests orders"| node_analyzer
node_analyzer -->|"manages orders"| node_sandbox_orders
node_sandbox_orders -->|"persists orders"| node_sandbox_store
node_analyzer -->|"fetches quotes"| node_market_data
node_websocket_proxy -->|"distributes feed"| node_market_data
node_market_data -.->|"connects streams"| node_broker_plugins
node_strategy_engine -->|"dispatches orders"| node_broker_plugins
node_unified_api -.->|"resolves symbols"| node_symbol_store
node_app -->|"manages sessions"| node_auth_store
node_app -.->|"serves application"| node_web_app

click node_web_app "https://github.com/marketcalls/openalgo/blob/main/frontend/src/App.tsx"
click node_unified_api "https://github.com/marketcalls/openalgo/blob/main/blueprints/core.py"
click node_python_host "https://github.com/marketcalls/openalgo/blob/main/blueprints/python_strategy.py"
click node_flow_builder "https://github.com/marketcalls/openalgo/blob/main/blueprints/flow.py"
click node_flow_executor "https://github.com/marketcalls/openalgo/blob/main/services/flow_executor_service.py"
click node_ai_agent "https://github.com/marketcalls/openalgo/blob/main/blueprints/agent.py"
click node_mcp "https://github.com/marketcalls/openalgo/blob/main/services/agent/mcp/client.py"
click node_options_tools "https://github.com/marketcalls/openalgo/blob/main/blueprints/strategy_chart.py"
click node_analytics "https://github.com/marketcalls/openalgo/blob/main/services/arbitrage_service.py"
click node_market_data "https://github.com/marketcalls/openalgo/blob/main/services/market_data_service.py"
click node_analyzer "https://github.com/marketcalls/openalgo/blob/main/sandbox/execution_engine.py"
click node_sandbox_orders "https://github.com/marketcalls/openalgo/blob/main/sandbox/order_manager.py"
click node_broker_plugins "https://github.com/marketcalls/openalgo/tree/main/broker"
click node_websocket_proxy "https://github.com/marketcalls/openalgo/blob/main/websocket_proxy/server.py"
click node_strategy_engine "https://github.com/marketcalls/openalgo/blob/main/services/strategy_module/engine.py"
click node_symbol_store "https://github.com/marketcalls/openalgo/blob/main/database/token_db_enhanced.py"
click node_sandbox_store "https://github.com/marketcalls/openalgo/blob/main/database/sandbox_db.py"
click node_auth_store "https://github.com/marketcalls/openalgo/blob/main/database/auth_db.py"
click node_app "https://github.com/marketcalls/openalgo/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_web_app,node_unified_api,node_python_host,node_flow_builder,node_flow_executor,node_ai_agent,node_mcp,node_trader toneBlue
class node_options_tools,node_analytics,node_market_data toneAmber
class node_analyzer,node_sandbox_orders,node_broker_plugins,node_websocket_proxy,node_strategy_engine toneMint
class node_symbol_store,node_sandbox_store,node_auth_store,node_app toneRose
```

## Components

### Trading Surfaces

- [Web Application](https://github.com/marketcalls/openalgo/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Unified Broker API](https://github.com/marketcalls/openalgo/blob/main/blueprints/core.py): `blueprints/core.py`
- [Python Strategy Host](https://github.com/marketcalls/openalgo/blob/main/blueprints/python_strategy.py): `blueprints/python_strategy.py`
- [Flow Builder](https://github.com/marketcalls/openalgo/blob/main/blueprints/flow.py): `blueprints/flow.py`
- [Flow Executor](https://github.com/marketcalls/openalgo/blob/main/services/flow_executor_service.py): `services/flow_executor_service.py`
- [AI Agent](https://github.com/marketcalls/openalgo/blob/main/blueprints/agent.py): `blueprints/agent.py`
- [MCP Interface](https://github.com/marketcalls/openalgo/blob/main/services/agent/mcp/client.py): `services/agent/mcp/client.py`

### Market Data and Analysis

- [Options Tools](https://github.com/marketcalls/openalgo/blob/main/blueprints/strategy_chart.py): `blueprints/strategy_chart.py`
- [Market Analytics](https://github.com/marketcalls/openalgo/blob/main/services/arbitrage_service.py): `services/arbitrage_service.py`
- [Market Data Service](https://github.com/marketcalls/openalgo/blob/main/services/market_data_service.py): `services/market_data_service.py`

### Execution and Brokers

- [Analyzer Sandbox](https://github.com/marketcalls/openalgo/blob/main/sandbox/execution_engine.py): `sandbox/execution_engine.py`
- [Sandbox Order Manager](https://github.com/marketcalls/openalgo/blob/main/sandbox/order_manager.py): `sandbox/order_manager.py`
- [Broker Plugins](https://github.com/marketcalls/openalgo/tree/main/broker): `broker`
- [WebSocket Proxy](https://github.com/marketcalls/openalgo/blob/main/websocket_proxy/server.py): `websocket_proxy/server.py`
- [Strategy Engine](https://github.com/marketcalls/openalgo/blob/main/services/strategy_module/engine.py): `services/strategy_module/engine.py`

### Platform Services

- [Symbol and Token Data](https://github.com/marketcalls/openalgo/blob/main/database/token_db_enhanced.py): `database/token_db_enhanced.py`
- [Sandbox Store](https://github.com/marketcalls/openalgo/blob/main/database/sandbox_db.py): `database/sandbox_db.py`
- [Auth and Broker Sessions](https://github.com/marketcalls/openalgo/blob/main/database/auth_db.py): `database/auth_db.py`
- [Flask Application](https://github.com/marketcalls/openalgo/blob/main/app.py): `app.py`

### Other components

- **Trader or Client**

## Connections

- Trader or Client → Web Application: uses (evidence: `README.md`)
- Trader or Client → Unified Broker API: submits signals (evidence: `README.md`)
- Trader or Client → Python Strategy Host: hosts strategies (evidence: `README.md`)
- Trader or Client → Flow Builder: builds strategies (evidence: `README.md`)
- Trader or Client → AI Agent: requests analysis (evidence: `README.md`)
- Trader or Client → Options Tools: explores options (evidence: `README.md`)
- Flow Builder → Flow Executor: executes flows (evidence: `README.md`)
- AI Agent → Market Data Service: reads market data (evidence: `README.md`)
- AI Agent → MCP Interface: offers MCP (evidence: `README.md`)
- Options Tools → Market Data Service: streams data (evidence: `README.md`)
- Market Analytics → Market Data Service: uses shared feed
- Unified Broker API → Broker Plugins: routes orders (evidence: `README.md`)
- Python Strategy Host → Broker Plugins: executes trades (evidence: `README.md`)
- Flow Executor → Broker Plugins: executes orders (evidence: `README.md`)
- Unified Broker API → Analyzer Sandbox: tests orders (evidence: `README.md`)
- Python Strategy Host → Analyzer Sandbox: tests orders (evidence: `README.md`)
- Flow Executor → Analyzer Sandbox: tests orders (evidence: `README.md`)
- Analyzer Sandbox → Sandbox Order Manager: manages orders (evidence: `sandbox/execution_engine.py`)
- Sandbox Order Manager → Sandbox Store: persists orders (evidence: `sandbox/order_manager.py`)
- Analyzer Sandbox → Market Data Service: fetches quotes (evidence: `sandbox/execution_engine.py`)
- WebSocket Proxy → Market Data Service: distributes feed (evidence: `websocket_proxy/server.py`)
- Market Data Service → Broker Plugins: connects streams
- Strategy Engine → Broker Plugins: dispatches orders (evidence: `services/strategy_module/engine.py`)
- Unified Broker API → Symbol and Token Data: resolves symbols
- Flask Application → Auth and Broker Sessions: manages sessions (evidence: `app.py`)
- Flask Application → Web Application: serves application
