https://syntax-cartel-devclash.vercel.app/
DevClash 2026 β Team Syntax Cartel
An event-driven, production-grade system that detects systemic financial crises in real-time using an ensemble of Six ML/quant models processing 18 correlated assets at 4β25 Hz, with Redis Streams event-driven architecture, PostgreSQL star-schema persistence, and a 60fps WebSocket-driven dashboard.
The 2008 crisis, COVID crash, and SVB collapse all shared a pattern: systemic risk signals existed days before markets collapsed, but no unified system combined cross-asset anomaly detection, credit risk models, and correlation analysis in real-time.
Velure solves this. It fuses four complementary models into one system that gives portfolio managers, regulators, and risk desks a single pane of glass showing when markets transition from noise to contagion.
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββββββ
β GBM Simulator β β Redis Streams β β ML Ensemble β
β 18 assets, 4Hz ββββββΆβ (Event Queue) ββββββΆβ Micro-Batch β
β Correlated Mkt β β Backpressure β β IF + LSTM + CISS β
β Crisis Injectionβ β Fallback Queue β β + Merton DD β
βββββββββββββββββββ ββββββββββββββββββββ ββββββββββ¬βββββββββββββ
β
ββββββββββββββββββββββββββββββββββββββββ
β
ββββββββββΌββββββββββ βββββββββββββββββββββββ
β FastAPI + WS β β Next.js Dashboard β
β REST + WebSocketββββββΆβ ECharts + Canvas β
β CORS + Lifecycleβ β 60fps RAF Buffer β
ββββββββββ¬ββββββββββ βββββββββββββββββββββββ
β
ββββββββββΌββββββββββ
β PostgreSQL 16 β
β Star Schema β
β Kimball DW β
ββββββββββββββββββββ
| Layer | Technology | Why |
|---|---|---|
| Simulation | Geometric Brownian Motion + Cholesky decomp | Realistic correlated multi-asset returns |
| Live Data | Finnhub WebSocket (11 symbols) | Real-time equities, FX, crypto with OHLCV aggregation |
| Message Queue | Redis 7 Streams + asyncio.Queue fallback | Event-driven decoupling with backpressure |
| Anomaly Detection | scikit-learn Isolation Forest (200 trees) | Cross-sectional anomaly scoring |
| Temporal Detection | PyTorch LSTM Autoencoder (72β32β72) | Regime-change detection via reconstruction error |
| Systemic Stress | ECB CISS methodology (SciPy) | Correlation-weighted composite stress index |
| Credit Risk | Merton structural model + SRISK | Distance-to-Default + systemic capital shortfall |
| API | FastAPI + uvicorn async | Sub-ms routing, native WebSocket support |
| Database | PostgreSQL 16 + asyncpg | Star schema fact tables, dimension modeling |
| Frontend | Next.js 16 + React 19 | Server components, Turbopack |
| Charts | ECharts 6 (Canvas) + Canvas 2D API | GPU-accelerated 60fps rendering |
| Animation | Framer Motion 12 | Physics-based UI transitions |
| Infra | Docker Compose (4 services) | One-command deployment |
| Model | Architecture | Input | Output | Purpose |
|---|---|---|---|---|
| Isolation Forest | 200 estimators, contamination=0.05 | 72-dim state vector (18 assets Γ 4 features) | Anomaly score [0,1] | Detects cross-asset statistical outliers |
| LSTM Autoencoder | Encoder: LSTM(72β64β32), Decoder: LSTM(32β64β72) | 60-tick sequence window | Reconstruction error β score [0,1] | Detects temporal regime changes |
| CISS | Empirical CDF + correlation-weighted quadratic form | 5 market segments (equity, FX, rates, credit, vol) | Systemic stress [0,1] | ECB-inspired composite stress index |
| Merton DD | Structural: DD = [ln(A/L) + (ΞΌ-ΟΒ²/2)T] / ΟβT | Per-institution equity vol, leverage | Distance-to-Default, P(Default), SRISK | Institutional credit risk |
Ensemble weights: IF (0.4) + LSTM (0.4) + CISS (0.2) β Combined anomaly score
Alert thresholds: Combined > 0.7 β HIGH | > 0.85 β CRITICAL
- Real-time pipeline β 4β25 Hz configurable tick rate, sub-100ms inference latency
- 4-model ML ensemble β Micro-batch processing (flush every 10 ticks or 500ms)
- CISS Gauge β SVG arc gauge with severity color transitions
- Merton Distance-to-Default β 5 tracked institutions (JPM, GS, BAC, C, MS)
- System SRISK β Aggregate capital shortfall with per-institution breakdown
- Crisis Presets β One-click Lehman 2008, COVID 2020, SVB 2023, Flash Crash scenarios
- Speed Control β Slow (2 tps) / Normal (4) / Fast (10) / Turbo (25) for demo
- Anomaly Timeline β ECharts canvas with 4 overlaid model score series
- Correlation Heatmap β Canvas 2D rendered cross-asset matrix
- Explainability (XAI) β Feature importance + CISS segment breakdown
- Pipeline Health β Live throughput, latency, Redis/PostgreSQL status monitoring
- Star Schema β Kimball fact/dimension tables with time, asset, source, alert dims
- Graceful degradation β Redis down β in-process queue; DB down β continues without persistence
- VaR/CVaR Calculator β 3 methods (Historical, Parametric, Cornish-Fisher) with risk regime detection
- Contagion Network β Force-directed graph showing cross-asset correlation propagation
- Finnhub Live Connector β Real-time WebSocket data from 11 symbols (equities, FX, crypto)
- Circuit Breakers β 3-state (CLOSED/OPEN/HALF_OPEN) for Redis and PostgreSQL fault isolation
- Structured JSON Logging β Per-component loggers with timestamp, level, and context fields
- Rate Limiting β Sliding-window per-IP rate limiter (configurable via env)
- Prometheus Metrics β
/metricsendpoint with 16 metric families for Grafana/Alertmanager - Deep Health Check β
/healthendpoint with circuit breaker status and component readiness
docker-compose up --build# Terminal 1 β Backend
cd backend
pip install -r requirements.txt
uvicorn main:app --reload --port 8000
# Terminal 2 β Frontend
cd frontend
npm install
npm run dev- [0:00β0:30] Normal Markets β Show live streaming data, CISS gauge at green, all models scoring low
- [0:30β1:00] Explain Architecture β Point to pipeline health panel showing tps, Redis Streams, DB writes
- [1:00β2:00] Trigger Lehman 2008 β Click preset, watch correlations spike, CISS gauge sweep to red, Merton DD collapse
- [2:00β3:00] Show SRISK Panel β Total capital shortfall climbing, per-institution bars filling, CRITICAL status
- [3:00β3:30] Explainability β Show which features drove the alert, CISS segment breakdown
- [3:30β4:00] Recovery β Deactivate crisis, watch models return to baseline, demonstrate adaptive thresholding
- [4:00β5:00] Architecture Deep-Dive β Redis Streams decoupling, micro-batch inference, star schema, RAF pattern
| Method | Endpoint | Description |
|---|---|---|
GET |
/ |
System status |
GET |
/health |
Deep health check (pipeline, Redis, PostgreSQL, circuit breakers) |
GET |
/metrics |
Prometheus text exposition metrics (Grafana/Alertmanager compatible) |
GET |
/api/scores |
Latest ML scores |
GET |
/api/merton |
Institution DD scores |
GET |
/api/merton/srisk |
Aggregate SRISK |
GET |
/api/ciss/breakdown |
CISS component decomposition |
GET |
/api/var |
VaR/CVaR risk metrics (Historical, Parametric, Cornish-Fisher) |
GET |
/api/alerts |
Recent alert history |
GET |
/api/metrics |
Pipeline health metrics |
GET |
/api/crisis-presets |
Available crisis scenarios |
GET |
/api/config |
System configuration |
POST |
/api/stress-test/activate |
Custom crisis injection |
POST |
/api/stress-test/preset |
Named crisis scenario |
POST |
/api/stress-test/deactivate |
Restore normal markets |
POST |
/api/speed/{mode} |
Set pipeline speed (slow/normal/fast/turbo) |
WS |
/ws/dashboard |
Live streaming WebSocket |
Kimball Star Schema with fact/dimension modeling:
fact_market_metricsβ 15 measures per tick (price, vol, scores, anomaly flags)dim_timeβ Time hierarchy (hour, day, session, market state)dim_assetβ 20 assets across 5 classes (equity, FX, bonds, crypto, rates)dim_sourceβ 5 data providersdim_alertβ Crisis alerts with severity, model source, scores
βββ docker-compose.yml # 4-service orchestration
βββ backend/
β βββ main.py # FastAPI + pipeline orchestrator (~700 lines)
β βββ ingestion/
β β βββ simulator.py # Correlated GBM market generator
β β βββ redis_streams.py # Event queue with fallback
β β βββ finnhub_connector.py# Live Finnhub WebSocket connector (11 symbols)
β βββ models/
β β βββ ensemble.py # Micro-batch ML orchestrator (fault-isolated)
β β βββ isolation_forest.py # Unsupervised anomaly detection
β β βββ lstm_autoencoder.py # Temporal pattern detection
β β βββ ciss_scorer.py # ECB systemic stress index
β β βββ merton_model.py # Structural credit risk
β β βββ var_calculator.py # VaR/CVaR (3 methods) + risk regime
β βββ utils/
β β βββ config.py # Centralized env-based configuration
β β βββ logger.py # Structured JSON logging
β β βββ circuit_breaker.py # 3-state circuit breakers (Redis/PostgreSQL)
β β βββ middleware.py # Rate limiter + API key auth
β βββ db/
β βββ schema.sql # Star schema DDL
β βββ seed.sql # Dimension data
β βββ connection.py # asyncpg pool
βββ frontend/
βββ src/app/
βββ page.js # Dashboard compositor
βββ components/ # 15 specialized components
βββ lib/useWebSocket.js # RAF-buffered WS hook
Syntax Cartel β DevClash 2026