# murad24-cuper/tradingbot-server architecture

> Architecture diagram of the GitHub repository murad24-cuper/tradingbot-server, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/murad24-cuper/tradingbot-server
- Repository: https://github.com/murad24-cuper/tradingbot-server

## Overview

XM MT5 Trading Bot is a single-owner, locally run trading system with a localhost dashboard. Its main workflow scans discovered broker symbols, filters and analyzes movers, applies trade and risk rules, and manages orders through the local MT5 terminal; SQLite records decisions and trades. Separate product branches provide dashboard-based monitoring and queued controls, historical backtesting, and research/brain evaluation. The README documents the workflow and capabilities; many implementation files were not sampled, so only documented relationships are shown.

Main entry points: [`src/bot.py`](https://github.com/murad24-cuper/tradingbot-server/blob/main/src/bot.py) (Bot runtime), [`src/dashboard/app.py`](https://github.com/murad24-cuper/tradingbot-server/blob/main/src/dashboard/app.py) (Trading dashboard), [`src/backtest/engine.py`](https://github.com/murad24-cuper/tradingbot-server/blob/main/src/backtest/engine.py) (Backtest simulator), [`src/scanner.py`](https://github.com/murad24-cuper/tradingbot-server/blob/main/src/scanner.py) (Symbol scanner)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_trading["Live trading"]
  node_bot["Bot runtime<br/>[bot.py]"]
  node_scanner["Symbol scanner<br/>[scanner.py]"]
  node_rules["Trade and risk rules<br/>[risk.py]"]
  node_executor["Order execution<br/>[executor.py]"]
  node_trade_db[("Trade records<br/>[db.py]")]
end

subgraph group_market["Market analysis"]
  node_market_data["Broker market data<br/>[market_data.py]"]
  node_indicators["Technical indicators<br/>[indicators.py]"]
  node_strategies["Signal strategies"]
end

subgraph group_dashboard["Dashboard"]
  node_dashboard_app["Trading dashboard<br/>[app.py]"]
  node_queries["Dashboard queries<br/>[queries.py]"]
  node_settings["Settings editor<br/>[settings_editor.py]"]
  node_commands["Queued bot commands<br/>[commands.py]"]
end

subgraph group_research["Research"]
  node_backtest["Backtest simulator<br/>[engine.py]"]
  node_backtest_report["Backtest reports<br/>[report.py]"]
  node_brain["Brain evaluation"]
  node_time_machine["Historical time machine<br/>[time_machine.py]"]
  node_history["Historical market data<br/>[history.py]"]
end

node_owner(("Bot owner"))
node_mt5["Local MT5 terminal"]

node_owner -->|"starts and controls"| node_bot
node_bot -->|"scans symbols"| node_scanner
node_scanner -->|"checks market data"| node_market_data
node_scanner -->|"analyzes movers"| node_strategies
node_bot -->|"filters entries"| node_rules
node_bot -->|"manages orders"| node_executor
node_executor -->|"sends orders"| node_mt5
node_bot -->|"records decisions and trades"| node_trade_db
node_market_data -->|"gets broker data"| node_mt5
node_strategies -->|"uses indicators"| node_indicators
node_owner -->|"monitors and controls"| node_dashboard_app
node_dashboard_app -->|"reads dashboard data"| node_queries
node_dashboard_app -->|"edits settings"| node_settings
node_dashboard_app -->|"queues commands"| node_commands
node_dashboard_app -->|"reads trade records"| node_trade_db
node_backtest -->|"simulates market data"| node_market_data
node_backtest -->|"applies risk checks"| node_rules
node_backtest -->|"evaluates strategies"| node_strategies
node_backtest_report -.->|"reports results"| node_backtest
node_brain -.->|"uses historical data"| node_history
node_time_machine -->|"reads historical paths"| node_history

click node_bot "https://github.com/murad24-cuper/tradingbot-server/blob/main/src/bot.py"
click node_scanner "https://github.com/murad24-cuper/tradingbot-server/blob/main/src/scanner.py"
click node_rules "https://github.com/murad24-cuper/tradingbot-server/blob/main/src/risk.py"
click node_executor "https://github.com/murad24-cuper/tradingbot-server/blob/main/src/executor.py"
click node_trade_db "https://github.com/murad24-cuper/tradingbot-server/blob/main/src/db.py"
click node_market_data "https://github.com/murad24-cuper/tradingbot-server/blob/main/src/market_data.py"
click node_indicators "https://github.com/murad24-cuper/tradingbot-server/blob/main/src/indicators.py"
click node_strategies "https://github.com/murad24-cuper/tradingbot-server/tree/main/src/strategies"
click node_dashboard_app "https://github.com/murad24-cuper/tradingbot-server/blob/main/src/dashboard/app.py"
click node_queries "https://github.com/murad24-cuper/tradingbot-server/blob/main/src/dashboard/queries.py"
click node_settings "https://github.com/murad24-cuper/tradingbot-server/blob/main/src/dashboard/settings_editor.py"
click node_commands "https://github.com/murad24-cuper/tradingbot-server/blob/main/src/commands.py"
click node_backtest "https://github.com/murad24-cuper/tradingbot-server/blob/main/src/backtest/engine.py"
click node_backtest_report "https://github.com/murad24-cuper/tradingbot-server/blob/main/src/backtest/report.py"
click node_brain "https://github.com/murad24-cuper/tradingbot-server/tree/main/src/brain"
click node_time_machine "https://github.com/murad24-cuper/tradingbot-server/blob/main/src/research/time_machine.py"
click node_history "https://github.com/murad24-cuper/tradingbot-server/blob/main/src/history.py"

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_bot,node_scanner,node_rules,node_executor,node_trade_db toneBlue
class node_market_data,node_indicators,node_strategies toneAmber
class node_dashboard_app,node_queries,node_settings,node_commands toneMint
class node_backtest,node_backtest_report,node_brain,node_time_machine,node_history toneRose
class node_owner,node_mt5 toneIndigo
```

## Components

### Live trading

- [Bot runtime](https://github.com/murad24-cuper/tradingbot-server/blob/main/src/bot.py): `src/bot.py`
- [Symbol scanner](https://github.com/murad24-cuper/tradingbot-server/blob/main/src/scanner.py): `src/scanner.py`
- [Trade and risk rules](https://github.com/murad24-cuper/tradingbot-server/blob/main/src/risk.py): `src/risk.py`
- [Order execution](https://github.com/murad24-cuper/tradingbot-server/blob/main/src/executor.py): `src/executor.py`
- [Trade records](https://github.com/murad24-cuper/tradingbot-server/blob/main/src/db.py): `src/db.py`

### Market analysis

- [Broker market data](https://github.com/murad24-cuper/tradingbot-server/blob/main/src/market_data.py): `src/market_data.py`
- [Technical indicators](https://github.com/murad24-cuper/tradingbot-server/blob/main/src/indicators.py): `src/indicators.py`
- [Signal strategies](https://github.com/murad24-cuper/tradingbot-server/tree/main/src/strategies): `src/strategies`

### Dashboard

- [Trading dashboard](https://github.com/murad24-cuper/tradingbot-server/blob/main/src/dashboard/app.py): `src/dashboard/app.py`
- [Dashboard queries](https://github.com/murad24-cuper/tradingbot-server/blob/main/src/dashboard/queries.py): `src/dashboard/queries.py`
- [Settings editor](https://github.com/murad24-cuper/tradingbot-server/blob/main/src/dashboard/settings_editor.py): `src/dashboard/settings_editor.py`
- [Queued bot commands](https://github.com/murad24-cuper/tradingbot-server/blob/main/src/commands.py): `src/commands.py`

### Research

- [Backtest simulator](https://github.com/murad24-cuper/tradingbot-server/blob/main/src/backtest/engine.py): `src/backtest/engine.py`
- [Backtest reports](https://github.com/murad24-cuper/tradingbot-server/blob/main/src/backtest/report.py): `src/backtest/report.py`
- [Brain evaluation](https://github.com/murad24-cuper/tradingbot-server/tree/main/src/brain): `src/brain`
- [Historical time machine](https://github.com/murad24-cuper/tradingbot-server/blob/main/src/research/time_machine.py): `src/research/time_machine.py`
- [Historical market data](https://github.com/murad24-cuper/tradingbot-server/blob/main/src/history.py): `src/history.py`

### Other components

- **Bot owner**
- **Local MT5 terminal**

## Connections

- Bot owner → Bot runtime: starts and controls (evidence: `README.md`)
- Bot runtime → Symbol scanner: scans symbols (evidence: `README.md`)
- Symbol scanner → Broker market data: checks market data (evidence: `README.md`)
- Symbol scanner → Signal strategies: analyzes movers (evidence: `README.md`)
- Bot runtime → Trade and risk rules: filters entries (evidence: `README.md`)
- Bot runtime → Order execution: manages orders (evidence: `README.md`)
- Order execution → Local MT5 terminal: sends orders (evidence: `README.md`)
- Bot runtime → Trade records: records decisions and trades (evidence: `README.md`)
- Broker market data → Local MT5 terminal: gets broker data (evidence: `README.md`)
- Signal strategies → Technical indicators: uses indicators (evidence: `src/strategies/research_families.py`)
- Bot owner → Trading dashboard: monitors and controls (evidence: `README.md`)
- Trading dashboard → Dashboard queries: reads dashboard data (evidence: `src/dashboard/app.py`)
- Trading dashboard → Settings editor: edits settings (evidence: `src/dashboard/app.py`)
- Trading dashboard → Queued bot commands: queues commands (evidence: `README.md`)
- Trading dashboard → Trade records: reads trade records (evidence: `src/dashboard/app.py`)
- Backtest simulator → Broker market data: simulates market data (evidence: `src/backtest/engine.py`)
- Backtest simulator → Trade and risk rules: applies risk checks (evidence: `src/backtest/engine.py`)
- Backtest simulator → Signal strategies: evaluates strategies (evidence: `src/backtest/engine.py`)
- Backtest reports → Backtest simulator: reports results
- Brain evaluation → Historical market data: uses historical data
- Historical time machine → Historical market data: reads historical paths (evidence: `src/research/time_machine.py`)
