# manojk3535/openalgo architecture

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

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

## Overview

OpenAlgo is a self-hosted algorithmic trading platform. Traders connect a broker, then submit orders through the unified API, hosted Python strategies, or visual Flow; Analyzer Mode can test workflows before live execution. Separate options analytics and real-time streaming support market analysis, while sandbox execution, portfolio/SIP backtesting, and operational tools provide additional capabilities. The README documents these product surfaces, and the excerpts show app registration, Flow service dependencies, broker-streaming management, and sandbox execution. Many route implementations and shared services were not sampled, so those links are omitted or marked unverified.

Main entry points: [`frontend/src/App.tsx`](https://github.com/manojk3535/openalgo/blob/main/frontend/src/App.tsx) (Trading UI), [`broker`](https://github.com/manojk3535/openalgo/tree/main/broker) (Broker plugins), [`websocket_proxy/server.py`](https://github.com/manojk3535/openalgo/blob/main/websocket_proxy/server.py) (WebSocket proxy), [`app.py`](https://github.com/manojk3535/openalgo/blob/main/app.py) (Flask application)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["User interfaces"]
  node_webui["Trading UI<br/>[App.tsx]"]
  node_rest["Unified API routes<br/>[orders.py]"]
  node_flowui["Flow builder<br/>[flow.py]"]
end

subgraph group_execution["Strategy execution"]
  node_pyhost["Python strategy host<br/>[python_strategy.py]"]
  node_flowexec["Flow executor"]
  node_analyzer["Analyzer mode<br/>[analyzer.py]"]
end

subgraph group_market["Market and brokers"]
  node_brokers["Broker plugins"]
  node_wsproxy["WebSocket proxy<br/>[server.py]"]
  node_connpool["Connection pooling"]
  node_marketdata["Market data service"]
end

subgraph group_analytics["Analysis and simulation"]
  node_options["Options analytics"]
  node_arbitrage["Arbitrage scanner<br/>[arbitrage.py]"]
  node_portfolio["Portfolio backtest<br/>[engine.py]"]
  node_sip["SIP simulation<br/>[engine.py]"]
  node_sandbox["Sandbox execution"]
  node_orders["Sandbox order manager<br/>[order_manager.py]"]
end

subgraph group_platform["Platform services"]
  node_sandboxdb[("Sandbox database<br/>[sandbox_db.py]")]
  node_auth[("Authentication and sessions<br/>[auth_db.py]")]
  node_app["Flask application<br/>[app.py]"]
  node_mcp["MCP interfaces<br/>[mcp_http.py]"]
end

node_trader(("Trader or client"))

node_trader -->|"uses"| node_webui
node_trader -->|"submits orders"| node_rest
node_trader -->|"builds strategies"| node_flowui
node_webui -.->|"hosts scripts"| node_pyhost
node_flowui -->|"executes flows"| node_flowexec
node_rest -->|"tests orders"| node_analyzer
node_pyhost -->|"tests orders"| node_analyzer
node_flowexec -->|"tests orders"| node_analyzer
node_rest -.->|"executes via"| node_brokers
node_pyhost -.->|"trades via"| node_brokers
node_flowexec -.->|"trades via"| node_brokers
node_webui -->|"views tools"| node_options
node_options -->|"reads broker data"| node_brokers
node_webui -->|"opens backtest"| node_portfolio
node_webui -->|"opens simulator"| node_sip
node_webui -->|"opens scanner"| node_arbitrage
node_wsproxy -->|"uses pooling"| node_connpool
node_wsproxy -->|"dispatches feeds"| node_brokers
node_wsproxy -->|"uses market data"| node_marketdata
node_sandbox -.->|"executes orders"| node_orders
node_orders -->|"writes orders"| node_sandboxdb
node_orders -->|"uses execution engine"| node_sandbox
node_app -->|"checks sessions"| node_auth
node_app -->|"registers routes"| node_mcp
node_app -->|"serves frontend"| node_webui

click node_webui "https://github.com/manojk3535/openalgo/blob/main/frontend/src/App.tsx"
click node_rest "https://github.com/manojk3535/openalgo/blob/main/blueprints/orders.py"
click node_flowui "https://github.com/manojk3535/openalgo/blob/main/blueprints/flow.py"
click node_pyhost "https://github.com/manojk3535/openalgo/blob/main/blueprints/python_strategy.py"
click node_flowexec "https://github.com/manojk3535/openalgo/blob/main/services/flow_executor_service.py"
click node_analyzer "https://github.com/manojk3535/openalgo/blob/main/blueprints/analyzer.py"
click node_brokers "https://github.com/manojk3535/openalgo/tree/main/broker"
click node_wsproxy "https://github.com/manojk3535/openalgo/blob/main/websocket_proxy/server.py"
click node_connpool "https://github.com/manojk3535/openalgo/blob/main/websocket_proxy/connection_manager.py"
click node_marketdata "https://github.com/manojk3535/openalgo/blob/main/services/market_data_service.py"
click node_options "https://github.com/manojk3535/openalgo/tree/main/blueprints"
click node_arbitrage "https://github.com/manojk3535/openalgo/blob/main/blueprints/arbitrage.py"
click node_portfolio "https://github.com/manojk3535/openalgo/blob/main/portfolio/engine.py"
click node_sip "https://github.com/manojk3535/openalgo/blob/main/sip/engine.py"
click node_sandbox "https://github.com/manojk3535/openalgo/blob/main/sandbox/execution_engine.py"
click node_orders "https://github.com/manojk3535/openalgo/blob/main/sandbox/order_manager.py"
click node_sandboxdb "https://github.com/manojk3535/openalgo/blob/main/database/sandbox_db.py"
click node_auth "https://github.com/manojk3535/openalgo/blob/main/database/auth_db.py"
click node_app "https://github.com/manojk3535/openalgo/blob/main/app.py"
click node_mcp "https://github.com/manojk3535/openalgo/blob/main/blueprints/mcp_http.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_webui,node_rest,node_flowui,node_trader toneBlue
class node_pyhost,node_flowexec,node_analyzer toneAmber
class node_brokers,node_wsproxy,node_connpool,node_marketdata toneMint
class node_options,node_arbitrage,node_portfolio,node_sip,node_sandbox,node_orders toneRose
class node_sandboxdb,node_auth,node_app,node_mcp toneIndigo
```

## Components

### User interfaces

- [Trading UI](https://github.com/manojk3535/openalgo/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Unified API routes](https://github.com/manojk3535/openalgo/blob/main/blueprints/orders.py): `blueprints/orders.py`
- [Flow builder](https://github.com/manojk3535/openalgo/blob/main/blueprints/flow.py): `blueprints/flow.py`

### Strategy execution

- [Python strategy host](https://github.com/manojk3535/openalgo/blob/main/blueprints/python_strategy.py): `blueprints/python_strategy.py`
- [Flow executor](https://github.com/manojk3535/openalgo/blob/main/services/flow_executor_service.py): `services/flow_executor_service.py`
- [Analyzer mode](https://github.com/manojk3535/openalgo/blob/main/blueprints/analyzer.py): `blueprints/analyzer.py`

### Market and brokers

- [Broker plugins](https://github.com/manojk3535/openalgo/tree/main/broker): `broker`
- [WebSocket proxy](https://github.com/manojk3535/openalgo/blob/main/websocket_proxy/server.py): `websocket_proxy/server.py`
- [Connection pooling](https://github.com/manojk3535/openalgo/blob/main/websocket_proxy/connection_manager.py): `websocket_proxy/connection_manager.py`
- [Market data service](https://github.com/manojk3535/openalgo/blob/main/services/market_data_service.py): `services/market_data_service.py`

### Analysis and simulation

- [Options analytics](https://github.com/manojk3535/openalgo/tree/main/blueprints): `blueprints`
- [Arbitrage scanner](https://github.com/manojk3535/openalgo/blob/main/blueprints/arbitrage.py): `blueprints/arbitrage.py`
- [Portfolio backtest](https://github.com/manojk3535/openalgo/blob/main/portfolio/engine.py): `portfolio/engine.py`
- [SIP simulation](https://github.com/manojk3535/openalgo/blob/main/sip/engine.py): `sip/engine.py`
- [Sandbox execution](https://github.com/manojk3535/openalgo/blob/main/sandbox/execution_engine.py): `sandbox/execution_engine.py`
- [Sandbox order manager](https://github.com/manojk3535/openalgo/blob/main/sandbox/order_manager.py): `sandbox/order_manager.py`

### Platform services

- [Sandbox database](https://github.com/manojk3535/openalgo/blob/main/database/sandbox_db.py): `database/sandbox_db.py`
- [Authentication and sessions](https://github.com/manojk3535/openalgo/blob/main/database/auth_db.py): `database/auth_db.py`
- [Flask application](https://github.com/manojk3535/openalgo/blob/main/app.py): `app.py`
- [MCP interfaces](https://github.com/manojk3535/openalgo/blob/main/blueprints/mcp_http.py): `blueprints/mcp_http.py`

### Other components

- **Trader or client**

## Connections

- Trader or client → Trading UI: uses
- Trader or client → Unified API routes: submits orders
- Trader or client → Flow builder: builds strategies
- Trading UI → Python strategy host: hosts scripts
- Flow builder → Flow executor: executes flows
- Unified API routes → Analyzer mode: tests orders
- Python strategy host → Analyzer mode: tests orders
- Flow executor → Analyzer mode: tests orders
- Unified API routes → Broker plugins: executes via
- Python strategy host → Broker plugins: trades via
- Flow executor → Broker plugins: trades via
- Trading UI → Options analytics: views tools
- Options analytics → Broker plugins: reads broker data
- Trading UI → Portfolio backtest: opens backtest (evidence: `frontend/src/App.tsx`)
- Trading UI → SIP simulation: opens simulator (evidence: `frontend/src/App.tsx`)
- Trading UI → Arbitrage scanner: opens scanner (evidence: `blueprints/arbitrage.py`)
- WebSocket proxy → Connection pooling: uses pooling (evidence: `websocket_proxy/server.py`)
- WebSocket proxy → Broker plugins: dispatches feeds (evidence: `websocket_proxy/server.py`)
- WebSocket proxy → Market data service: uses market data (evidence: `websocket_proxy/server.py`)
- Sandbox execution → Sandbox order manager: executes orders (evidence: `sandbox/order_manager.py`)
- Sandbox order manager → Sandbox database: writes orders (evidence: `sandbox/order_manager.py`)
- Sandbox order manager → Sandbox execution: uses execution engine (evidence: `sandbox/order_manager.py`)
- Flask application → Authentication and sessions: checks sessions (evidence: `app.py`)
- Flask application → MCP interfaces: registers routes (evidence: `app.py`)
- Flask application → Trading UI: serves frontend (evidence: `app.py`)
