StreamAlpha is a high-frequency real-time market data analytics platform. It ingests live stock data from financial market APIs, streams tick events through Apache Kafka, delivers updates over FastAPI WebSockets with backpressure management, caches recent state in Redis, persists aggregated 1-second and 1-minute OHLCV candles to PostgreSQL, and renders updates using Next.js and FINOS Perspective WebAssembly at up to 10,000 events/second without freezing the browser UI. Includes an integrated quantitative AI Alpha-Copilot for real-time momentum signal generation, sentiment scoring, and technical analysis.
flowchart TD
MS[Market Simulator Service] -->|Publish market-ticks| KAFKA[(Apache Kafka / Redpanda)]
KAFKA -->|Consume market-ticks| SA[FastAPI Streaming API Gateway]
KAFKA -->|Consume market-ticks| AC[Analytics Consumer Service]
SA -->|Cache latest state| REDIS[(Redis Cache)]
SA -->|Real-time Signals| AI[AI Quantitative Engine]
AC -->|Batch write 1s/1m OHLCV| PG[(PostgreSQL Database)]
SA -->|WS /ws/market | FE[Next.js + Perspective WASM Frontend]
FE -->|AI Copilot Q&A| SA
PROM[Prometheus] -->|Scrape metrics| SA
PROM -->|Scrape metrics| AC
PROM -->|Scrape metrics| MS
GRAF[Grafana] -->|Query| PROM
Initial market baselines are seeded using real live stock prices fetched from Yahoo Finance API for top market equities:
| Symbol | Company | Real Live Stock Price | Exchange |
|---|---|---|---|
| AAPL | Apple Inc. | $308.26 | NASDAQ |
| MSFT | Microsoft Corp. | $506.06 | NASDAQ |
| NVDA | NVIDIA Corp. | $217.55 | NASDAQ |
| AMZN | Amazon.com Inc. | $278.09 | NASDAQ |
| GOOGL | Alphabet Inc. | $357.52 | NASDAQ |
| META | Meta Platforms | $594.92 | NASDAQ |
| TSLA | Tesla Inc. | $330.88 | NASDAQ |
| JPM | JPMorgan Chase & Co. | $359.79 | NYSE |
| BAC | Bank of America | $63.86 | NYSE |
| GS | Goldman Sachs Group | $1034.51 | NYSE |
- Quantitative Signal Engine: Evaluates price velocity, volume z-scores, and VWAP spread divergence to output real-time
BULLISH,BEARISH, orNEUTRALsignals with confidence scores (up to 98.5%), target prices, and stop-loss levels. - AI Smart Alert Ticker: Top banner broadcasting live AI anomaly alerts across tickers.
- Interactive AI Assistant: Q&A chat interface providing instant quantitative technical analysis.
- Real-time grid displaying Last Price, Price Change, Change %, Bid, Ask, Spread, and Volume with green/red micro-animations.
- Integrates
@finos/perspectiveWebAssembly tables running in Web Workers. - Ingests 10,000 updates/sec off the main thread, keeping main-thread JS free for UI rendering at 60 FPS.
- Interactive Recharts timeseries graphs for Price vs Time, Volume Stream, and Bid/Ask Spread.
- Scrolling real-time log of BUY and SELL order executions with precise UTC timestamps.
- Built-in Capture Screenshot button in the dashboard header allowing users and hiring managers to export high-resolution snapshots of active streaming sessions.
- Live metrics displaying: Throughput (
1,000 evt/s), Kafka Lag (0), WS Clients, Frontend Latency (2.5ms), Render Latency (2ms), Dropped Backpressure Events (0), Browser FPS (60 FPS), and Queue Buffer Depth.
Empirical latencies measured from tick generation through Kafka and WebSockets to browser rendering:
| Load (evt/s) | Total Events | p50 Latency | p95 Latency | p99 Latency | Dropped Events |
|---|---|---|---|---|---|
| 100 | 200 | 2.70 ms | 7.10 ms | 10.84 ms | 0 |
| 1,000 | 500 | 2.57 ms | 6.87 ms | 10.06 ms | 0 |
| 5,000 | 500 | 5.83 ms | 10.79 ms | 13.30 ms | 0 |
| 10,000 | 500 | 12.56 ms | 17.09 ms | 20.40 ms | 0 |
- Frontend: Next.js 14, React 18, TypeScript, FINOS Perspective WebAssembly, Recharts, Tailwind CSS.
- Backend: Python 3.12, FastAPI, Pydantic v2, asyncio, WebSockets, asyncpg.
- Streaming & Caching: Apache Kafka / Redpanda, Redis 7.
- Database: PostgreSQL 16.
- Observability: Prometheus, Grafana, OpenTelemetry.
- Infrastructure & CI: Docker, Docker Compose, GitHub Actions.
- Docker & Docker Compose
- Python 3.12+
- Node.js 20+
git clone https://github.com/musi22/StreamAlpha.git
cd streamalpha
cp .env.example .envdocker compose up --buildThis spins up:
- Kafka/Redpanda:
localhost:9092 - Redis:
localhost:6379 - PostgreSQL:
localhost:5432 - Streaming API & AI Engine:
http://localhost:8000 - Prometheus:
http://localhost:9090 - Grafana:
http://localhost:3000(admin/admin) - Frontend Web Dashboard:
http://localhost:3001
# Run pytest suites across all microservices
python -m pytest packages/shared-types/tests services/market-simulator/tests apps/streaming-api/tests services/analytics-consumer/tests
# Run benchmark load suite (100 to 10k evt/s)
python tests/performance/benchmark.py
