# foolahmad556-rgb/quantum-bot-usb architecture

> Architecture diagram of the GitHub repository foolahmad556-rgb/quantum-bot-usb, 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/foolahmad556-rgb/quantum-bot-usb
- Repository: https://github.com/foolahmad556-rgb/quantum-bot-usb

## Overview

This is a trading application with a React operator dashboard and a TypeScript trading runtime. Operators inspect live status, manage positions and controls, and configure strategies; the runtime coordinates market analysis, decisions, risk checks, and order execution. The repository also includes portfolio optimization, historical backtesting, persistence, authentication, and notifications. The excerpts establish several imports and selected calls, but do not show the full runtime wiring, so unverified pipeline relationships are dashed.

Main entry points: [`src/app/TradingPipeline.ts`](https://github.com/foolahmad556-rgb/quantum-bot-usb/blob/master/src/app/TradingPipeline.ts) (Trading orchestrator), [`src/App.tsx`](https://github.com/foolahmad556-rgb/quantum-bot-usb/blob/master/src/App.tsx) (Dashboard app), [`src/features/FeatureEngine.ts`](https://github.com/foolahmad556-rgb/quantum-bot-usb/blob/master/src/features/FeatureEngine.ts) (Feature engine), [`src/strategies/StrategyManager.ts`](https://github.com/foolahmad556-rgb/quantum-bot-usb/blob/master/src/strategies/StrategyManager.ts) (Strategy manager)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Operator interface"]
  node_app["Dashboard app<br/>[App.tsx]"]
  node_pair["Market selector"]
  node_boardui["Board controls"]
  node_riskui["Risk view<br/>[RiskEngineView.tsx]"]
  node_strategyui["Strategy view"]
end

subgraph group_runtime["Trading runtime"]
  node_pipeline["Trading orchestrator<br/>[TradingPipeline.ts]"]
end

subgraph group_analysis["Signals and portfolio"]
  node_features["Feature engine<br/>[FeatureEngine.ts]"]
  node_regime["Regime detector<br/>[RegimeDetector.ts]"]
  node_strategies["Strategy manager<br/>[StrategyManager.ts]"]
  node_decision["Decision engine<br/>[DecisionEngine.ts]"]
  node_board["Board engine"]
  node_portfolio["QUBO portfolio<br/>[QuboPortfolio.ts]"]
  node_backtest["Backtest engine<br/>[BacktestEngine.ts]"]
end

subgraph group_execution["Market, risk, execution"]
  node_market["Exchange market data"]
  node_book["Order book builder"]
  node_screener["Asset screener<br/>[AssetScreener.ts]"]
  node_risk["Risk engine<br/>[RiskEngine.ts]"]
  node_sizer["Portfolio sizer<br/>[PortfolioSizer.ts]"]
  node_gateway["Order gateway<br/>[OrderGateway.ts]"]
  node_stream["User data stream<br/>[UserDataStream.ts]"]
end

subgraph group_support["Data and integrations"]
  node_database[("Trade database<br/>[DatabaseService.ts]")]
  node_auth["Authentication<br/>[AuthContext.tsx]"]
  node_api["Authenticated API client<br/>[api.ts]"]
  node_telegram["Telegram service<br/>[TelegramService.ts]"]
end

node_operator(("Operator"))
node_external{{"Exchange"}}

node_operator -->|"operates"| node_app
node_app -->|"renders"| node_pair
node_app -->|"renders"| node_boardui
node_app -->|"uses"| node_auth
node_app -->|"fetches status"| node_api
node_app -->|"requests position close"| node_api
node_strategyui -->|"uses"| node_api
node_strategyui -->|"uses"| node_strategies
node_features -->|"imports"| node_regime
node_features -->|"imports"| node_portfolio
node_features -.->|"analyzes regime"| node_regime
node_strategies -->|"calls decide"| node_decision
node_strategies -.->|"evaluates features"| node_features
node_strategies -.->|"uses regime"| node_regime
node_boardui -->|"syncs learning"| node_board
node_risk -->|"uses sizing"| node_sizer
node_portfolio -.->|"provides allocations"| node_pipeline
node_pipeline -.->|"coordinates market data"| node_market
node_pipeline -.->|"requests features"| node_features
node_pipeline -.->|"requests signals"| node_strategies
node_pipeline -.->|"coordinates deliberation"| node_board
node_pipeline -->|"updates limits"| node_risk
node_pipeline -.->|"coordinates orders"| node_gateway
node_gateway -->|"uses book"| node_book
node_gateway -.->|"routes orders"| node_external
node_external -.->|"supplies market data"| node_market
node_external -.->|"sends order updates"| node_stream
node_pipeline -.->|"coordinates updates"| node_stream
node_backtest -->|"uses features"| node_features
node_backtest -->|"uses decisions"| node_decision
node_backtest -->|"uses storage"| node_database
node_app -.->|"shows risk"| node_riskui
node_pipeline -.->|"persists trading state"| node_database
node_pipeline -.->|"sends notifications"| node_telegram

click node_app "https://github.com/foolahmad556-rgb/quantum-bot-usb/blob/master/src/App.tsx"
click node_pair "https://github.com/foolahmad556-rgb/quantum-bot-usb/blob/master/src/components/HolographicPairSelector.tsx"
click node_boardui "https://github.com/foolahmad556-rgb/quantum-bot-usb/blob/master/src/components/BoardOfDirectorsTab.tsx"
click node_riskui "https://github.com/foolahmad556-rgb/quantum-bot-usb/blob/master/src/components/RiskEngineView.tsx"
click node_strategyui "https://github.com/foolahmad556-rgb/quantum-bot-usb/blob/master/src/components/StrategyEngineView.tsx"
click node_pipeline "https://github.com/foolahmad556-rgb/quantum-bot-usb/blob/master/src/app/TradingPipeline.ts"
click node_market "https://github.com/foolahmad556-rgb/quantum-bot-usb/blob/master/src/market-data/ExchangeMarketData.ts"
click node_book "https://github.com/foolahmad556-rgb/quantum-bot-usb/blob/master/src/market-data/OrderBookBuilder.ts"
click node_screener "https://github.com/foolahmad556-rgb/quantum-bot-usb/blob/master/src/market-data/AssetScreener.ts"
click node_features "https://github.com/foolahmad556-rgb/quantum-bot-usb/blob/master/src/features/FeatureEngine.ts"
click node_regime "https://github.com/foolahmad556-rgb/quantum-bot-usb/blob/master/src/risk/RegimeDetector.ts"
click node_strategies "https://github.com/foolahmad556-rgb/quantum-bot-usb/blob/master/src/strategies/StrategyManager.ts"
click node_decision "https://github.com/foolahmad556-rgb/quantum-bot-usb/blob/master/src/strategies/DecisionEngine.ts"
click node_board "https://github.com/foolahmad556-rgb/quantum-bot-usb/blob/master/src/strategies/BoardOfDirectorsEngine.ts"
click node_portfolio "https://github.com/foolahmad556-rgb/quantum-bot-usb/blob/master/src/portfolio/QuboPortfolio.ts"
click node_risk "https://github.com/foolahmad556-rgb/quantum-bot-usb/blob/master/src/risk/RiskEngine.ts"
click node_sizer "https://github.com/foolahmad556-rgb/quantum-bot-usb/blob/master/src/risk/PortfolioSizer.ts"
click node_gateway "https://github.com/foolahmad556-rgb/quantum-bot-usb/blob/master/src/execution/OrderGateway.ts"
click node_stream "https://github.com/foolahmad556-rgb/quantum-bot-usb/blob/master/src/execution/UserDataStream.ts"
click node_backtest "https://github.com/foolahmad556-rgb/quantum-bot-usb/blob/master/src/backtest/BacktestEngine.ts"
click node_database "https://github.com/foolahmad556-rgb/quantum-bot-usb/blob/master/src/storage/DatabaseService.ts"
click node_auth "https://github.com/foolahmad556-rgb/quantum-bot-usb/blob/master/src/contexts/AuthContext.tsx"
click node_api "https://github.com/foolahmad556-rgb/quantum-bot-usb/blob/master/src/lib/api.ts"
click node_telegram "https://github.com/foolahmad556-rgb/quantum-bot-usb/blob/master/src/services/TelegramService.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_app,node_pair,node_boardui,node_riskui,node_strategyui toneBlue
class node_pipeline toneAmber
class node_features,node_regime,node_strategies,node_decision,node_board,node_portfolio,node_backtest toneMint
class node_market,node_book,node_screener,node_risk,node_sizer,node_gateway,node_stream toneRose
class node_database,node_auth,node_api,node_telegram,node_operator,node_external toneIndigo
```

## Components

### Operator interface

- [Dashboard app](https://github.com/foolahmad556-rgb/quantum-bot-usb/blob/master/src/App.tsx): `src/App.tsx`
- [Market selector](https://github.com/foolahmad556-rgb/quantum-bot-usb/blob/master/src/components/HolographicPairSelector.tsx): `src/components/HolographicPairSelector.tsx`
- [Board controls](https://github.com/foolahmad556-rgb/quantum-bot-usb/blob/master/src/components/BoardOfDirectorsTab.tsx): `src/components/BoardOfDirectorsTab.tsx`
- [Risk view](https://github.com/foolahmad556-rgb/quantum-bot-usb/blob/master/src/components/RiskEngineView.tsx): `src/components/RiskEngineView.tsx`
- [Strategy view](https://github.com/foolahmad556-rgb/quantum-bot-usb/blob/master/src/components/StrategyEngineView.tsx): `src/components/StrategyEngineView.tsx`

### Trading runtime

- [Trading orchestrator](https://github.com/foolahmad556-rgb/quantum-bot-usb/blob/master/src/app/TradingPipeline.ts): `src/app/TradingPipeline.ts`

### Signals and portfolio

- [Feature engine](https://github.com/foolahmad556-rgb/quantum-bot-usb/blob/master/src/features/FeatureEngine.ts): `src/features/FeatureEngine.ts`
- [Regime detector](https://github.com/foolahmad556-rgb/quantum-bot-usb/blob/master/src/risk/RegimeDetector.ts): `src/risk/RegimeDetector.ts`
- [Strategy manager](https://github.com/foolahmad556-rgb/quantum-bot-usb/blob/master/src/strategies/StrategyManager.ts): `src/strategies/StrategyManager.ts`
- [Decision engine](https://github.com/foolahmad556-rgb/quantum-bot-usb/blob/master/src/strategies/DecisionEngine.ts): `src/strategies/DecisionEngine.ts`
- [Board engine](https://github.com/foolahmad556-rgb/quantum-bot-usb/blob/master/src/strategies/BoardOfDirectorsEngine.ts): `src/strategies/BoardOfDirectorsEngine.ts`
- [QUBO portfolio](https://github.com/foolahmad556-rgb/quantum-bot-usb/blob/master/src/portfolio/QuboPortfolio.ts): `src/portfolio/QuboPortfolio.ts`
- [Backtest engine](https://github.com/foolahmad556-rgb/quantum-bot-usb/blob/master/src/backtest/BacktestEngine.ts): `src/backtest/BacktestEngine.ts`

### Market, risk, execution

- [Exchange market data](https://github.com/foolahmad556-rgb/quantum-bot-usb/blob/master/src/market-data/ExchangeMarketData.ts): `src/market-data/ExchangeMarketData.ts`
- [Order book builder](https://github.com/foolahmad556-rgb/quantum-bot-usb/blob/master/src/market-data/OrderBookBuilder.ts): `src/market-data/OrderBookBuilder.ts`
- [Asset screener](https://github.com/foolahmad556-rgb/quantum-bot-usb/blob/master/src/market-data/AssetScreener.ts): `src/market-data/AssetScreener.ts`
- [Risk engine](https://github.com/foolahmad556-rgb/quantum-bot-usb/blob/master/src/risk/RiskEngine.ts): `src/risk/RiskEngine.ts`
- [Portfolio sizer](https://github.com/foolahmad556-rgb/quantum-bot-usb/blob/master/src/risk/PortfolioSizer.ts): `src/risk/PortfolioSizer.ts`
- [Order gateway](https://github.com/foolahmad556-rgb/quantum-bot-usb/blob/master/src/execution/OrderGateway.ts): `src/execution/OrderGateway.ts`
- [User data stream](https://github.com/foolahmad556-rgb/quantum-bot-usb/blob/master/src/execution/UserDataStream.ts): `src/execution/UserDataStream.ts`

### Data and integrations

- [Trade database](https://github.com/foolahmad556-rgb/quantum-bot-usb/blob/master/src/storage/DatabaseService.ts): `src/storage/DatabaseService.ts`
- [Authentication](https://github.com/foolahmad556-rgb/quantum-bot-usb/blob/master/src/contexts/AuthContext.tsx): `src/contexts/AuthContext.tsx`
- [Authenticated API client](https://github.com/foolahmad556-rgb/quantum-bot-usb/blob/master/src/lib/api.ts): `src/lib/api.ts`
- [Telegram service](https://github.com/foolahmad556-rgb/quantum-bot-usb/blob/master/src/services/TelegramService.ts): `src/services/TelegramService.ts`

### Other components

- **Operator**
- **Exchange**

## Connections

- Operator → Dashboard app: operates
- Dashboard app → Market selector: renders (evidence: `src/App.tsx`)
- Dashboard app → Board controls: renders (evidence: `src/App.tsx`)
- Dashboard app → Authentication: uses (evidence: `src/App.tsx`)
- Dashboard app → Authenticated API client: fetches status (evidence: `src/App.tsx`)
- Dashboard app → Authenticated API client: requests position close (evidence: `src/App.tsx`)
- Strategy view → Authenticated API client: uses (evidence: `src/components/StrategyEngineView.tsx`)
- Strategy view → Strategy manager: uses (evidence: `src/components/StrategyEngineView.tsx`)
- Feature engine → Regime detector: imports (evidence: `src/features/FeatureEngine.ts`)
- Feature engine → QUBO portfolio: imports (evidence: `src/features/FeatureEngine.ts`)
- Feature engine → Regime detector: analyzes regime (evidence: `src/features/FeatureEngine.ts`)
- Strategy manager → Decision engine: calls decide (evidence: `src/strategies/StrategyManager.ts`)
- Strategy manager → Feature engine: evaluates features (evidence: `src/strategies/StrategyManager.ts`)
- Strategy manager → Regime detector: uses regime (evidence: `src/strategies/StrategyManager.ts`)
- Board controls → Board engine: syncs learning (evidence: `src/components/BoardOfDirectorsTab.tsx`)
- Risk engine → Portfolio sizer: uses sizing (evidence: `src/risk/RiskEngine.ts`)
- QUBO portfolio → Trading orchestrator: provides allocations (evidence: `src/app/TradingPipeline.ts`)
- Trading orchestrator → Exchange market data: coordinates market data (evidence: `src/app/TradingPipeline.ts`)
- Trading orchestrator → Feature engine: requests features (evidence: `src/app/TradingPipeline.ts`)
- Trading orchestrator → Strategy manager: requests signals (evidence: `src/app/TradingPipeline.ts`)
- Trading orchestrator → Board engine: coordinates deliberation (evidence: `src/app/TradingPipeline.ts`)
- Trading orchestrator → Risk engine: updates limits (evidence: `src/app/TradingPipeline.ts`)
- Trading orchestrator → Order gateway: coordinates orders (evidence: `src/app/TradingPipeline.ts`)
- Order gateway → Order book builder: uses book (evidence: `src/execution/OrderGateway.ts`)
- Order gateway → Exchange: routes orders
- Exchange → Exchange market data: supplies market data
- Exchange → User data stream: sends order updates
- Trading orchestrator → User data stream: coordinates updates (evidence: `src/app/TradingPipeline.ts`)
- Backtest engine → Feature engine: uses features (evidence: `src/backtest/BacktestEngine.ts`)
- Backtest engine → Decision engine: uses decisions (evidence: `src/backtest/BacktestEngine.ts`)
- Backtest engine → Trade database: uses storage (evidence: `src/backtest/BacktestEngine.ts`)
- Dashboard app → Risk view: shows risk
- Trading orchestrator → Trade database: persists trading state (evidence: `src/app/TradingPipeline.ts`)
- Trading orchestrator → Telegram service: sends notifications (evidence: `src/app/TradingPipeline.ts`)
