Architecture
System Overview
Section titled “System Overview”┌─────────────────────────────────────────────────┐│ Frontend (React + Mantine UI) ││ Dashboard, Charts, Strategy Builder ││ Port 8500 │└────────────────────────┬────────────────────────┘ │ REST API┌────────────────────────▼────────────────────────┐│ FastAPI Backend ││ Strategies, Backtests, Data Collection ││ Port 8501 │└──────────┬─────────────────────────┬────────────┘ │ │┌──────────▼──────────┐ ┌────────▼─────────────┐│ TimescaleDB │ │ Data Providers ││ Time-series DB │ │ Polygon, yfinance ││ Port 8502 │ │ Alpha Vantage │└─────────────────────┘ └──────────────────────┘Components
Section titled “Components”Frontend
Section titled “Frontend”Stack: React, TypeScript, Mantine UI, TanStack Query
Responsibilities:
- User interface
- Chart rendering (Lightweight Charts)
- State management
- API communication
Backend API
Section titled “Backend API”Stack: FastAPI, Python 3.11+, Pydantic v2
Responsibilities:
- REST API endpoints
- Strategy execution
- Backtesting engine
- Data collection orchestration
Database
Section titled “Database”Stack: TimescaleDB (PostgreSQL + time-series extension)
Features:
- Optimized for OHLCV data
- Automatic partitioning
- Compression for old data
- Fast time-range queries
Data Flow
Section titled “Data Flow”Data Collection
Section titled “Data Collection”Data Provider → Backend → TimescaleDBBacktesting
Section titled “Backtesting”Frontend → API Request → Load Data → Execute Strategy → Return ResultsStrategy Creation
Section titled “Strategy Creation”Frontend (Rule Builder) → API → Store in DB → Available for BacktestsDatabase Schema
Section titled “Database Schema”Key Tables
Section titled “Key Tables”| Table | Description |
|---|---|
tickers | Tracked symbols |
ohlcv_data | Price/volume data |
strategies | Strategy definitions |
backtests | Backtest results |
trades | Individual trades |
tasks | Background jobs |
Performance Considerations
Section titled “Performance Considerations”Database
Section titled “Database”- Hypertables for time-series data
- Indexes on (symbol, time, interval)
- Data retention policies
- Async endpoints
- Connection pooling
- Response caching
Frontend
Section titled “Frontend”- React Query caching
- Virtualized lists
- Lazy loading
Next Steps
Section titled “Next Steps”- Installation - Set up the system
- API Reference - Integration details