OpenAlgo Architecture
OpenAlgo is a self-hosted Flask application with a React frontend. Everything runs on your machine: the web UI, the REST API, the WebSocket proxy, the strategy host, and the databases. Data is stored on your instance. Broker requests, enabled messaging services and configured AI providers communicate with their respective external services.
This page explains how the pieces fit together. For component-level detail, see the Design Documentation.
The Layered View
Every client speaks the same OpenAlgo API. The service layer holds the business logic, and a broker plugin translates it to whatever the broker actually expects.

The point of the plugin boundary is that your strategy uses shared request and symbol formats across brokers. Exchange coverage, order types and data availability still vary by broker. Symbols, order types, quotes and streams are normalised on the way down, and broker responses are normalised on the way back up.
Processes and Ports
The web application and market-data proxy expose separate listeners. Production uses one Gunicorn worker with eventlet by default, or the optional 64-thread gthread worker. The proxy runs as a supervised child process or an external process in Docker. The development server uses a real thread for the proxy.
Flask application
127.0.0.1:5000
Web UI, REST API v1, webhooks, broker OAuth callbacks
WebSocket proxy
127.0.0.1:8765
Market data streaming and order updates
Hosted Python strategies run in separate subprocesses. This isolates their execution from the HTTP worker, while memory, CPU and other host resources are still shared.
Request Lifecycle: Placing an Order
Whether the signal comes from a TradingView webhook, the Python SDK, an Excel cell, or the built-in terminal, it follows the same path.

Two things in that chain are worth calling out.
Analyzer mode is a real fork in the path. When it is on, the order stops at the sandbox store and never reaches the broker, while market prices still come from live broker data. This is what makes it safe to test a strategy end to end. See API Analyzer.
The event bus is how everything else stays in sync. Order placement publishes an event that the Telegram and WhatsApp subscribers, the logging subscriber, the strategy book, and the WebSocket proxy all listen to independently. Adding a notification channel does not mean touching the order path.
Market Data: One Upstream, Many Consumers
The WebSocket proxy shares the broker feed across consumers. A pool may use several upstream broker connections as symbol capacity requires. Ten strategies watching NIFTY do not open ten broker connections.

Each consumer subscribes to the symbols and mode it wants (LTP, quote, or depth). The proxy handles broker-specific adapter logic, reconnection, and subscription bookkeeping, so consumers see one protocol regardless of broker. See WebSockets.
Code Layout
blueprints/
Flask route modules, one per feature area, registered by feature
restx_api/
The versioned REST API surface and its request schemas
services/
Business logic, shared by the API and the UI
broker/
38 broker plugins, each with its own api/ and mapping/
websocket_proxy/
Streaming server, broker adapters, connection manager
database/
SQLAlchemy models and per-domain data access
sandbox/
Analyzer mode: simulated execution, margin, positions
events/, subscribers/
In-process event bus and its listeners
strategies/, portfolio/, sip/
Strategy hosting, portfolio and SIP backtesting
mcp/
Model Context Protocol server for AI agents
frontend/
React and Vite single page application
utils/
Shared helpers, HTTP connection pooling, constants
The restx_api/ schemas are the contract. They validate every incoming request and reject unknown fields, so a malformed payload fails fast with a clear message rather than reaching a broker.
Data Stores
OpenAlgo splits its data across several SQLite databases so that heavy write paths do not contend with trading data, plus DuckDB for historical bars.
db/openalgo.db
Users, API keys, saved broker keys, pending broker logins, broker auth, symbols, strategies, settings
db/latency.db
Order round-trip timings
db/logs.db
Traffic logs: request metadata, status, duration
db/sandbox.db
Analyzer mode orders, positions, and funds
db/health.db
System health monitoring
DuckDB (Historify)
Historical OHLCV bars, stored columnar for fast range queries
Security Boundaries
Session login
TOTP two-factor, rate-limited login attempts
API requests
API key resolved server-side, never a broker token from the client
Key storage
Argon2 hashing plus a separately encrypted retrieval copy
Browser
CORS policy, CSP headers, CSRF tokens
Throughput
Per-endpoint rate limits, defaulting to 50 requests per second overall and 10 per second for orders
Strategies
Hosted scripts run in isolated processes
Audit
Full request and order audit trail
Broker credentials never reach the client. A strategy holds an OpenAlgo API key, and the server resolves that to the active broker session, so revoking a key does not require touching your broker account. See Security.
Hosting Topologies
Windows and Mac Hosting Architecture

Linux Server Hosting Architecture

A local install is the simplest and keeps everything on your desktop. A server install suits strategies that must run when your desktop does not. A public deployment still requires you to configure TLS, a reverse proxy, firewall rules, secrets, and an update process correctly. See Getting Started.
Related Reading
Design Documentation for the component-by-component breakdown
Place Order Call Flow for the order path in detail
API Documentation for the REST and WebSocket surface
Why to Build with OpenAlgo? for the rationale
Last updated