# ralphtradesz/trading-hub architecture

> Architecture diagram of the GitHub repository ralphtradesz/trading-hub, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ralphtradesz/trading-hub
- Repository: https://github.com/ralphtradesz/trading-hub

## Overview

Trading Hub is a local desktop trading platform: users connect market data or load history, inspect charts and trade, then author strategies, test and optimize them, and optionally run them live. The graph preserves the documented data, charting, execution, strategy-validation, live-risk, and Claude lab capabilities. Source evidence is limited to the supplied excerpts, SOURCE INDEX references, and README; unsampled subsystem links are omitted or marked unverified.

Main entry points: [`src/TradingHub.Strategies/BacktestEngine.cs`](https://github.com/ralphtradesz/trading-hub/blob/main/src/TradingHub.Strategies/BacktestEngine.cs) (Backtesting), [`src/TradingHub.App/Lab/LabServer.cs`](https://github.com/ralphtradesz/trading-hub/blob/main/src/TradingHub.App/Lab/LabServer.cs) (Research lab server), [`src/TradingHub.App/Views/StrategiesView.cs`](https://github.com/ralphtradesz/trading-hub/blob/main/src/TradingHub.App/Views/StrategiesView.cs) (Strategy views), [`src/TradingHub.App/App.cs`](https://github.com/ralphtradesz/trading-hub/blob/main/src/TradingHub.App/App.cs) (Desktop app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Desktop experience"]
  node_app["Desktop app<br/>[App.cs]"]
  node_app_services["App services<br/>[AppServices.cs]"]
  node_trading_views["Trading views<br/>[TradingView.cs]"]
  node_strategy_views["Strategy views<br/>[StrategiesView.cs]"]
  node_chart_controller["Chart controller<br/>[ChartController.cs]"]
  node_chart_renderer["Chart renderer<br/>[ChartRenderer.cs]"]
  node_chart_drawing["Chart drawings<br/>[ChartDrawing.cs]"]
  node_render_context["Render context<br/>[RenderContext.cs]"]
end

subgraph group_market["Markets and trading"]
  node_market_feeds["Market feeds<br/>[Feeds]"]
  node_history_data[("Market history<br/>[InstrumentData.cs]")]
  node_instrument["Instrument model<br/>[Instrument.cs]"]
  node_execution["Trading accounts<br/>[ITradingAccount.cs]"]
  node_brackets["Order brackets<br/>[Brackets.cs]"]
end

subgraph group_research["Strategy research"]
  node_strategy["Strategy API<br/>[Strategy.cs]"]
  node_backtest["Backtesting<br/>[BacktestEngine.cs]"]
  node_market_context["Market context<br/>[MarketContext.cs]"]
  node_optimization["Optimization<br/>[Optimization.cs]"]
  node_robustness["Robustness analysis<br/>[Robustness.cs]"]
  node_script_compiler["C&#35; script compiler<br/>[ScriptCompiler.cs]"]
end

subgraph group_automation["Automation and AI"]
  node_live_runner["Live strategy runner"]
  node_live_portfolio["Live portfolios<br/>[LivePortfolio.cs]"]
  node_risk_agent["Live risk agent<br/>[LiveRiskAgent.cs]"]
  node_claude_agent["Claude assistant<br/>[ClaudeAgent.cs]"]
  node_lab_server["Research lab server<br/>[LabServer.cs]"]
  node_report_builder["Lab reports<br/>[ReportBuilder.cs]"]
end

node_user(("Trader"))
node_broker_services["Broker services"]
node_claude_code["Claude Code"]

node_user -->|"uses"| node_app
node_app -->|"creates"| node_app_services
node_app -.->|"opens"| node_trading_views
node_app_services -->|"manages"| node_market_feeds
node_app_services -->|"opens replay"| node_history_data
node_app_services -->|"provides"| node_execution
node_market_feeds -.->|"supplies data"| node_history_data
node_market_feeds -.->|"connects"| node_broker_services
node_trading_views -.->|"controls"| node_chart_controller
node_chart_controller -->|"renders through"| node_chart_renderer
node_chart_renderer -->|"renders"| node_chart_drawing
node_chart_renderer -->|"draws with"| node_render_context
node_strategy_views -.->|"runs"| node_backtest
node_strategy_views -.->|"optimizes"| node_optimization
node_strategy_views -.->|"compiles"| node_script_compiler
node_script_compiler -->|"builds"| node_strategy
node_backtest -->|"executes"| node_strategy
node_backtest -.->|"reads ticks"| node_history_data
node_strategy -->|"tracks context"| node_market_context
node_optimization -.->|"evaluates"| node_backtest
node_robustness -.->|"validates"| node_backtest
node_strategy_views -.->|"launches"| node_live_runner
node_live_runner -.->|"submits orders"| node_execution
node_live_portfolio -.->|"coordinates"| node_live_runner
node_risk_agent -.->|"sizes risk"| node_live_portfolio
node_app -->|"hosts"| node_lab_server
node_claude_code -->|"requests research"| node_lab_server
node_lab_server -->|"runs studies"| node_backtest
node_lab_server -.->|"runs studies"| node_optimization
node_lab_server -.->|"builds reports"| node_report_builder
node_claude_agent -.->|"uses subscription"| node_claude_code

click node_app "https://github.com/ralphtradesz/trading-hub/blob/main/src/TradingHub.App/App.cs"
click node_app_services "https://github.com/ralphtradesz/trading-hub/blob/main/src/TradingHub.App/Services/AppServices.cs"
click node_trading_views "https://github.com/ralphtradesz/trading-hub/blob/main/src/TradingHub.App/Views/TradingView.cs"
click node_strategy_views "https://github.com/ralphtradesz/trading-hub/blob/main/src/TradingHub.App/Views/StrategiesView.cs"
click node_chart_controller "https://github.com/ralphtradesz/trading-hub/blob/main/src/TradingHub.Charting/ChartController.cs"
click node_chart_renderer "https://github.com/ralphtradesz/trading-hub/blob/main/src/TradingHub.Charting/Rendering/ChartRenderer.cs"
click node_chart_drawing "https://github.com/ralphtradesz/trading-hub/blob/main/src/TradingHub.Charting/Drawings/ChartDrawing.cs"
click node_render_context "https://github.com/ralphtradesz/trading-hub/blob/main/src/TradingHub.Sdk/Rendering/RenderContext.cs"
click node_market_feeds "https://github.com/ralphtradesz/trading-hub/tree/main/src/TradingHub.Core/Feeds"
click node_history_data "https://github.com/ralphtradesz/trading-hub/blob/main/src/TradingHub.Core/Data/InstrumentData.cs"
click node_instrument "https://github.com/ralphtradesz/trading-hub/blob/main/src/TradingHub.Core/Market/Instrument.cs"
click node_execution "https://github.com/ralphtradesz/trading-hub/blob/main/src/TradingHub.Core/Trading/ITradingAccount.cs"
click node_brackets "https://github.com/ralphtradesz/trading-hub/blob/main/src/TradingHub.Core/Trading/Brackets.cs"
click node_strategy "https://github.com/ralphtradesz/trading-hub/blob/main/src/TradingHub.Strategies/Strategy.cs"
click node_backtest "https://github.com/ralphtradesz/trading-hub/blob/main/src/TradingHub.Strategies/BacktestEngine.cs"
click node_market_context "https://github.com/ralphtradesz/trading-hub/blob/main/src/TradingHub.Strategies/MarketContext.cs"
click node_optimization "https://github.com/ralphtradesz/trading-hub/blob/main/src/TradingHub.Strategies/Optimization.cs"
click node_robustness "https://github.com/ralphtradesz/trading-hub/blob/main/src/TradingHub.Strategies/Robustness.cs"
click node_script_compiler "https://github.com/ralphtradesz/trading-hub/blob/main/src/TradingHub.Scripting/ScriptCompiler.cs"
click node_live_runner "https://github.com/ralphtradesz/trading-hub/blob/main/src/TradingHub.Strategies/LiveStrategyRunner.cs"
click node_live_portfolio "https://github.com/ralphtradesz/trading-hub/blob/main/src/TradingHub.Strategies/LivePortfolio.cs"
click node_risk_agent "https://github.com/ralphtradesz/trading-hub/blob/main/src/TradingHub.App/Services/LiveRiskAgent.cs"
click node_claude_agent "https://github.com/ralphtradesz/trading-hub/blob/main/src/TradingHub.App/Services/ClaudeAgent.cs"
click node_lab_server "https://github.com/ralphtradesz/trading-hub/blob/main/src/TradingHub.App/Lab/LabServer.cs"
click node_report_builder "https://github.com/ralphtradesz/trading-hub/blob/main/src/TradingHub.App/Lab/ReportBuilder.cs"

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_app_services,node_trading_views,node_strategy_views,node_chart_controller,node_chart_renderer,node_chart_drawing,node_render_context toneBlue
class node_market_feeds,node_history_data,node_instrument,node_execution,node_brackets toneAmber
class node_strategy,node_backtest,node_market_context,node_optimization,node_robustness,node_script_compiler toneMint
class node_live_runner,node_live_portfolio,node_risk_agent,node_claude_agent,node_lab_server,node_report_builder toneRose
class node_user,node_broker_services,node_claude_code toneIndigo
```

## Components

### Desktop experience

- [Desktop app](https://github.com/ralphtradesz/trading-hub/blob/main/src/TradingHub.App/App.cs): `src/TradingHub.App/App.cs`
- [App services](https://github.com/ralphtradesz/trading-hub/blob/main/src/TradingHub.App/Services/AppServices.cs): `src/TradingHub.App/Services/AppServices.cs`
- [Trading views](https://github.com/ralphtradesz/trading-hub/blob/main/src/TradingHub.App/Views/TradingView.cs): `src/TradingHub.App/Views/TradingView.cs`
- [Strategy views](https://github.com/ralphtradesz/trading-hub/blob/main/src/TradingHub.App/Views/StrategiesView.cs): `src/TradingHub.App/Views/StrategiesView.cs`
- [Chart controller](https://github.com/ralphtradesz/trading-hub/blob/main/src/TradingHub.Charting/ChartController.cs): `src/TradingHub.Charting/ChartController.cs`
- [Chart renderer](https://github.com/ralphtradesz/trading-hub/blob/main/src/TradingHub.Charting/Rendering/ChartRenderer.cs): `src/TradingHub.Charting/Rendering/ChartRenderer.cs`
- [Chart drawings](https://github.com/ralphtradesz/trading-hub/blob/main/src/TradingHub.Charting/Drawings/ChartDrawing.cs): `src/TradingHub.Charting/Drawings/ChartDrawing.cs`
- [Render context](https://github.com/ralphtradesz/trading-hub/blob/main/src/TradingHub.Sdk/Rendering/RenderContext.cs): `src/TradingHub.Sdk/Rendering/RenderContext.cs`

### Markets and trading

- [Market feeds](https://github.com/ralphtradesz/trading-hub/tree/main/src/TradingHub.Core/Feeds): `src/TradingHub.Core/Feeds`
- [Market history](https://github.com/ralphtradesz/trading-hub/blob/main/src/TradingHub.Core/Data/InstrumentData.cs): `src/TradingHub.Core/Data/InstrumentData.cs`
- [Instrument model](https://github.com/ralphtradesz/trading-hub/blob/main/src/TradingHub.Core/Market/Instrument.cs): `src/TradingHub.Core/Market/Instrument.cs`
- [Trading accounts](https://github.com/ralphtradesz/trading-hub/blob/main/src/TradingHub.Core/Trading/ITradingAccount.cs): `src/TradingHub.Core/Trading/ITradingAccount.cs`
- [Order brackets](https://github.com/ralphtradesz/trading-hub/blob/main/src/TradingHub.Core/Trading/Brackets.cs): `src/TradingHub.Core/Trading/Brackets.cs`

### Strategy research

- [Strategy API](https://github.com/ralphtradesz/trading-hub/blob/main/src/TradingHub.Strategies/Strategy.cs): `src/TradingHub.Strategies/Strategy.cs`
- [Backtesting](https://github.com/ralphtradesz/trading-hub/blob/main/src/TradingHub.Strategies/BacktestEngine.cs): `src/TradingHub.Strategies/BacktestEngine.cs`
- [Market context](https://github.com/ralphtradesz/trading-hub/blob/main/src/TradingHub.Strategies/MarketContext.cs): `src/TradingHub.Strategies/MarketContext.cs`
- [Optimization](https://github.com/ralphtradesz/trading-hub/blob/main/src/TradingHub.Strategies/Optimization.cs): `src/TradingHub.Strategies/Optimization.cs`
- [Robustness analysis](https://github.com/ralphtradesz/trading-hub/blob/main/src/TradingHub.Strategies/Robustness.cs): `src/TradingHub.Strategies/Robustness.cs`
- [C# script compiler](https://github.com/ralphtradesz/trading-hub/blob/main/src/TradingHub.Scripting/ScriptCompiler.cs): `src/TradingHub.Scripting/ScriptCompiler.cs`

### Automation and AI

- [Live strategy runner](https://github.com/ralphtradesz/trading-hub/blob/main/src/TradingHub.Strategies/LiveStrategyRunner.cs): `src/TradingHub.Strategies/LiveStrategyRunner.cs`
- [Live portfolios](https://github.com/ralphtradesz/trading-hub/blob/main/src/TradingHub.Strategies/LivePortfolio.cs): `src/TradingHub.Strategies/LivePortfolio.cs`
- [Live risk agent](https://github.com/ralphtradesz/trading-hub/blob/main/src/TradingHub.App/Services/LiveRiskAgent.cs): `src/TradingHub.App/Services/LiveRiskAgent.cs`
- [Claude assistant](https://github.com/ralphtradesz/trading-hub/blob/main/src/TradingHub.App/Services/ClaudeAgent.cs): `src/TradingHub.App/Services/ClaudeAgent.cs`
- [Research lab server](https://github.com/ralphtradesz/trading-hub/blob/main/src/TradingHub.App/Lab/LabServer.cs): `src/TradingHub.App/Lab/LabServer.cs`
- [Lab reports](https://github.com/ralphtradesz/trading-hub/blob/main/src/TradingHub.App/Lab/ReportBuilder.cs): `src/TradingHub.App/Lab/ReportBuilder.cs`

### Other components

- **Trader**
- **Broker services**
- **Claude Code**

## Connections

- Trader → Desktop app: uses (evidence: `src/TradingHub.App/App.cs`)
- Desktop app → App services: creates (evidence: `src/TradingHub.App/App.cs`)
- Desktop app → Trading views: opens
- App services → Market feeds: manages (evidence: `src/TradingHub.App/Services/AppServices.cs`)
- App services → Market history: opens replay (evidence: `src/TradingHub.App/Services/AppServices.cs`)
- App services → Trading accounts: provides (evidence: `src/TradingHub.App/Services/AppServices.cs`)
- Market feeds → Market history: supplies data
- Market feeds → Broker services: connects
- Trading views → Chart controller: controls
- Chart controller → Chart renderer: renders through (evidence: `src/TradingHub.Charting/ChartController.cs`)
- Chart renderer → Chart drawings: renders (evidence: `src/TradingHub.Charting/Rendering/ChartRenderer.cs`)
- Chart renderer → Render context: draws with (evidence: `src/TradingHub.Charting/Rendering/ChartRenderer.cs`)
- Strategy views → Backtesting: runs
- Strategy views → Optimization: optimizes
- Strategy views → C# script compiler: compiles
- C# script compiler → Strategy API: builds (evidence: `src/TradingHub.Scripting/ScriptCompiler.cs`)
- Backtesting → Strategy API: executes (evidence: `src/TradingHub.Strategies/BacktestEngine.cs`)
- Backtesting → Market history: reads ticks
- Strategy API → Market context: tracks context (evidence: `src/TradingHub.Strategies/Strategy.cs`)
- Optimization → Backtesting: evaluates
- Robustness analysis → Backtesting: validates
- Strategy views → Live strategy runner: launches
- Live strategy runner → Trading accounts: submits orders
- Live portfolios → Live strategy runner: coordinates
- Live risk agent → Live portfolios: sizes risk
- Desktop app → Research lab server: hosts (evidence: `src/TradingHub.App/Lab/LabServer.cs`)
- Claude Code → Research lab server: requests research (evidence: `src/TradingHub.App/Lab/LabServer.cs`)
- Research lab server → Backtesting: runs studies (evidence: `src/TradingHub.App/Lab/LabServer.cs`)
- Research lab server → Optimization: runs studies (evidence: `src/TradingHub.App/Lab/LabServer.cs`)
- Research lab server → Lab reports: builds reports (evidence: `src/TradingHub.App/Lab/LabServer.cs`)
- Claude assistant → Claude Code: uses subscription
