← Back to Blog
Technical Deep Dive

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

Multiple AI models voting on every decision. A Guardian that self-corrects. A Governance Board that oversees 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 ←→ Model versioning and tracking
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 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 contract with explicit success/error shapes and timestamps. Every endpoint has timeout and circuit breaker protection.

Telegram Bridge — Node.js Alert Layer

Event-driven bot that delivers consensus signals, regime changes, and Guardian 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 model calls at once
ML model inference Python industry-standard Python ML libraries — mature, best-in-class ML ecosystem
Sequence modeling sequence models State-of-the-art long-range dependency modeling for market sequences
Regime detection Python statistical regime analysis — 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 Consensus Engine

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

[PHASE 1] Raw Market Data → Feature Pipeline

[PHASE 2] Multiple Models Analyze Concurrently

[PHASE 3] Recursive Deliberation → Ensemble Convergence

[PHASE 4] Governance Board → Veto Check

[PHASE 5] Risk-Adjusted Signal Output

Model Families

Each model family 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 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 Governance Board

The Governance Board is our oversight 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 RiskAgent, RegimeAgent, or FlowAgent — converts the signal to NEUTRAL. RiskAgent always has the final word.

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

Veto Conditions (Codified)

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

The Guardian System — Self-Correcting Intelligence

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

The Guardian monitors:

The Guardian 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

Guardian Detects Drift

Flag model + weight down automatically

Trigger Recalibration Pipeline

Paper Trade New Weights (1 trading week)

Promote or Reject → Guardian resumes monitoring

Self-Improving AI — The Continual Learning Pipeline

Traders Regiment uses continual learning techniques that allow the AI to learn new market patterns without 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
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

Multi-model consensus. Governance oversight. Self-correcting intelligence. This is what institutional quant intelligence looks like — in your browser.

Access Traders Regiment →