# pathtomillions001-bot/neurotradeai-8-bk2-backup5 architecture

> Architecture diagram of the GitHub repository pathtomillions001-bot/neurotradeai-8-bk2-backup5, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/pathtomillions001-bot/neurotradeai-8-bk2-backup5
- Repository: https://github.com/pathtomillions001-bot/neurotradeai-8-bk2-backup5

## Overview

This repository implements an algorithmic trading platform: a browser console and API server support market analysis, trading engines, and account-scoped execution. A typical user connects an account, views markets or a trading console, and uses an engine to analyze signals and place trades through Deriv; results can be streamed to the browser. The tree also documents analytics, bots, recovery, and specialist strategies. Source excerpts show selected engine and session relationships; many route and UI integrations are unsampled, so those links are omitted or marked unverified.

Main entry points: [`artifacts/api-server/src/lib/deriv.ts`](https://github.com/pathtomillions001-bot/neurotradeai-8-bk2-backup5/blob/main/artifacts/api-server/src/lib/deriv.ts) (Deriv client), [`artifacts/api-server/src/lib/speed-ai-engine.ts`](https://github.com/pathtomillions001-bot/neurotradeai-8-bk2-backup5/blob/main/artifacts/api-server/src/lib/speed-ai-engine.ts) (NeuroAI FAB), [`artifacts/api-server/src/lib/agents/recovery-engine.ts`](https://github.com/pathtomillions001-bot/neurotradeai-8-bk2-backup5/blob/main/artifacts/api-server/src/lib/agents/recovery-engine.ts) (Recovery engine), [`artifacts/api-server/src/lib/bot-engine.ts`](https://github.com/pathtomillions001-bot/neurotradeai-8-bk2-backup5/blob/main/artifacts/api-server/src/lib/bot-engine.ts) (Specialist bots)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Trading console"]
  node_webapp["Trading platform<br/>[App.tsx]"]
  node_marketdetail["Market detail<br/>[market-detail.tsx]"]
end

subgraph group_api["API surface"]
  node_apiapp["API server<br/>[app.ts]"]
  node_airoutes["AI routes<br/>[ai.ts]"]
  node_routes["Route registry<br/>[index.ts]"]
end

subgraph group_market["Market data"]
  node_deriv["Deriv client<br/>[deriv.ts]"]
  node_bands["Market regimes<br/>[band-regime.ts]"]
end

subgraph group_engines["Trading engines"]
  node_speed["NeuroAI FAB<br/>[speed-ai-engine.ts]"]
  node_botengine["Specialist bots<br/>[bot-engine.ts]"]
  node_apex["Apex strategy<br/>[apex-engine.ts]"]
  node_bastion["Bastion strategy<br/>[bastion-engine.ts]"]
  node_killshot["Kill-Shot strategy<br/>[killshot-engine.ts]"]
  node_navigator["Over/Under strategy"]
  node_analysis["Apex analysis<br/>[apex-analysis.ts]"]
  node_killanalysis["Kill-Shot analysis"]
  node_specialist["Specialist analysis"]
  node_quantum["Quantum analysis"]
end

subgraph group_execution["Execution and state"]
  node_recovery["Recovery engine<br/>[recovery-engine.ts]"]
  node_arbiter["Execution arbiter<br/>[engine-arbiter.ts]"]
  node_registry["Bot registry<br/>[engine-registry.ts]"]
  node_sessions["Browser sessions<br/>[session.ts]"]
  node_payout["Recovery payout<br/>[recovery-payout.ts]"]
  node_sse["Event stream<br/>[sse.ts]"]
  node_logger["Logging<br/>[logger.ts]"]
end

node_trader(("Trader"))
node_derivservice{{"Deriv trading service"}}
node_database[("Database")]

node_trader -->|"uses"| node_webapp
node_webapp -.->|"requests API"| node_apiapp
node_webapp -->|"routes to"| node_marketdetail
node_apiapp -->|"mounts routes"| node_routes
node_apiapp -->|"mounts AI routes"| node_airoutes
node_airoutes -.->|"uses market services"| node_deriv
node_speed -->|"executes trades"| node_deriv
node_speed -->|"quotes recovery"| node_payout
node_speed -->|"scores signals"| node_quantum
node_speed -.->|"coordinates execution"| node_arbiter
node_speed -.->|"scopes state"| node_sessions
node_speed -.->|"publishes events"| node_sse
node_botengine -->|"uses market services"| node_deriv
node_botengine -->|"uses recovery"| node_recovery
node_botengine -->|"scores signals"| node_quantum
node_botengine -->|"analyzes strategies"| node_specialist
node_botengine -.->|"registers engine"| node_registry
node_apex -->|"uses market services"| node_deriv
node_apex -->|"analyzes signals"| node_analysis
node_apex -->|"uses recovery"| node_recovery
node_bastion -->|"uses market services"| node_deriv
node_bastion -->|"checks regimes"| node_bands
node_bastion -->|"uses recovery"| node_recovery
node_killshot -->|"reads ticks"| node_deriv
node_killshot -->|"screens candidates"| node_killanalysis
node_killshot -->|"quotes recovery"| node_payout
node_navigator -->|"uses market services"| node_deriv
node_navigator -->|"checks regimes"| node_bands
node_navigator -->|"uses recovery"| node_recovery
node_recovery -->|"scopes recovery"| node_sessions
node_recovery -->|"persists state"| node_database
node_payout -->|"requests quote"| node_deriv
node_payout -.->|"uses fallback schedule"| node_database
node_sessions -->|"reads session links"| node_database
node_deriv -.->|"connects WebSocket"| node_derivservice
node_killshot -->|"broadcasts updates"| node_sse
node_speed -.->|"logs activity"| node_logger

click node_webapp "https://github.com/pathtomillions001-bot/neurotradeai-8-bk2-backup5/blob/main/artifacts/trading-platform/src/App.tsx"
click node_marketdetail "https://github.com/pathtomillions001-bot/neurotradeai-8-bk2-backup5/blob/main/artifacts/trading-platform/src/pages/market-detail.tsx"
click node_apiapp "https://github.com/pathtomillions001-bot/neurotradeai-8-bk2-backup5/blob/main/artifacts/api-server/src/app.ts"
click node_airoutes "https://github.com/pathtomillions001-bot/neurotradeai-8-bk2-backup5/blob/main/artifacts/api-server/src/routes/ai.ts"
click node_routes "https://github.com/pathtomillions001-bot/neurotradeai-8-bk2-backup5/blob/main/artifacts/api-server/src/routes/index.ts"
click node_deriv "https://github.com/pathtomillions001-bot/neurotradeai-8-bk2-backup5/blob/main/artifacts/api-server/src/lib/deriv.ts"
click node_bands "https://github.com/pathtomillions001-bot/neurotradeai-8-bk2-backup5/blob/main/artifacts/api-server/src/lib/band-regime.ts"
click node_speed "https://github.com/pathtomillions001-bot/neurotradeai-8-bk2-backup5/blob/main/artifacts/api-server/src/lib/speed-ai-engine.ts"
click node_botengine "https://github.com/pathtomillions001-bot/neurotradeai-8-bk2-backup5/blob/main/artifacts/api-server/src/lib/bot-engine.ts"
click node_apex "https://github.com/pathtomillions001-bot/neurotradeai-8-bk2-backup5/blob/main/artifacts/api-server/src/lib/apex-engine.ts"
click node_bastion "https://github.com/pathtomillions001-bot/neurotradeai-8-bk2-backup5/blob/main/artifacts/api-server/src/lib/bastion-engine.ts"
click node_killshot "https://github.com/pathtomillions001-bot/neurotradeai-8-bk2-backup5/blob/main/artifacts/api-server/src/lib/killshot-engine.ts"
click node_navigator "https://github.com/pathtomillions001-bot/neurotradeai-8-bk2-backup5/blob/main/artifacts/api-server/src/lib/overunder-navigator-engine.ts"
click node_analysis "https://github.com/pathtomillions001-bot/neurotradeai-8-bk2-backup5/blob/main/artifacts/api-server/src/lib/apex-analysis.ts"
click node_killanalysis "https://github.com/pathtomillions001-bot/neurotradeai-8-bk2-backup5/blob/main/artifacts/api-server/src/lib/killshot-analysis.ts"
click node_specialist "https://github.com/pathtomillions001-bot/neurotradeai-8-bk2-backup5/blob/main/artifacts/api-server/src/lib/specialist-analysis.ts"
click node_quantum "https://github.com/pathtomillions001-bot/neurotradeai-8-bk2-backup5/blob/main/artifacts/api-server/src/lib/quantum-analysis.ts"
click node_recovery "https://github.com/pathtomillions001-bot/neurotradeai-8-bk2-backup5/blob/main/artifacts/api-server/src/lib/agents/recovery-engine.ts"
click node_arbiter "https://github.com/pathtomillions001-bot/neurotradeai-8-bk2-backup5/blob/main/artifacts/api-server/src/lib/engine-arbiter.ts"
click node_registry "https://github.com/pathtomillions001-bot/neurotradeai-8-bk2-backup5/blob/main/artifacts/api-server/src/lib/engine-registry.ts"
click node_sessions "https://github.com/pathtomillions001-bot/neurotradeai-8-bk2-backup5/blob/main/artifacts/api-server/src/lib/session.ts"
click node_payout "https://github.com/pathtomillions001-bot/neurotradeai-8-bk2-backup5/blob/main/artifacts/api-server/src/lib/recovery-payout.ts"
click node_sse "https://github.com/pathtomillions001-bot/neurotradeai-8-bk2-backup5/blob/main/artifacts/api-server/src/lib/sse.ts"
click node_logger "https://github.com/pathtomillions001-bot/neurotradeai-8-bk2-backup5/blob/main/artifacts/api-server/src/lib/logger.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_webapp,node_marketdetail toneBlue
class node_apiapp,node_airoutes,node_routes,node_database toneAmber
class node_deriv,node_bands toneMint
class node_speed,node_botengine,node_apex,node_bastion,node_killshot,node_navigator,node_analysis,node_killanalysis,node_specialist,node_quantum toneRose
class node_recovery,node_arbiter,node_registry,node_sessions,node_payout,node_sse,node_logger,node_trader,node_derivservice toneIndigo
```

## Components

### Trading console

- [Trading platform](https://github.com/pathtomillions001-bot/neurotradeai-8-bk2-backup5/blob/main/artifacts/trading-platform/src/App.tsx): `artifacts/trading-platform/src/App.tsx`
- [Market detail](https://github.com/pathtomillions001-bot/neurotradeai-8-bk2-backup5/blob/main/artifacts/trading-platform/src/pages/market-detail.tsx): `artifacts/trading-platform/src/pages/market-detail.tsx`

### API surface

- [API server](https://github.com/pathtomillions001-bot/neurotradeai-8-bk2-backup5/blob/main/artifacts/api-server/src/app.ts): `artifacts/api-server/src/app.ts`
- [AI routes](https://github.com/pathtomillions001-bot/neurotradeai-8-bk2-backup5/blob/main/artifacts/api-server/src/routes/ai.ts): `artifacts/api-server/src/routes/ai.ts`
- [Route registry](https://github.com/pathtomillions001-bot/neurotradeai-8-bk2-backup5/blob/main/artifacts/api-server/src/routes/index.ts): `artifacts/api-server/src/routes/index.ts`

### Market data

- [Deriv client](https://github.com/pathtomillions001-bot/neurotradeai-8-bk2-backup5/blob/main/artifacts/api-server/src/lib/deriv.ts): `artifacts/api-server/src/lib/deriv.ts`
- [Market regimes](https://github.com/pathtomillions001-bot/neurotradeai-8-bk2-backup5/blob/main/artifacts/api-server/src/lib/band-regime.ts): `artifacts/api-server/src/lib/band-regime.ts`

### Trading engines

- [NeuroAI FAB](https://github.com/pathtomillions001-bot/neurotradeai-8-bk2-backup5/blob/main/artifacts/api-server/src/lib/speed-ai-engine.ts): `artifacts/api-server/src/lib/speed-ai-engine.ts`
- [Specialist bots](https://github.com/pathtomillions001-bot/neurotradeai-8-bk2-backup5/blob/main/artifacts/api-server/src/lib/bot-engine.ts): `artifacts/api-server/src/lib/bot-engine.ts`
- [Apex strategy](https://github.com/pathtomillions001-bot/neurotradeai-8-bk2-backup5/blob/main/artifacts/api-server/src/lib/apex-engine.ts): `artifacts/api-server/src/lib/apex-engine.ts`
- [Bastion strategy](https://github.com/pathtomillions001-bot/neurotradeai-8-bk2-backup5/blob/main/artifacts/api-server/src/lib/bastion-engine.ts): `artifacts/api-server/src/lib/bastion-engine.ts`
- [Kill-Shot strategy](https://github.com/pathtomillions001-bot/neurotradeai-8-bk2-backup5/blob/main/artifacts/api-server/src/lib/killshot-engine.ts): `artifacts/api-server/src/lib/killshot-engine.ts`
- [Over/Under strategy](https://github.com/pathtomillions001-bot/neurotradeai-8-bk2-backup5/blob/main/artifacts/api-server/src/lib/overunder-navigator-engine.ts): `artifacts/api-server/src/lib/overunder-navigator-engine.ts`
- [Apex analysis](https://github.com/pathtomillions001-bot/neurotradeai-8-bk2-backup5/blob/main/artifacts/api-server/src/lib/apex-analysis.ts): `artifacts/api-server/src/lib/apex-analysis.ts`
- [Kill-Shot analysis](https://github.com/pathtomillions001-bot/neurotradeai-8-bk2-backup5/blob/main/artifacts/api-server/src/lib/killshot-analysis.ts): `artifacts/api-server/src/lib/killshot-analysis.ts`
- [Specialist analysis](https://github.com/pathtomillions001-bot/neurotradeai-8-bk2-backup5/blob/main/artifacts/api-server/src/lib/specialist-analysis.ts): `artifacts/api-server/src/lib/specialist-analysis.ts`
- [Quantum analysis](https://github.com/pathtomillions001-bot/neurotradeai-8-bk2-backup5/blob/main/artifacts/api-server/src/lib/quantum-analysis.ts): `artifacts/api-server/src/lib/quantum-analysis.ts`

### Execution and state

- [Recovery engine](https://github.com/pathtomillions001-bot/neurotradeai-8-bk2-backup5/blob/main/artifacts/api-server/src/lib/agents/recovery-engine.ts): `artifacts/api-server/src/lib/agents/recovery-engine.ts`
- [Execution arbiter](https://github.com/pathtomillions001-bot/neurotradeai-8-bk2-backup5/blob/main/artifacts/api-server/src/lib/engine-arbiter.ts): `artifacts/api-server/src/lib/engine-arbiter.ts`
- [Bot registry](https://github.com/pathtomillions001-bot/neurotradeai-8-bk2-backup5/blob/main/artifacts/api-server/src/lib/engine-registry.ts): `artifacts/api-server/src/lib/engine-registry.ts`
- [Browser sessions](https://github.com/pathtomillions001-bot/neurotradeai-8-bk2-backup5/blob/main/artifacts/api-server/src/lib/session.ts): `artifacts/api-server/src/lib/session.ts`
- [Recovery payout](https://github.com/pathtomillions001-bot/neurotradeai-8-bk2-backup5/blob/main/artifacts/api-server/src/lib/recovery-payout.ts): `artifacts/api-server/src/lib/recovery-payout.ts`
- [Event stream](https://github.com/pathtomillions001-bot/neurotradeai-8-bk2-backup5/blob/main/artifacts/api-server/src/lib/sse.ts): `artifacts/api-server/src/lib/sse.ts`
- [Logging](https://github.com/pathtomillions001-bot/neurotradeai-8-bk2-backup5/blob/main/artifacts/api-server/src/lib/logger.ts): `artifacts/api-server/src/lib/logger.ts`

### Other components

- **Trader**
- **Deriv trading service**
- **Database**

## Connections

- Trader → Trading platform: uses
- Trading platform → API server: requests API
- Trading platform → Market detail: routes to (evidence: `artifacts/trading-platform/src/App.tsx`)
- API server → Route registry: mounts routes (evidence: `artifacts/api-server/src/app.ts`)
- API server → AI routes: mounts AI routes (evidence: `artifacts/api-server/src/app.ts`)
- AI routes → Deriv client: uses market services
- NeuroAI FAB → Deriv client: executes trades (evidence: `artifacts/api-server/src/lib/speed-ai-engine.ts`)
- NeuroAI FAB → Recovery payout: quotes recovery (evidence: `artifacts/api-server/src/lib/speed-ai-engine.ts`)
- NeuroAI FAB → Quantum analysis: scores signals (evidence: `artifacts/api-server/src/lib/speed-ai-engine.ts`)
- NeuroAI FAB → Execution arbiter: coordinates execution (evidence: `artifacts/api-server/src/lib/speed-ai-engine.ts`)
- NeuroAI FAB → Browser sessions: scopes state (evidence: `artifacts/api-server/src/lib/speed-ai-engine.ts`)
- NeuroAI FAB → Event stream: publishes events (evidence: `artifacts/api-server/src/lib/speed-ai-engine.ts`)
- Specialist bots → Deriv client: uses market services (evidence: `artifacts/api-server/src/lib/bot-engine.ts`)
- Specialist bots → Recovery engine: uses recovery (evidence: `artifacts/api-server/src/lib/bot-engine.ts`)
- Specialist bots → Quantum analysis: scores signals (evidence: `artifacts/api-server/src/lib/bot-engine.ts`)
- Specialist bots → Specialist analysis: analyzes strategies (evidence: `artifacts/api-server/src/lib/bot-engine.ts`)
- Specialist bots → Bot registry: registers engine (evidence: `artifacts/api-server/src/lib/bot-engine.ts`)
- Apex strategy → Deriv client: uses market services (evidence: `artifacts/api-server/src/lib/apex-engine.ts`)
- Apex strategy → Apex analysis: analyzes signals (evidence: `artifacts/api-server/src/lib/apex-engine.ts`)
- Apex strategy → Recovery engine: uses recovery (evidence: `artifacts/api-server/src/lib/apex-engine.ts`)
- Bastion strategy → Deriv client: uses market services (evidence: `artifacts/api-server/src/lib/bastion-engine.ts`)
- Bastion strategy → Market regimes: checks regimes (evidence: `artifacts/api-server/src/lib/bastion-engine.ts`)
- Bastion strategy → Recovery engine: uses recovery (evidence: `artifacts/api-server/src/lib/bastion-engine.ts`)
- Kill-Shot strategy → Deriv client: reads ticks (evidence: `artifacts/api-server/src/lib/killshot-engine.ts`)
- Kill-Shot strategy → Kill-Shot analysis: screens candidates (evidence: `artifacts/api-server/src/lib/killshot-engine.ts`)
- Kill-Shot strategy → Recovery payout: quotes recovery (evidence: `artifacts/api-server/src/lib/killshot-engine.ts`)
- Over/Under strategy → Deriv client: uses market services (evidence: `artifacts/api-server/src/lib/overunder-navigator-engine.ts`)
- Over/Under strategy → Market regimes: checks regimes (evidence: `artifacts/api-server/src/lib/overunder-navigator-engine.ts`)
- Over/Under strategy → Recovery engine: uses recovery (evidence: `artifacts/api-server/src/lib/overunder-navigator-engine.ts`)
- Recovery engine → Browser sessions: scopes recovery (evidence: `artifacts/api-server/src/lib/agents/recovery-engine.ts`)
- Recovery engine → Database: persists state (evidence: `artifacts/api-server/src/lib/agents/recovery-engine.ts`)
- Recovery payout → Deriv client: requests quote (evidence: `artifacts/api-server/src/lib/recovery-payout.ts`)
- Recovery payout → Database: uses fallback schedule
- Browser sessions → Database: reads session links (evidence: `artifacts/api-server/src/lib/session.ts`)
- Deriv client → Deriv trading service: connects WebSocket
- Kill-Shot strategy → Event stream: broadcasts updates (evidence: `artifacts/api-server/src/lib/killshot-engine.ts`)
- NeuroAI FAB → Logging: logs activity (evidence: `artifacts/api-server/src/lib/speed-ai-engine.ts`)
