# chloepike/depth architecture

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

- Interactive diagram: https://gitdiagram.com/chloepike/depth
- Repository: https://github.com/chloepike/depth

## Overview

Depth is a local multi-exchange trading terminal. A user selects an asset and market; venue feeds and history supply market data that the data layer normalizes and aggregates for the terminal’s book, tape, and chart. Users can then inspect signals or submit trades, with risk checks, venue-specific execution, account views, and optional paper trading. Hunter scanning and custom indicators are separate capabilities. The UI’s module wiring and selected engine calls are visible in excerpts; several feature connections are documented in the README, while unsampled implementation details are left out.

Main entry points: [`ui/src/lib.rs`](https://github.com/chloepike/depth/blob/main/ui/src/lib.rs) (Terminal shell), [`ui/src/engine.rs`](https://github.com/chloepike/depth/blob/main/ui/src/engine.rs) (Data engine), [`src/trade.rs`](https://github.com/chloepike/depth/blob/main/src/trade.rs) (Trading dispatch), [`src/ex/mod.rs`](https://github.com/chloepike/depth/blob/main/src/ex/mod.rs) (Venue feeds)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Terminal interface"]
  node_app["Terminal shell<br/>[lib.rs]"]
  node_engine["Data engine<br/>[engine.rs]"]
  node_bookview["Book and tape<br/>[book.rs]"]
  node_chartview["Chart views<br/>[chart.rs]"]
  node_orderview["Order panel<br/>[order.rs]"]
  node_accountview["Account views<br/>[account.rs]"]
end

subgraph group_market["Market data"]
  node_connectors["Venue feeds<br/>[mod.rs]"]
  node_protocol["WebSocket and REST<br/>[ws.rs]"]
  node_aliases["Market aliases<br/>[alias.rs]"]
  node_aggregation["Market aggregation<br/>[agg.rs]"]
  node_l3["Order-level data<br/>[l3.rs]"]
end

subgraph group_insight["Analysis tools"]
  node_signals["Signals and models<br/>[quant.rs]"]
  node_scanner["Hunter scanner<br/>[hunter.rs]"]
  node_indicators["Custom indicators<br/>[script.rs]"]
end

subgraph group_execution["Trading"]
  node_tradeapi["Trading dispatch<br/>[trade.rs]"]
  node_routing["Smart routing<br/>[route.rs]"]
  node_risk["Risk guard<br/>[risk.rs]"]
  node_venueorders["Venue execution<br/>[bybit.rs]"]
  node_tpsl["TP and SL<br/>[tpsl.rs]"]
  node_paper["Paper trading<br/>[demo.rs]"]
end

subgraph group_local["Local services"]
  node_storage[("SQLite store<br/>[db.rs]")]
  node_system["OS services<br/>[sys.rs]"]
end

node_user(("Trader"))

node_user -->|"uses"| node_app
node_app -->|"starts"| node_engine
node_app -->|"renders"| node_bookview
node_app -->|"renders"| node_chartview
node_app -->|"renders"| node_orderview
node_app -->|"renders"| node_accountview
node_connectors -->|"uses"| node_protocol
node_connectors -->|"maps symbols"| node_aliases
node_connectors -->|"streams data"| node_aggregation
node_aggregation -->|"uses"| node_l3
node_engine -->|"checks orders"| node_risk
node_engine -->|"sends batches"| node_paper
node_engine -->|"records OI"| node_storage
node_orderview -->|"offers routing"| node_routing
node_routing -->|"routes orders"| node_tradeapi
node_tradeapi -->|"dispatches"| node_venueorders
node_tradeapi -->|"delegates TP/SL"| node_tpsl
node_tradeapi -->|"reads credentials"| node_system
node_chartview -->|"supports scripts"| node_indicators
node_aggregation -->|"feeds analysis"| node_signals
node_scanner -->|"stores scan bars"| node_storage
node_paper -->|"persists events"| node_storage

click node_app "https://github.com/chloepike/depth/blob/main/ui/src/lib.rs"
click node_engine "https://github.com/chloepike/depth/blob/main/ui/src/engine.rs"
click node_bookview "https://github.com/chloepike/depth/blob/main/ui/src/book.rs"
click node_chartview "https://github.com/chloepike/depth/blob/main/ui/src/chart.rs"
click node_orderview "https://github.com/chloepike/depth/blob/main/ui/src/order.rs"
click node_accountview "https://github.com/chloepike/depth/blob/main/ui/src/account.rs"
click node_connectors "https://github.com/chloepike/depth/blob/main/src/ex/mod.rs"
click node_protocol "https://github.com/chloepike/depth/blob/main/src/ws.rs"
click node_aliases "https://github.com/chloepike/depth/blob/main/src/alias.rs"
click node_aggregation "https://github.com/chloepike/depth/blob/main/src/agg.rs"
click node_l3 "https://github.com/chloepike/depth/blob/main/src/l3.rs"
click node_signals "https://github.com/chloepike/depth/blob/main/src/quant.rs"
click node_scanner "https://github.com/chloepike/depth/blob/main/src/hunter.rs"
click node_indicators "https://github.com/chloepike/depth/blob/main/ui/src/script.rs"
click node_tradeapi "https://github.com/chloepike/depth/blob/main/src/trade.rs"
click node_routing "https://github.com/chloepike/depth/blob/main/src/route.rs"
click node_risk "https://github.com/chloepike/depth/blob/main/src/risk.rs"
click node_venueorders "https://github.com/chloepike/depth/blob/main/src/trade/bybit.rs"
click node_tpsl "https://github.com/chloepike/depth/blob/main/src/trade/tpsl.rs"
click node_paper "https://github.com/chloepike/depth/blob/main/src/demo.rs"
click node_storage "https://github.com/chloepike/depth/blob/main/src/db.rs"
click node_system "https://github.com/chloepike/depth/blob/main/src/sys.rs"

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_engine,node_bookview,node_chartview,node_orderview,node_accountview toneBlue
class node_connectors,node_protocol,node_aliases,node_aggregation,node_l3 toneAmber
class node_signals,node_scanner,node_indicators toneMint
class node_tradeapi,node_routing,node_risk,node_venueorders,node_tpsl,node_paper toneRose
class node_storage,node_system,node_user toneIndigo
```

## Components

### Terminal interface

- [Terminal shell](https://github.com/chloepike/depth/blob/main/ui/src/lib.rs): `ui/src/lib.rs`
- [Data engine](https://github.com/chloepike/depth/blob/main/ui/src/engine.rs): `ui/src/engine.rs`
- [Book and tape](https://github.com/chloepike/depth/blob/main/ui/src/book.rs): `ui/src/book.rs`
- [Chart views](https://github.com/chloepike/depth/blob/main/ui/src/chart.rs): `ui/src/chart.rs`
- [Order panel](https://github.com/chloepike/depth/blob/main/ui/src/order.rs): `ui/src/order.rs`
- [Account views](https://github.com/chloepike/depth/blob/main/ui/src/account.rs): `ui/src/account.rs`

### Market data

- [Venue feeds](https://github.com/chloepike/depth/blob/main/src/ex/mod.rs): `src/ex/mod.rs`
- [WebSocket and REST](https://github.com/chloepike/depth/blob/main/src/ws.rs): `src/ws.rs`
- [Market aliases](https://github.com/chloepike/depth/blob/main/src/alias.rs): `src/alias.rs`
- [Market aggregation](https://github.com/chloepike/depth/blob/main/src/agg.rs): `src/agg.rs`
- [Order-level data](https://github.com/chloepike/depth/blob/main/src/l3.rs): `src/l3.rs`

### Analysis tools

- [Signals and models](https://github.com/chloepike/depth/blob/main/src/quant.rs): `src/quant.rs`
- [Hunter scanner](https://github.com/chloepike/depth/blob/main/src/hunter.rs): `src/hunter.rs`
- [Custom indicators](https://github.com/chloepike/depth/blob/main/ui/src/script.rs): `ui/src/script.rs`

### Trading

- [Trading dispatch](https://github.com/chloepike/depth/blob/main/src/trade.rs): `src/trade.rs`
- [Smart routing](https://github.com/chloepike/depth/blob/main/src/route.rs): `src/route.rs`
- [Risk guard](https://github.com/chloepike/depth/blob/main/src/risk.rs): `src/risk.rs`
- [Venue execution](https://github.com/chloepike/depth/blob/main/src/trade/bybit.rs): `src/trade/bybit.rs`
- [TP and SL](https://github.com/chloepike/depth/blob/main/src/trade/tpsl.rs): `src/trade/tpsl.rs`
- [Paper trading](https://github.com/chloepike/depth/blob/main/src/demo.rs): `src/demo.rs`

### Local services

- [SQLite store](https://github.com/chloepike/depth/blob/main/src/db.rs): `src/db.rs`
- [OS services](https://github.com/chloepike/depth/blob/main/src/sys.rs): `src/sys.rs`

### Other components

- **Trader**

## Connections

- Trader → Terminal shell: uses
- Terminal shell → Data engine: starts (evidence: `ui/src/lib.rs`)
- Terminal shell → Book and tape: renders (evidence: `ui/src/lib.rs`)
- Terminal shell → Chart views: renders (evidence: `ui/src/lib.rs`)
- Terminal shell → Order panel: renders (evidence: `ui/src/lib.rs`)
- Terminal shell → Account views: renders (evidence: `ui/src/lib.rs`)
- Venue feeds → WebSocket and REST: uses
- Venue feeds → Market aliases: maps symbols (evidence: `src/ex/mod.rs`)
- Venue feeds → Market aggregation: streams data
- Market aggregation → Order-level data: uses (evidence: `src/agg.rs`)
- Data engine → Risk guard: checks orders (evidence: `ui/src/engine.rs`)
- Data engine → Paper trading: sends batches (evidence: `ui/src/engine.rs`)
- Data engine → SQLite store: records OI (evidence: `ui/src/engine.rs`)
- Order panel → Smart routing: offers routing
- Smart routing → Trading dispatch: routes orders
- Trading dispatch → Venue execution: dispatches (evidence: `src/trade.rs`)
- Trading dispatch → TP and SL: delegates TP/SL (evidence: `src/trade.rs`)
- Trading dispatch → OS services: reads credentials (evidence: `src/trade.rs`)
- Chart views → Custom indicators: supports scripts
- Market aggregation → Signals and models: feeds analysis
- Hunter scanner → SQLite store: stores scan bars (evidence: `src/db.rs`)
- Paper trading → SQLite store: persists events (evidence: `src/db.rs`)
