Overview
High-level introduction, core capabilities, architecture, and tech stack of the DepthSight platform.
DepthSight is an enterprise-grade, open-source platform for algorithmic cryptocurrency trading — packaged as a complete SaaS-in-a-box. It provides every layer you need to launch a multi-user trading platform (similar to 3Commas or Veles) out of the box: a drag-and-drop strategy builder, an AI-powered co-pilot, a dual backtesting engine, dynamic risk management, multi-exchange execution, real-time dashboards, and a mobile PWA — all wired together through a distributed architecture of containerized services.

The visual strategy builder in action — describe your idea in plain language and AI assembles a complete multi-stage trading strategy.
What DepthSight Does
At its core, DepthSight automates the full lifecycle of crypto trading: analyze market data → evaluate strategy conditions → manage risk → execute orders → log and report. What distinguishes it from a simple trading bot framework is its multi-tenant architecture — every component is designed so that hundreds of users can run independent strategies on isolated accounts, all sharing the same infrastructure. The platform enforces per-user quotas, plan-based permissions, and fully separated execution environments, making it production-ready for commercial SaaS deployments.
The platform currently targets cryptocurrency markets with native support for Binance and Bybit (fully tested and stable), with Bitget, OKX, Gate.io, and BingX in active development. All exchange communication flows through CCXT-based executors behind a unified abstraction, so adding new exchanges requires implementing a single adapter rather than rewriting trading logic.
Core Capabilities at a Glance
| Capability | Description | Key Module |
|---|---|---|
| Visual Strategy Builder | Drag-and-drop node graph with 40+ logic blocks; cross-referencing nodes for dynamic stop-loss placement | frontend/src/components/strategy-editor/ |
| AI Co-Pilot | Generate strategies from text prompts or chart screenshots; analyze live trades and backtests | api/ai_assistant.py |
| Weighted Foundations | Probability-based entry system — trades execute only when weighted condition confidence exceeds a threshold | bot_module/strategy.py |
| Dynamic Risk Management | Adaptive position sizing and risk parameters that respond per-pair to real-time performance | bot_module/risk_manager.py |
| Dual Backtesting | Fast vector engine for prototyping + candle/tick-level engine for precise execution simulation | bot_module/fast_vector_backtester.py, bot_module/depthsight_backtester.py |
| Genetic Optimization | Evolve strategy parameters through genetic algorithms with a dynamic gene pool | bot_module/genetic_strategy_finder.py |
| ML Pipeline | Online learning (River) + batch models (scikit-learn, XGBoost, LightGBM) for signal confirmation | bot_module/model_pipeline.py, bot_module/ml_strategy.py |
| Discovery Hub | Community repository for sharing strategy templates, trading ideas with KPIs, and federated node topology | api/hub_router.py |
| Trade Mining | Earn $DEPTH by submitting anonymous trade telemetry — verified trades mint daily token rewards with referrals, welcome bonuses and halving | api/hub_router.py, bot_module/controller.py, tasks.py |
| Multi-Tenant SaaS | JWT auth, Redis quotas, plan-based permissions, isolated execution per user account | api/security.py, api/quota_manager.py |
System Architecture
DepthSight is a distributed system of 8 containerized services orchestrated by Docker Compose, communicating through Redis (messaging, state, fan-out) and PostgreSQL (persistence). The following diagram illustrates the high-level component topology and data flows:
The architecture follows a fan-out consumption pattern for market data: the Market Data Service maintains a single WebSocket connection per exchange stream, then replicates data to all interested bot workers through Redis Pub/Sub. This means 100 users trading BTCUSDT share one upstream connection rather than opening 100 separate streams — a critical efficiency for scaling.
Service Map and Ports
Every service runs in its own Docker container with isolated Redis ACL credentials. The following table summarizes the service topology:
| Service | Default Port | Role | Key Technology |
|---|---|---|---|
| PostgreSQL | 5432 | Persistent storage (users, strategies, trades, backtests) | PostgreSQL 15 Alpine |
| Redis | internal | Cache, state, Pub/Sub, Celery broker, command bus | Redis 7.2 Alpine |
| Redis Market | internal | High-throughput HFT market data fan-out (no persistence) | Redis 7.2 Alpine |
| API | 8000 | REST API, auth, strategy CRUD, admin | FastAPI + Uvicorn |
| WebSocket | 8765 | Real-time event streaming to frontends | Uvicorn + Gunicorn |
| Frontend | 5173 | Web dashboard | React + Vite + shadcn/ui |
| PWA | 5174 | Mobile-optimized client | React + Vite |
| Bot | n/a | Trading engine runtime | Python async |
| Market Data | n/a | Central exchange stream ingestion + fan-out | Python async + aiohttp |
| Celery Worker | n/a | Background jobs (backtests, genetic opt, analytics) | Celery 5.5 + prefork |
[!TIP] Redis is never exposed on the host — each container authenticates with its own ACL user (
api,websocket,bot,celery,market_data), enforcing least-privilege access at the data layer.
Data and Control Flow Summary
Understanding how data moves through DepthSight is essential for working with the codebase. There are six primary flow paths:
| Flow | Path | Purpose |
|---|---|---|
| Configuration | Frontend → REST API → PostgreSQL | User saves strategy settings, API keys, preferences |
| Control | Frontend → REST API → Redis Command Bus → Bot Runner → TradingController | Start/stop strategies, modify positions |
| Market Data | Exchange WS → Market Data Service → Redis Fan-out → Bot (DataConsumer) | Real-time klines, order books, trades |
| Execution | Processed Data → Controller → Strategy → RiskManager → Executor → Exchange API | Signal generation through order placement |
| Observation | Bot → Redis Pub/Sub → WebSocket Server → Frontend Dashboard | Live logs, position updates, signal alerts |
| Analytics | Bot → PostgreSQL → Celery Task → Analytics → PostgreSQL | Post-trade analytics, backtest results |
The Control Flow is particularly important: the API never directly calls the trading engine. Instead, it publishes commands to Redis channels, and the bot runner polls those channels asynchronously. This decoupling means the API can restart without disrupting active trades.
Project Structure
The repository is organized into clearly separated domains. Here is a visual map of the top-level layout with the purpose of each directory:
DepthSight/
├── api/ │ ├── routes/ # Modular route files (auth, strategies, backtests, admin, ...)
│ ├── depthsight_api.py # Main FastAPI application entry point
│ ├── models.py # SQLAlchemy database models
│ ├── schemas.py # Pydantic request/response schemas
│ ├── security.py # JWT, password hashing, encryption
│ ├── crud.py # Database CRUD operations
│ └── ...
├── bot_module/ # Trading engine — strategies, execution, backtesting
│ ├── controller.py # TradingController — the heartbeat of live trading
│ ├── strategy.py # Strategy framework + built-in strategy definitions
│ ├── fast_vector_backtester.py # High-speed vector backtester
│ ├── depthsight_backtester.py # Candle/tick-level simulation backtester
│ ├── risk_manager.py # Dynamic risk management engine
│ ├── executor.py # Exchange order execution (CCXT)
│ ├── genetic_strategy_finder.py # Genetic optimization
│ ├── model_pipeline.py # ML inference pipeline
│ └── exchanges/ # Exchange-specific adapters
├── frontend/ # React web dashboard (Vite + shadcn/ui + Tailwind)
│ └── src/
│ ├── components/ # UI components (strategy-editor, analytics, positions, ...)
│ ├── pages/ # Route pages (Strategies, Analytics, CommunityHub, ...)
│ └── context/ # React contexts (Auth, WebSocket, Theme, ...)
├── pwa/ # Mobile-optimized Progressive Web App
│ └── src/ # Screens, components, i18n locales (en/ru)
├── tests/ # Comprehensive test suite (100+ test files)
├── alembic/ # Database migration scripts
├── scripts/ # Utility scripts (data pipeline, diagnostics)
├── docs/ # Public documentation and assets
├── market_data_service.py # Centralized market data fan-out service
├── bot_runner.py # Multi-user bot process entry point
├── tasks.py # Celery task definitions
├── docker-compose.yml # Service orchestration
└── requirements.txt # Python dependencies
The largest code concentrations are bot_module/strategy.py (~12,700 LOC) containing the full strategy framework and condition system, and bot_module/controller.py (~13,800 LOC) orchestrating the trading lifecycle. The frontend strategy editor (frontend/src/components/strategy-editor/) implements the drag-and-drop visual builder.
Technology Stack
DepthSight's stack is deliberately chosen for real-time performance, observability, and production reliability:
| Layer | Technology | Rationale |
|---|---|---|
| Backend API | FastAPI + Uvicorn + Gunicorn | Async-first, automatic OpenAPI docs, high throughput |
| Trading Engine | Python 3.11+ asyncio | Native async I/O for concurrent exchange operations |
| Database | PostgreSQL 15 + SQLAlchemy + Alembic | ACID compliance, migrations, relational integrity |
| Cache / Messaging | Redis 7.2 (2 instances) | Pub/Sub for real-time events; separate instance for HFT data |
| Task Queue | Celery 5.5 + prefork | CPU-bound backtests and genetic optimization off the main loop |
| ML / AI | River, scikit-learn, XGBoost, LightGBM, Google Gemini | Online learning + batch inference + LLM co-pilot |
| Frontend | React 19 + Vite + shadcn/ui + Tailwind CSS | Component-driven UI with drag-and-drop (dnd-kit) |
| Mobile | React 19 + Vite PWA | Installable, offline-capable mobile experience |
| Exchange | CCXT 4.4 | Unified API across 6+ exchanges |
| Optimization | DEAP (genetic) + Optuna (Bayesian) + Numba (JIT) | Multi-strategy parameter search with compiled hot paths |
| Infrastructure | Docker Compose + Caddy | One-click deploy with auto-SSL, PgBouncer-ready |
Two separate Redis instances are intentional: the primary Redis handles persistent state (JWT sessions, rate limits, Celery broker), while redis-market is a volatile, no-persistence instance dedicated to high-frequency market data fan-out — preventing HFT data volume from evicting critical system state.
Deployment Model
DepthSight ships with a one-click deployment model designed for Ubuntu 22.04+ servers with a minimum of 6 CPU cores and 16 GB RAM. A single shell script handles everything: Docker installation, secret generation, firewall configuration, and service startup:
curl -sL "https://raw.githubusercontent.com/DepthSight-Pro/DepthSight/main/deploy.sh" | sudo bash
The platform also supports a secure container-to-host auto-update mechanism: clicking "Update" in the admin UI writes a trigger file to a shared volume, which a host-side cron job detects and executes — enabling zero-downtime updates without granting root privileges to the container.
For local development, the standard Docker Compose workflow applies:
cp .env.example .env # Replace all change_me_* secrets!
docker compose up -d --build
After startup, the interactive API documentation is available at http://localhost:8000/docs, the web dashboard at http://localhost:5173, and the PWA at http://localhost:5174.
Where to Go Next
Now that you have a high-level understanding of DepthSight's purpose and architecture, here is a recommended reading path through the documentation:
- Quick Start — Get a local instance running and place your first paper trade.
- Architecture Overview — Deep dive into how the 8 services communicate and scale.
Then explore based on your interest:
| If you want to understand... | Read |
|---|---|
| How strategies generate signals | Strategy and Signal System |
| The lifecycle of a trade from signal to execution | Trading Controller Lifecycle |
| Adaptive risk management mechanics | Dynamic Risk Management |
| Fast prototyping vs. precise simulation | Dual Backtesting Engines |
| Evolving strategies with genetic algorithms | Genetic Strategy Optimization |
| How market data flows from exchanges to bots | Centralized Market Data Service → Redis Fan-Out and Data Consumer |
| REST API design and route organization | FastAPI REST Routes |
| Multi-tenant auth, quotas, and billing | Multi-Tenant Auth and Quotas |
| Real-time event streaming architecture | WebSocket Real-Time Events |
| AI strategy generation and trade analysis | AI Co-Pilot Assistant |
| ML models, Compass strategy, online learning | ML Pipeline and Compass Strategy |
| Visual strategy builder and dashboard UI | React Dashboard and Strategy Editor |
| Mobile trading experience | Mobile PWA Client |