Skip to content

Cloudflare Edge Telemetry & Real-Time Push Streaming — Architecture Specification


status: ACTIVE tier: 2 (design reference) last-verified: 2026-10-19 verified-against: HEAD procedure-skill: .agents/skills/publish/SKILL.md


1. Executive Summary & Design Rationale

The Trader-Jan platform operates distributed quantitative trading and genetic optimization systems across multiple physical nodes (macOS Apple Silicon host, Windows ATAS workstations, and virtual machines).

To provide institutional transparency, public performance tracking, and live broadcast capabilities without the fragility, maintenance burden, and security risks of local web servers, dynamic DNS, or port-forwarding, the presentation and ingestion layers are consolidated 100% natively onto the Cloudflare Edge Platform.

 [ Local Compute & Trading Nodes ]                           [ Cloudflare Edge Platform (traderjan.com) ]

  Node A: ATAS Trading Platform (Win / Mac)
  • TJ Alpha & Options Strategies
  • Emits orders, fills, PnL
         │
         ├───► HTTP POST /api/telemetry/trade_event ──┐
                                                      │
  Node B: Genetic Evolve Backtest Engine (Mac)       ▼
  • Numba GA population runs                 [ Cloudflare Workers & Pages Functions ]
  • Saves local CSV / Parquet ledger                  │
         │                                            ├─► Ingests & validates payload
         ├───► HTTP POST /api/telemetry/evolve ───────┤─► Persists to Cloudflare D1 (SQLite)
                                                      ├─► Broadcasts via Durable Object WebSockets
                                                      │
                                                      ▼
                                       ┌──────────────────────────────────────────────┐
                                       │   https://traderjan.com Presentation Layer   │
                                       ├──────────────────────┬───────────────────────┤
                                       │ /fleet               │ /evolve               │
                                       │ Live Algo Fleet HUD  │ Genetic Evolve HUD    │
                                       │ Trade Tape & PnL     │ Phenotype & Apex Hero │
                                       └──────────────────────┴───────────────────────┘
                                                      │
                                                      ▼ (Sub-30ms WebSocket Push)
                                      [ Connected Consumers Anywhere ]
                                      • OBS Studio Browser Source (YouTube Live)
                                      • Mobile Safari / Chrome on iOS & Android
                                      • Public traders & institutional investors

Key Architectural Tenets:

  1. Zero Local Middleman: No local webservers (such as FastAPI on :8056 or SimpleHTTP on :8055) run on trading or compute machines. Nodes are strictly data producers.
  2. Sub-30ms Instant Push: Telemetry is pushed to connected clients via Cloudflare Durable Objects utilizing the WebSocket Hibernation API, providing instantaneous visual feedback with zero CPU idle costs.
  3. 24/7/365 High Availability: Dashboards remain fully responsive, interactive, and publicly available even when trading terminals or compute nodes are powered off.
  4. Outbound-Only HTTPS: Client nodes only initiate outbound HTTPS POST requests (port 443). No inbound firewall holes, VPN tunnels, or static IPs are required.

2. Ingestion Contracts (Data Producers)

2.1 ATAS C# Strategy Telemetry (trade_event)

The ATAS C# strategies (TJ Alpha Strategy and Options Strategy) utilize the non-blocking TJTradeTelemetry singleton to emit structured JSON events over an asynchronous ring buffer.

  • Endpoint: POST https://traderjan.com/api/telemetry/trade_event
  • Transport: HTTPS POST (JSON payload, TLS 1.3)
  • Headers:
  • Content-Type: application/json
  • X-TJ-Signature: Hex HMAC-SHA256 signature (optional node authentication)
  • Payload Structure:
{
  "event_type": "TRADE_OPENED",
  "timestamp": "2026-10-19T14:32:00.124Z",
  "account_id": "SIM_PRO_01",
  "account_alias": "Apex Fleet #1",
  "strategy_name": "TJ Alpha Strategy",
  "symbol": "MNQ",
  "direction": "Buy",
  "quantity": 2,
  "entry_price": 20412.50,
  "current_price": 20412.50,
  "stop_loss": 20380.00,
  "take_profit": 20475.00,
  "chart_timeframe": "M5",
  "archetype": "Reversal",
  "trigger_catalyst": "Demand Index Div + VAH Bounce",
  "is_tj_initiated": true
}

2.2 Genetic Backtest Evolve Telemetry (evolve)

The Python genetic evolution runner emits periodic population updates and apex champion breakthroughs directly to Cloudflare edge upon completion of each generation.

  • Endpoint: POST https://traderjan.com/api/telemetry/evolve
  • Transport: HTTPS POST (JSON payload, non-blocking 1.0s timeout)
  • Payload Structure:
{
  "run_id": "MES_Renko16_PA_20261019",
  "generation": 42,
  "total_generations": 100,
  "evaluations_completed": 1250000,
  "active_apex": {
    "uid": "MES_Renko_16_4483A98B",
    "fitness_score": 8.42,
    "win_rate": 0.684,
    "net_ticks_session": 14.5,
    "max_drawdown_ticks": 48.0,
    "alleles": {
      "trend_bars": 3,
      "reversal_bars": 2,
      "pullback_ticks": 4,
      "atr_mult": 1.5
    }
  },
  "phenotypes": [
    {"win_rate": 0.55, "net_ticks": 8.2, "count": 120},
    {"win_rate": 0.62, "net_ticks": 12.1, "count": 45}
  ]
}

3. Cloudflare Edge Architecture

3.1 Cloudflare D1 (Serverless Edge SQLite)

Cloudflare D1 stores canonical telemetry records across globally replicated SQLite instances: * trades: Persistent ledger of completed trade lifecycles, realized PnL, R-multiples, and execution quality metrics (MAE/MFE). * orders: In-flight active orders, fills, trailing ratchets, and cancellations. * evolve_runs: Metadata, generation convergence curves, and historical champion lineage. * telemetry_settings: Active privacy modes (UploadAllAccountTrades, ReportTjTrades, masking rules).

3.2 Cloudflare Durable Objects (TradeBroadcaster)

To enable sub-30ms push latency to all active viewers: * A globally coordinated Durable Object (TradeBroadcaster) coordinates active WebSocket subscribers. * Uses the WebSocket Hibernation API: when no trades are occurring, connections sleep in Cloudflare memory at $0.00 compute cost. * When a trade_event or evolve POST arrives at any Cloudflare edge data center, the Worker dispatches the event to TradeBroadcaster, which broadcasts the delta down all open WebSockets in under 30 milliseconds.


4. Presentation & Broadcast Delivery

4.1 Web Portals (Cloudflare Pages)

  • Algo Fleet Live (https://traderjan.com/fleet): Real-time institutional execution dashboard, live PnL meter, dynamic equity area chart, rolling ticker tape, and interactive multi-account filters.
  • Genetic Evolve Cockpit (https://traderjan.com/evolve): 2D Phenotype risk-opportunity scatter plot, real-time fitness convergence curve, and active Apex Champion allele breakdown.
  • Universal Command Navigation: Single top navigation bar allowing seamless switching between Fleet Execution and Evolve Cockpits.

4.2 OBS Studio Integration (YouTube Live)

  • Dedicated clean 1080p HUD endpoints:
  • https://traderjan.com/obs/fleet (Transparent lower-third / radar canvas for trading streams)
  • https://traderjan.com/obs/evolve (1920×1080 full-screen HUD for bot training streams)
  • OBS Studio runs on the local Mac M2 Pro, capturing the Cloudflare URL as a Browser Source with hardware-accelerated CSS and Web Audio API synthesized chimes.