Sravz Platform - Detailed Architecture
System Architecture Overview
The Sravz platform is built with a multi-backend, multi-language architecture designed to handle both realtime financial data streaming and historical analytics.

High-Level Data Flow
Realtime Pipeline:
- Interactive Brokers → C++ WebSocket Server → Redis Cache → Angular Dashboard
- Low-latency quote updates via WebSocket connections
Historical Analysis Pipeline:
- Economic Calendar + Historical Data → Airflow Orchestration → Dask Distribution → Python Analytics Engine
- Batch processing for statistical and ML-based analysis
Core Architecture Components
System Layers
| Layer | Component | Technology | Purpose |
|---|---|---|---|
| Frontend | Angular Dashboard | TypeScript/Angular | Real-time trading interface |
| API | REST Gateway | Go/Gorilla Mux | HTTP request handling |
| Realtime | WebSocket Server | C++/Boost ASIO | Low-latency streaming |
| Realtime | Ticker Plant | Rust/Tokio | Quote processing |
| Batch | Orchestration | Apache Airflow | DAG scheduling |
| Batch | Distribution | Dask | Distributed processing |
| Analytics | Analysis Engine | Python/Pandas | Statistical computing |
Data Storage Layer
| Store | Technology | Use Case | Scale |
|---|---|---|---|
| Cache | Redis | Real-time quotes | Sub-millisecond |
| Documents | MongoDB | User configs, portfolios | 100GB+ |
| Relational | MySQL | Transactional data | 50GB+ |
| Data Lake | AWS S3 | Historical OHLCV | 1TB+ |
| Analytics | DuckDB | Query engine | 500GB+ working set |
Data Flow Architecture
Realtime Path (WebSocket):
Interactive Brokers (Stock/Crypto) → C++ WebSocket Server
→ Redis Cache → Angular Dashboard (live quotes)
Historical Path (Batch):
Economic Calendar / Historical Data → Airflow Orchestration
→ Dask Task Scheduler → Python Analytics Engine
→ MongoDB (results) + S3 (archive)
Deployment Infrastructure
- Container Orchestration: Docker Swarm
- Load Balancing: Traefik (reverse proxy)
- Infrastructure:
- Contabo (Primary swarm cluster)
- Hetzner (Backup/HA swarm cluster)
- Images: AWS ECR (private registry)
Technology Stack by Layer
Frontend Layer
- Angular (frontend-ng): Dynamic SPA with real-time updates
- Hugo + WordPress: Static documentation and content management
Backend Services
| Service | Language | Purpose | Capabilities |
|---|---|---|---|
| REST API | Go (Gorilla Mux) | Primary API gateway, data retrieval | CRUD operations, historical lookups |
| WebSocket Server | C++ (Boost ASIO) | Real-time quote streaming | Multi-threaded, low-latency |
| Ticker Plant | Rust (Tokio) | Quote processing & storage | NSQ consumer, DataFrame analytics |
| Analytics Engine | Python (Pandas/NumPy) | Statistical & ML analysis | PCA, forecasting, risk models |
| Authentication | Node.js | OAuth, JWT, session management | SSO integration |
| Analytics DB | kdb+ (Q) | Time-series data warehouse | Lightning-fast queries on OHLCV |
Detailed Technical Architecture
Microservices & Data Flow - Complete System Diagram
The architecture follows a multi-tier, loosely-coupled microservices pattern with clear separation of concerns.

Architecture Flow: External Data Sources → API Gateway → Processing Services → Data Storage → Frontend
Architecture Layers:
External Data Sources
- Interactive Brokers (REST API + WebSocket for stock/crypto/forex data)
- Economic Calendar (Macro events and indicators)
- Crypto Exchanges (Digital asset data)
Frontend Tier
- Angular Dashboard (frontend-ng): Real-time trading interface with Material UI
- Documentation: Hugo + WordPress static sites
API Gateway & Routing
- Traefik: Reverse proxy with SSL/TLS, load balancing, service routing
- Directs requests to appropriate backend services
Backend Microservices - Realtime Path
- REST API (backend-go / Gorilla Mux): Core HTTP API, CRUD operations, data retrieval
- WebSocket Server (backend-cpp / Boost ASIO): Low-latency quote streaming, real-time updates
- Auth Service (backend-node / Node.js): OAuth, JWT validation, session management
Backend Microservices - Processing Path
- Ticker Plant (backend-rust / Tokio): NSQ message consumer, quote processing, DataFrame analytics
- Analytics Engine (backend-py / Pandas/SciPy): Statistical analysis, ML models (PCA, forecasting, risk)
- Time-Series Warehouse (backend-q / kdb+ TorQ): Lightning-fast OHLCV queries, backtesting
Message Queue & Orchestration
- NSQ: Distributed pub/sub message queue for service-to-service async communication
- Apache Airflow: DAG-based job orchestration, scheduled analytics jobs
- Dask: Distributed task scheduler for parallel processing
Data Storage
- MongoDB: Document store for user configs, portfolios, analysis results
- MySQL: Transactional data, ledgers, audit logs
- Redis: In-memory cache for real-time quotes, session storage
- AWS S3: Data lake for historical OHLCV, backups, archives
- DuckDB: Analytical query engine for ad-hoc financial analysis
Infrastructure
- Docker Swarm: Container orchestration on Contabo (primary) and Hetzner (HA)
- AWS ECR: Private container image registry (public.ecr.aws/b8h3z2a1/sravz/*)
Service-to-Service Communication Matrix
| From | To | Protocol | Purpose | Message Format |
|---|---|---|---|---|
| Angular | REST API | HTTP/REST | Data queries, mutations | JSON |
| Angular | WebSocket | WebSocket | Real-time quotes | JSON + protobuf |
| WebSocket | NSQ | TCP | Tick events | MsgPack/JSON |
| REST API | MongoDB | TCP | User data, configs | BSON |
| REST API | MySQL | TCP | Transactional ledgers | SQL |
| Ticker Plant | NSQ | TCP | Subscribe to ticks | MsgPack |
| Ticker Plant | MongoDB | TCP | Store results | BSON |
| Analytics | MongoDB | TCP | Query & store results | BSON |
| Airflow | NSQ | TCP | Trigger tasks | JSON |
| Auth Service | MongoDB | TCP | User validation | BSON |
Deployment Architecture
Docker Compose Services (localhost-docker-compose.yaml):
- mongo - MongoDB (port 27017)
- nsqlookupd-1 - NSQ lookup daemon (port 4160-4161)
- nsqd-1 - NSQ daemon (port 4150-4151)
- nsqadmin - NSQ admin UI (port 4171)
- backend-py - Python analytics (workspace mount)
- backend-rust - Rust ticker plant (workspace mount)
- backend-cpp - C++ WebSocket (port 5001, workspace mount)
- backend-node - Node.js auth (port 3030, workspace mount)
- backend-go - Go REST API (port 8081, workspace mount)
- backend-q - kdb+ time series (local build, TorQ setup)
- redis - Redis cache (port 6379)
- mysql - MySQL (port 3306)
Production Deployments:
- Contabo Docker Swarm (Primary)
- Hetzner Docker Swarm (HA/Failover)
- AWS ECR (Image registry: public.ecr.aws/b8h3z2a1/sravz/*) | WebSocket Server | C++ (Boost/Std) | Real-time quote streaming | Low-latency tick updates, live feeds | | Ticker Plant | Rust | Historical ticker management | OHLCV storage, tick history, time-series | | Analytics Engine | Python (Pandas/NumPy) | Data analysis & ML | PCA, Prophet models, rolling stats, correlations |
Realtime Data Flow
- Data Ingestion: Interactive Brokers → WebSocket Server (C++)
- Quote Caching: Redis stores latest quotes
- Live Analysis: Realtime calculations on streaming ticks
- Storage: Ticker Plant persists quotes to MySQL/S3
Historical Data Flow
- Orchestration: Airflow schedules batch jobs
- Data Processing: Dask distributes computation
- Task Queue: NSQ manages background tasks
- Analytics: Python engine computes metrics
- Persistence: Results → MongoDB, S3, DuckDB
Analysis Capabilities
Realtime Analysis
- Quote Processing: Live bid/ask, last price, volume
- Streaming Calculations: Moving averages, momentum
- Alert Generation: Price targets, threshold crossings
- Dashboard Updates: WebSocket pushes to frontend
Historical Analysis
Statistical Analysis
- PCA (Principal Component Analysis)
- Time Series Analysis (ARIMA, SARIMAX)
- Covariance & Correlation Matrix
- Rolling Statistics (volatility, Sharpe ratio)
- Year-to-Date Returns
ML Models
- Prophet Forecasting
- Pyfolio Returns Analysis
Data Sources
- Equities (Stocks, ETFs, Mutual Funds)
- Futures (Commodities, Indices)
- Forex (Currency Pairs)
- Crypto (Digital Assets)
- Economic Calendars (Macro Indicators)
Data Storage Architecture
| Store | Technology | Use Case | Scale |
|---|---|---|---|
| Cache | Redis | Quote cache, sessions | Real-time |
| Document | MongoDB | User data, configs, analysis results | Flexible schema |
| Relational | MySQL | OHLCV ticks, transactions | Historical ticks |
| Data Lake | AWS S3 | Archival, backups | Unlimited |
| Analytics | DuckDB | OLAP queries, aggregations | Fast analytical queries |
Deployment Architecture
Production Infrastructure
- Contabo Swarm: Primary production cluster
- Hetzner Swarm: Failover/HA cluster
- Container Orchestration: Docker Swarm
- Load Balancing: Nginx/Traefik
- Monitoring: Prometheus + Grafana (optional)
Local Development
- Docker Compose with volume mounts
- Hugo server on localhost:1313
- Angular dev server with hot reload
- Python/Rust/Go with local execution
Integration Points
External APIs
- Interactive Brokers: Real-time quotes, historical data, order execution
- Economic Calendar: Macro events, releases
- Crypto Exchanges: Digital asset data
Internal APIs
- REST endpoints for CRUD operations
- WebSocket for real-time updates
- Async task queues for background work
Scalability Features
- Horizontal Scaling: Services run as Docker replicas in Swarm
- Task Distribution: Dask + Airflow handle computational load
- Caching Strategy: Redis reduces database hits
- Data Partitioning: Time-based partitioning in S3/MySQL
- Async Processing: NSQ decouples request/response cycles
See also: Tech Stack Details for implementation specifics
