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.
Traders Regiment is a monorepo with six independently deployable services:
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().
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.
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.
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.
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 |
This is the core of Traders Regiment. Every trading decision passes through multiple phases:
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:
Phase 2 doesn't end with a simple vote. The ensemble aggregator runs a multi-round deliberation:
The result is not just a majority vote — it's a deliberated consensus that has been stress-tested against dissenting views.
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 |
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 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.
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 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 |
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.
Multi-model consensus. Governance oversight. Self-correcting intelligence. This is what institutional quant intelligence looks like — in your browser.
Access Traders Regiment →