← Back to Blog
Technical Deep Dive

How We Built a Self-Improving Trading AI That Thinks Like a Quant Team

12 AI models voting on every decision. A Watchtower that self-corrects. A Board Room that governs every signal. Here's the complete architecture of Traders Regiment — and why every decision was made the way it was.
By Gunit Singh — Founder & Lead Architect, Traders Regiment  •  April 2026

When I set out to build Traders Regiment, I had one rule: no shortcuts. Every component had to be built the way an institutional quant team would build it — with the right tool for the right job, with explicit contracts between layers, and with failure modes that were designed for rather than discovered in production.

This is the architecture of that system. Every layer, every decision, every reason.

The System at a Glance

Traders Regiment is a monorepo with six independently deployable services:

Frontend (React + Vite) ←→ BFF (Node.js) ←→ ML Engine (Python FastAPI)
Telegram Bridge (Node.js) ←→ Firebase Auth + Realtime DB
SQLite Candle DB ←→ DVC + MLflow (model versioning)
Frontend — React + Vite UI Layer

React with Vite for fast hot-module replacement in development and optimized production builds. The frontend is purely presentational — it owns rendering and user interaction. All business logic lives in the BFF. Components are pure: props in, UI out. Heavy components lazy-loaded with React.lazy().

BFF — Node.js (port 8788) Orchestration Layer

Express.js Backend-for-Frontend. All ML engine calls, news fetches, and Telegram messages are orchestrated here. This is where the async-first, concurrent-by-default rule lives: when a consensus call is made, all 12 models are queried simultaneously — not sequentially. Bottleneck is the slowest model, not the sum of all models.

ML Engine — Python FastAPI (port 8001) Intelligence Layer

Every model runs in its own isolated process. FastAPI handles routing. All responses follow a strict BaseResponse contract with ok, error, latency_ms, and timestamp. Every endpoint has a 5-second timeout and a circuit breaker.

Telegram Bridge — Node.js Alert Layer

Event-driven bot that delivers consensus signals, regime changes, and Watchtower alerts directly to the trader's phone. Low latency. Rate-limited. Never floods the chat.

The Language Stack — The Right Tool for Every Task

No single language is best for everything. We chose each language for what it does best:

Task Language / Stack Why
Real-time signal orchestration Node.js Non-blocking async I/O — concurrent calls to 12 models at once
ML model inference Python scikit-learn, LightGBM, PyTorch — mature, best-in-class ML ecosystem
Sequence modeling PyTorch Mamba State-of-the-art long-range dependency modeling for market sequences
Regime detection Python HMM, fractal analysis, anomalous diffusion — statistical foundations
Frontend UI React Reactive component model — fast, declarative, easy to test
Data pipeline Python (pandas, numpy) Best for numerical, time-series, and financial computation
Telegram bridge Node.js Event-driven architecture matches Telegram's webhook model
Circuit breaking Node.js Built-in async error handling + promise race conditions for timeouts

The 5-Phase Recursive Consensus Engine

This is the core of Traders Regiment. Every trading decision passes through five phases:

[PHASE 1] Raw Market Data → Feature Pipeline

[PHASE 2] 12 Models Analyze Concurrently

[PHASE 3] Recursive Deliberation → Ensemble Convergence

[PHASE 4] Board Room Governance → Veto Check

[PHASE 5] Risk-Adjusted Signal Output

The 12 Models

Each model is an independent analytical agent with its own specialty. They don't know about each other — they just produce their output. The ensemble aggregator collects all votes and converges on a consensus:

Recursive Deliberation

Phase 2 doesn't end with a simple vote. The ensemble aggregator runs a multi-round deliberation:

  1. Round 1: All 12 models vote. Ensemble aggregates.
  2. Round 2: Models that were in the minority are asked to justify or revise. Regime conditions are injected as context.
  3. Round 3: Final convergence. Confidence score is weighted by historical model accuracy in the current regime.

The result is not just a majority vote — it's a deliberated consensus that has been stress-tested against dissenting views.

The Deliberative Board Room

The Board Room is our governance layer. It exists to prevent bad trades, not just to confirm good ones. It has veto power — and it uses it.

Consensus rule: 3 out of 5 Board Members must agree to proceed. Any single veto — from RiskOfficer, RegimeWatcher, or OptionsDesk — converts the signal to NEUTRAL. RiskOfficer always has the final word.

Board Member Specialty Veto?
Tech_IB Trendline + horizontal structure geometry No
Tech_Candle Candle patterns, wick noise filtering ("wick = noise, close = truth") No
RegimeWatcher CRISIS and CONTAGION regime detection YES
OptionsDesk Expiry day detection, LOW_IV regime YES
RiskOfficer Daily stop (2 losses), max positions (1 open) YES — ALWAYS FINAL

Veto Conditions (Codified)

The Board Room cannot be overridden by any other component. RiskOfficer veto is absolute. No code, prompt, or agent may disable or bypass these conditions.

Watchtower — The Self-Correcting Guardian

Watchtower is our performance monitoring and self-correction layer. It runs continuously, not on-demand.

Watchtower monitors:

Watchtower is the reason Traders Regiment doesn't just work on day one. It works better on day 30, and even better on day 300. The system learns from its own performance.

Self-Correction Loop

Watchtower Detects Drift

Flag model + weight down automatically

Trigger EWC Recalibration Pipeline

Paper Trade New Weights (1 trading week)

Promote or Reject → Watchtower resumes monitoring

Self-Improving AI — The Continual Learning Pipeline

Traders Regiment uses Elastic Weight Consolidation (EWC) — a technique that allows the AI to learn new market patterns without catastrophically forgetting the patterns it already knows. This is critical in trading, where old regimes return and old patterns resurface.

The continual learning pipeline:

Security Architecture

Security is not a feature. It's architecture. Every layer has explicit security controls:

Security Measure Layer What It Prevents
No secrets in code All layers Credentials in git history
Parameterized SQL queries ML Engine SQL injection
Pydantic input validation ML Engine Malformed inputs
5s timeout + circuit breaker BFF Cascading ML failures
Rate limiting BFF API abuse / DoS
SSH key auth + fail2ban VPS Brute-force access
UFW firewall (SSH locked to known IPs) VPS Unauthorized network access
Zod validation on all BFF routes BFF Bad data entering the system

Data Infrastructure

The Pipeline Ahead

The current architecture is the foundation. Here's what's being built on top of it:

The architecture was designed for growth. Every layer has explicit contracts. Every service is independently deployable. Adding a new model family takes one new subdirectory and one new BFF route — nothing else needs to change.
EDGE QUANT SYSTEM UNIVERSE ALPHA INSTITUTIONAL TRADING DESK HEDGE FUND MACHINE LEARNING PYTHON SELF-IMPROVING MOST INTELLIGENT AI SYSTEM

See the Architecture in Action

12 models. Board Room governance. Watchtower self-correction. This is what institutional quant intelligence looks like — in your browser.

Access Traders Regiment →