00 - Directory Structure

Overview

OpenAlgo follows a modular architecture with clear separation of concerns. This document provides a comprehensive map of the project structure to help developers navigate the codebase effectively.

Root Directory

openalgo/
├── app.py                    # Flask application entry point
├── extensions.py             # Flask extensions (SocketIO, CORS)
├── cors.py                   # CORS configuration
├── csp.py                    # Content Security Policy
├── limiter.py                # Rate limiting setup
├── utils.py                  # Legacy utilities

├── .env                      # Environment configuration (not in git)
├── .sample.env               # Environment template
├── pyproject.toml            # Python dependencies (uv)
├── requirements.txt          # Pip fallback dependencies
├── uv.lock                   # Locked dependency versions

├── CLAUDE.md                 # AI assistant instructions
├── README.md                 # Project overview
├── CONTRIBUTING.md           # Contribution guidelines
├── SECURITY.md               # Security policy
├── License.md                # AGPL-3.0 license

├── Dockerfile                # Container build
├── docker-compose.yaml       # Multi-container setup
├── start.sh                  # Production startup script

├── blueprints/               # Flask route handlers
├── restx_api/                # REST API endpoints
├── services/                 # Business logic layer
├── database/                 # Database models & utilities
├── broker/                   # Broker integrations (29 brokers)
├── utils/                    # Shared utilities
├── websocket_proxy/          # Real-time data server
├── sandbox/                  # Sandbox trading engine
├── frontend/                 # React 19 SPA
├── docs/                     # Documentation
├── test/                     # Test suites
└── db/                       # SQLite database files

Core Backend Modules

/blueprints/ - Flask Route Handlers

UI routes and webhook handlers organized by feature.

/restx_api/ - REST API Endpoints

Flask-RESTX namespaces for /api/v1/ routes with Swagger documentation.

/services/ - Business Logic Layer

Core business logic separated from routes.

/database/ - Database Models & Utilities

SQLAlchemy models and database operations.

/utils/ - Shared Utilities

Common utilities used across the application.

Broker Integration

/broker/ - Broker Plugins

Each broker follows a standardized structure.

Broker Module Structure

Each broker implements the same interface:

Real-Time Infrastructure

/websocket_proxy/ - WebSocket Server

Unified market data streaming server.

/sandbox/ - Sandbox Trading Engine

Virtual trading environment for testing.

Frontend

/frontend/ - React 19 SPA

Modern single-page application.

Data & Storage

/db/ - Database Files

Documentation

/docs/ - Documentation

Testing

/test/ - Test Suites

Additional Directories

Directory
Purpose

/collections/

Postman/Bruno API collections

/examples/

Example integrations and scripts

/strategies/

Strategy templates

/playground/

API playground resources

/mcp/

Model Context Protocol configs

/upgrade/

Database migration scripts

/install/

Installation helpers

/scripts/

Utility scripts

/download/

Downloaded resources

/data/

Data files

/keys/

SSL certificates (not in git)

/logs/

Application logs (not in git)

/tmp/

Temporary files (not in git)

Key File Reference

File
Purpose

app.py

Main Flask entry point, registers all blueprints

extensions.py

SocketIO, CORS initialization

frontend/src/App.tsx

React router configuration

restx_api/__init__.py

REST API namespace registry

broker/*/plugin.json

Broker plugin metadata

websocket_proxy/server.py

WebSocket server entry

sandbox/execution_engine.py

Sandbox order execution

database/auth_db.py

Core authentication models

services/place_order_service.py

Order placement logic

  1. Finding a feature: Start in /blueprints/ for UI routes or /restx_api/ for API endpoints

  2. Business logic: Look in /services/ for the corresponding service

  3. Database operations: Check /database/ for models and queries

  4. Broker-specific code: Navigate to /broker/{broker_name}/

  5. Frontend components: Explore /frontend/src/components/ and /frontend/src/pages/

  6. Real-time features: See /websocket_proxy/ for market data streaming

  7. Sandbox mode: Check /sandbox/ for virtual trading logic

Last updated