# prabhat-190/algo-trade-simulator architecture

> Architecture diagram of the GitHub repository prabhat-190/algo-trade-simulator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/prabhat-190/algo-trade-simulator
- Repository: https://github.com/prabhat-190/algo-trade-simulator

## Overview

Algo Trade Simulator is a pre-trade cost dashboard, not an execution system. A user configures a market-order estimate in Dash; live or synthetic L2 frames update shared market state, and the simulator estimates slippage, fees, impact, maker/taker mix, and net cost for display. The app also supports saved projects, market charts, and health/readiness endpoints. The README documents the high-level feed-to-book-to-simulator-to-UI flow; source excerpts show app wiring and key callbacks, but not every internal call or feed implementation.

Main entry points: [`trading/src/models/simulator.py`](https://github.com/prabhat-190/algo-trade-simulator/blob/main/trading/src/models/simulator.py) (Trade Simulator), [`trading/src/app.py`](https://github.com/prabhat-190/algo-trade-simulator/blob/main/trading/src/app.py) (App Factory), [`trading/src/services/feed_manager.py`](https://github.com/prabhat-190/algo-trade-simulator/blob/main/trading/src/services/feed_manager.py) (Feed Manager), [`trading/src/ui/dashboard.py`](https://github.com/prabhat-190/algo-trade-simulator/blob/main/trading/src/ui/dashboard.py) (Dash Dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Application Runtime"]
  node_app["App Factory<br/>[app.py]"]
  node_settings["Settings<br/>[config.py]"]
  node_market["Market State<br/>[market_state.py]"]
end

subgraph group_feeds["Market Data"]
  node_feedmgr["Feed Manager<br/>[feed_manager.py]"]
  node_redisbus["Redis Bus<br/>[redis_bus.py]"]
  node_websocket["WebSocket Client"]
  node_synthetic["Synthetic Feed<br/>[synthetic_feed.py]"]
end

subgraph group_estimation["Cost Estimation"]
  node_orderbook["Orderbook<br/>[orderbook.py]"]
  node_simulator["Trade Simulator<br/>[simulator.py]"]
  node_fees["Fee Model<br/>[fee_model.py]"]
  node_slippage["Slippage Model<br/>[slippage_model.py]"]
  node_impact["Market Impact Model<br/>[market_impact.py]"]
  node_makertaker["Maker Taker Model<br/>[maker_taker.py]"]
  node_acviz["Impact Visualizer"]
end

subgraph group_dashboard["Dashboard &amp; Projects"]
  node_dashboard["Dash Dashboard<br/>[dashboard.py]"]
  node_callbacks["UI Callbacks<br/>[callbacks.py]"]
  node_layout["Dashboard Layout<br/>[layout.py]"]
  node_figures["Market Charts<br/>[figures.py]"]
  node_projects["Project Store<br/>[trading_project.py]"]
end

node_user(("Trader"))
node_redis[("Redis")]
node_exchange(("Market Feed"))
node_browser(("Dashboard User"))

node_user -->|"configures estimate"| node_dashboard
node_app -->|"loads settings"| node_settings
node_app -->|"creates state"| node_market
node_app -->|"starts feed"| node_feedmgr
node_app -->|"creates dashboard"| node_dashboard
node_app -->|"creates store"| node_projects
node_feedmgr -->|"subscribes"| node_redisbus
node_redisbus -.->|"reads frames"| node_redis
node_feedmgr -->|"connects"| node_websocket
node_websocket -.->|"receives frames"| node_exchange
node_feedmgr -->|"generates fallback"| node_synthetic
node_feedmgr -->|"delivers frames"| node_market
node_market -->|"updates book"| node_simulator
node_simulator -->|"updates and reads"| node_orderbook
node_simulator -->|"calculates fees"| node_fees
node_simulator -->|"estimates slippage"| node_slippage
node_simulator -->|"estimates impact"| node_impact
node_simulator -->|"estimates mix"| node_makertaker
node_impact -.->|"visualized by"| node_acviz
node_dashboard -->|"registers callbacks"| node_callbacks
node_dashboard -->|"builds layout"| node_layout
node_callbacks -->|"reads and simulates"| node_market
node_callbacks -->|"loads and saves"| node_projects
node_callbacks -->|"builds charts"| node_figures
node_layout -->|"uses chart helpers"| node_figures
node_projects -.->|"persists optionally"| node_redis
node_browser -->|"views results"| node_dashboard

click node_app "https://github.com/prabhat-190/algo-trade-simulator/blob/main/trading/src/app.py"
click node_settings "https://github.com/prabhat-190/algo-trade-simulator/blob/main/trading/src/config.py"
click node_feedmgr "https://github.com/prabhat-190/algo-trade-simulator/blob/main/trading/src/services/feed_manager.py"
click node_redisbus "https://github.com/prabhat-190/algo-trade-simulator/blob/main/trading/src/data/redis_bus.py"
click node_websocket "https://github.com/prabhat-190/algo-trade-simulator/blob/main/trading/src/data/websocket_client.py"
click node_synthetic "https://github.com/prabhat-190/algo-trade-simulator/blob/main/trading/src/data/synthetic_feed.py"
click node_market "https://github.com/prabhat-190/algo-trade-simulator/blob/main/trading/src/services/market_state.py"
click node_orderbook "https://github.com/prabhat-190/algo-trade-simulator/blob/main/trading/src/data/orderbook.py"
click node_simulator "https://github.com/prabhat-190/algo-trade-simulator/blob/main/trading/src/models/simulator.py"
click node_fees "https://github.com/prabhat-190/algo-trade-simulator/blob/main/trading/src/models/fee_model.py"
click node_slippage "https://github.com/prabhat-190/algo-trade-simulator/blob/main/trading/src/models/slippage_model.py"
click node_impact "https://github.com/prabhat-190/algo-trade-simulator/blob/main/trading/src/models/market_impact.py"
click node_makertaker "https://github.com/prabhat-190/algo-trade-simulator/blob/main/trading/src/models/maker_taker.py"
click node_acviz "https://github.com/prabhat-190/algo-trade-simulator/blob/main/trading/src/visualization/almgren_chriss_visualizer.py"
click node_dashboard "https://github.com/prabhat-190/algo-trade-simulator/blob/main/trading/src/ui/dashboard.py"
click node_callbacks "https://github.com/prabhat-190/algo-trade-simulator/blob/main/trading/src/ui/callbacks.py"
click node_layout "https://github.com/prabhat-190/algo-trade-simulator/blob/main/trading/src/ui/layout.py"
click node_figures "https://github.com/prabhat-190/algo-trade-simulator/blob/main/trading/src/ui/figures.py"
click node_projects "https://github.com/prabhat-190/algo-trade-simulator/blob/main/trading/src/models/trading_project.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_app,node_settings,node_market,node_browser toneBlue
class node_feedmgr,node_redisbus,node_websocket,node_synthetic,node_redis toneAmber
class node_orderbook,node_simulator,node_fees,node_slippage,node_impact,node_makertaker,node_acviz toneMint
class node_dashboard,node_callbacks,node_layout,node_figures,node_projects toneRose
class node_user,node_exchange toneIndigo
```

## Components

### Application Runtime

- [App Factory](https://github.com/prabhat-190/algo-trade-simulator/blob/main/trading/src/app.py): `trading/src/app.py`
- [Settings](https://github.com/prabhat-190/algo-trade-simulator/blob/main/trading/src/config.py): `trading/src/config.py`
- [Market State](https://github.com/prabhat-190/algo-trade-simulator/blob/main/trading/src/services/market_state.py): `trading/src/services/market_state.py`

### Market Data

- [Feed Manager](https://github.com/prabhat-190/algo-trade-simulator/blob/main/trading/src/services/feed_manager.py): `trading/src/services/feed_manager.py`
- [Redis Bus](https://github.com/prabhat-190/algo-trade-simulator/blob/main/trading/src/data/redis_bus.py): `trading/src/data/redis_bus.py`
- [WebSocket Client](https://github.com/prabhat-190/algo-trade-simulator/blob/main/trading/src/data/websocket_client.py): `trading/src/data/websocket_client.py`
- [Synthetic Feed](https://github.com/prabhat-190/algo-trade-simulator/blob/main/trading/src/data/synthetic_feed.py): `trading/src/data/synthetic_feed.py`

### Cost Estimation

- [Orderbook](https://github.com/prabhat-190/algo-trade-simulator/blob/main/trading/src/data/orderbook.py): `trading/src/data/orderbook.py`
- [Trade Simulator](https://github.com/prabhat-190/algo-trade-simulator/blob/main/trading/src/models/simulator.py): `trading/src/models/simulator.py`
- [Fee Model](https://github.com/prabhat-190/algo-trade-simulator/blob/main/trading/src/models/fee_model.py): `trading/src/models/fee_model.py`
- [Slippage Model](https://github.com/prabhat-190/algo-trade-simulator/blob/main/trading/src/models/slippage_model.py): `trading/src/models/slippage_model.py`
- [Market Impact Model](https://github.com/prabhat-190/algo-trade-simulator/blob/main/trading/src/models/market_impact.py): `trading/src/models/market_impact.py`
- [Maker Taker Model](https://github.com/prabhat-190/algo-trade-simulator/blob/main/trading/src/models/maker_taker.py): `trading/src/models/maker_taker.py`
- [Impact Visualizer](https://github.com/prabhat-190/algo-trade-simulator/blob/main/trading/src/visualization/almgren_chriss_visualizer.py): `trading/src/visualization/almgren_chriss_visualizer.py`

### Dashboard & Projects

- [Dash Dashboard](https://github.com/prabhat-190/algo-trade-simulator/blob/main/trading/src/ui/dashboard.py): `trading/src/ui/dashboard.py`
- [UI Callbacks](https://github.com/prabhat-190/algo-trade-simulator/blob/main/trading/src/ui/callbacks.py): `trading/src/ui/callbacks.py`
- [Dashboard Layout](https://github.com/prabhat-190/algo-trade-simulator/blob/main/trading/src/ui/layout.py): `trading/src/ui/layout.py`
- [Market Charts](https://github.com/prabhat-190/algo-trade-simulator/blob/main/trading/src/ui/figures.py): `trading/src/ui/figures.py`
- [Project Store](https://github.com/prabhat-190/algo-trade-simulator/blob/main/trading/src/models/trading_project.py): `trading/src/models/trading_project.py`

### Other components

- **Trader**
- **Redis**
- **Market Feed**
- **Dashboard User**

## Connections

- Trader → Dash Dashboard: configures estimate (evidence: `README.md`)
- App Factory → Settings: loads settings (evidence: `trading/src/app.py`)
- App Factory → Market State: creates state (evidence: `trading/src/app.py`)
- App Factory → Feed Manager: starts feed (evidence: `trading/src/app.py`)
- App Factory → Dash Dashboard: creates dashboard (evidence: `trading/src/app.py`)
- App Factory → Project Store: creates store (evidence: `trading/src/app.py`)
- Feed Manager → Redis Bus: subscribes (evidence: `trading/src/services/feed_manager.py`)
- Redis Bus → Redis: reads frames (evidence: `README.md`)
- Feed Manager → WebSocket Client: connects (evidence: `trading/src/services/feed_manager.py`)
- WebSocket Client → Market Feed: receives frames (evidence: `README.md`)
- Feed Manager → Synthetic Feed: generates fallback (evidence: `trading/src/services/feed_manager.py`)
- Feed Manager → Market State: delivers frames (evidence: `trading/src/app.py`)
- Market State → Trade Simulator: updates book (evidence: `trading/src/services/market_state.py`)
- Trade Simulator → Orderbook: updates and reads (evidence: `trading/src/models/simulator.py`)
- Trade Simulator → Fee Model: calculates fees (evidence: `trading/src/models/simulator.py`)
- Trade Simulator → Slippage Model: estimates slippage (evidence: `trading/src/models/simulator.py`)
- Trade Simulator → Market Impact Model: estimates impact (evidence: `trading/src/models/simulator.py`)
- Trade Simulator → Maker Taker Model: estimates mix (evidence: `trading/src/models/simulator.py`)
- Market Impact Model → Impact Visualizer: visualized by (evidence: `trading/src/visualization/almgren_chriss_visualizer.py`)
- Dash Dashboard → UI Callbacks: registers callbacks (evidence: `trading/src/ui/dashboard.py`)
- Dash Dashboard → Dashboard Layout: builds layout (evidence: `trading/src/ui/dashboard.py`)
- UI Callbacks → Market State: reads and simulates (evidence: `trading/src/ui/callbacks.py`)
- UI Callbacks → Project Store: loads and saves (evidence: `trading/src/ui/callbacks.py`)
- UI Callbacks → Market Charts: builds charts (evidence: `trading/src/ui/callbacks.py`)
- Dashboard Layout → Market Charts: uses chart helpers (evidence: `trading/src/ui/layout.py`)
- Project Store → Redis: persists optionally
- Dashboard User → Dash Dashboard: views results (evidence: `README.md`)
