From 1844b4150a6ab5ccac6dd2376185f3c1549fc686 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Mar 2026 12:23:40 +0000 Subject: [PATCH 1/3] Add Mermaid architecture diagram to README Show the request flow from HTTP clients through middleware layers (CORS, logging, error handling, rate limiting, auth) into the router endpoints, the shared MT5 client singleton, and down to the MetaTrader 5 terminal via pdmt5. https://claude.ai/code/session_01YNwrPB3iN3JWpkVgM5XwVQ --- README.md | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/README.md b/README.md index 5c35760..9cbd64e 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,46 @@ The API server must run on Windows. The `MetaTrader5` Python package used by machine with a logged-in MetaTrader 5 terminal. HTTP clients can connect from any operating system. +## Architecture + +```mermaid +graph TB + Client["HTTP Client
(Any OS)"] + + subgraph "Windows Host" + subgraph "FastAPI Application" + Main["main.py
App Wiring & Lifespan"] + Main --> CORS["CORS Middleware"] + CORS --> Logging["Logging Middleware"] + Logging --> Error["Error Handler Middleware"] + Error --> RateLimit["Rate Limiter
(SlowAPI)"] + RateLimit --> Auth["API Key Auth
(Optional)"] + + Auth --> HealthRouter["health.py
/health, /version, /last-error"] + Auth --> SymbolsRouter["symbols.py
/symbols, /symbols/{symbol}"] + Auth --> MarketRouter["market.py
/rates, /ticks, /market-book"] + Auth --> AccountRouter["account.py
/account, /terminal"] + Auth --> HistoryRouter["history.py
/history/orders, /history/deals"] + Auth --> CalcRouter["calc.py
/calc/margin, /calc/profit"] + Auth --> TradingRouter["trading.py
/order/check"] + + SymbolsRouter --> Deps["dependencies.py
MT5 Client Singleton"] + MarketRouter --> Deps + AccountRouter --> Deps + HistoryRouter --> Deps + CalcRouter --> Deps + TradingRouter --> Deps + Deps --> Fmt["formatters.py
JSON / Parquet"] + end + + Deps --> pdmt5["pdmt5
MT5 Client Library"] + pdmt5 --> MT5["MetaTrader 5
Terminal"] + end + + Client -- "HTTP/REST" --> Main + Fmt -- "JSON / Parquet" --> Client +``` + ## Features - REST endpoints for symbols, market data, account info, orders, history, From 22d37a76d146e45f17997582f28b1ac8ada6a834 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Mar 2026 12:32:23 +0000 Subject: [PATCH 2/3] Compact FastAPI Application subgraph in architecture diagram Collapse the middleware chain and seven routers into single summary nodes to reduce diagram verbosity while keeping the key layers visible. https://claude.ai/code/session_01YNwrPB3iN3JWpkVgM5XwVQ --- README.md | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 9cbd64e..143b00b 100644 --- a/README.md +++ b/README.md @@ -22,36 +22,18 @@ graph TB subgraph "Windows Host" subgraph "FastAPI Application" - Main["main.py
App Wiring & Lifespan"] - Main --> CORS["CORS Middleware"] - CORS --> Logging["Logging Middleware"] - Logging --> Error["Error Handler Middleware"] - Error --> RateLimit["Rate Limiter
(SlowAPI)"] - RateLimit --> Auth["API Key Auth
(Optional)"] - - Auth --> HealthRouter["health.py
/health, /version, /last-error"] - Auth --> SymbolsRouter["symbols.py
/symbols, /symbols/{symbol}"] - Auth --> MarketRouter["market.py
/rates, /ticks, /market-book"] - Auth --> AccountRouter["account.py
/account, /terminal"] - Auth --> HistoryRouter["history.py
/history/orders, /history/deals"] - Auth --> CalcRouter["calc.py
/calc/margin, /calc/profit"] - Auth --> TradingRouter["trading.py
/order/check"] - - SymbolsRouter --> Deps["dependencies.py
MT5 Client Singleton"] - MarketRouter --> Deps - AccountRouter --> Deps - HistoryRouter --> Deps - CalcRouter --> Deps - TradingRouter --> Deps - Deps --> Fmt["formatters.py
JSON / Parquet"] + Middleware["Middleware Stack
CORS · Logging · Error Handler · Rate Limiter · Auth"] + Routers["Routers
health · symbols · market · account · history · calc · trading"] + Deps["MT5 Client Singleton
+ JSON/Parquet Formatter"] + Middleware --> Routers --> Deps end Deps --> pdmt5["pdmt5
MT5 Client Library"] pdmt5 --> MT5["MetaTrader 5
Terminal"] end - Client -- "HTTP/REST" --> Main - Fmt -- "JSON / Parquet" --> Client + Client -- "HTTP/REST" --> Middleware + Deps -- "JSON / Parquet" --> Client ``` ## Features From 8b84f02b697b3e784b1d3384e8b1b81e78304260 Mon Sep 17 00:00:00 2001 From: dceoy <1938249+dceoy@users.noreply.github.com> Date: Tue, 17 Mar 2026 22:51:43 +0900 Subject: [PATCH 3/3] docs: clarify architecture diagram Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- README.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 143b00b..7bad65b 100644 --- a/README.md +++ b/README.md @@ -22,10 +22,14 @@ graph TB subgraph "Windows Host" subgraph "FastAPI Application" - Middleware["Middleware Stack
CORS · Logging · Error Handler · Rate Limiter · Auth"] + Middleware["Middleware Stack
CORS · Logging · Error Handler · Rate Limiter"] Routers["Routers
health · symbols · market · account · history · calc · trading"] - Deps["MT5 Client Singleton
+ JSON/Parquet Formatter"] - Middleware --> Routers --> Deps + Auth["API Key Security Dependency
Security(api_key_header) · verify_api_key"] + Deps["FastAPI Dependencies
MT5 Client Singleton · Format Negotiation"] + Formatters["Response Formatters
JSON · Parquet"] + Middleware --> Routers --> Deps --> Formatters + Auth -.-> Routers + Formatters --> Middleware end Deps --> pdmt5["pdmt5
MT5 Client Library"] @@ -33,7 +37,7 @@ graph TB end Client -- "HTTP/REST" --> Middleware - Deps -- "JSON / Parquet" --> Client + Middleware -- "JSON / Parquet" --> Client ``` ## Features