# colochampre/strategy-manager architecture

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

- Interactive diagram: https://gitdiagram.com/colochampre/strategy-manager
- Repository: https://github.com/colochampre/strategy-manager
- Video tour (about a minute): https://gitdiagram.com/colochampre/strategy-manager/video

## Overview

Strategy Manager accepts TradingView strategy signals, persists and queues them for asynchronous processing, then allocates pooled capital and executes eligible orders. The README identifies the worker as responsible for allocation, execution, ledger writes, reservation expiry, and balance syncing; it also documents reconciliation and performance reporting capabilities reflected in the source tree. Some subsystem wiring is unsampled, so links beyond documented workflow are omitted. The frontend is described as an unfinished scaffold.

Main entry points: [`backend/src/strategy_manager/worker.py`](https://github.com/colochampre/strategy-manager/blob/main/backend/src/strategy_manager/worker.py) (Background worker), [`backend/src/strategy_manager/main.py`](https://github.com/colochampre/strategy-manager/blob/main/backend/src/strategy_manager/main.py) (API application), [`backend/src/strategy_manager/signals/application/ingest_signal.py`](https://github.com/colochampre/strategy-manager/blob/main/backend/src/strategy_manager/signals/application/ingest_signal.py) (Signal ingress), [`backend/src/strategy_manager/allocation/application/allocate_capital.py`](https://github.com/colochampre/strategy-manager/blob/main/backend/src/strategy_manager/allocation/application/allocate_capital.py) (Capital allocation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and strategies"]
  node_api["API application<br/>[main.py]"]
  node_strategy_config["Strategy configuration<br/>[router.py]"]
  node_identity["User identity"]
end

subgraph group_trading["Signal to execution"]
  node_signal_ingress["Signal ingress<br/>[ingest_signal.py]"]
  node_worker["Background worker<br/>[worker.py]"]
  node_exchange_adapters["Exchange adapters"]
  node_execution["Order execution<br/>[place_order.py]"]
end

subgraph group_capital["Capital and accounts"]
  node_allocation["Capital allocation"]
  node_reservations[("Reservations<br/>[repository.py]")]
  node_accounts["Account balances"]
end

subgraph group_oversight["Records and reporting"]
  node_ledger[("Append-only ledger<br/>[repository.py]")]
  node_reconciliation["Position reconciliation"]
  node_performance["Performance reports"]
end

subgraph group_runtime["Shared runtime"]
  node_job_queue["Job queue<br/>[job_queue.py]"]
  node_postgres[("PostgreSQL<br/>[db.py]")]
  node_shared["Shared application services"]
end

node_tradingview(("TradingView"))
node_exchanges{{"Trading exchanges"}}

node_tradingview -->|"sends alerts"| node_api
node_api -->|"accepts signals"| node_signal_ingress
node_signal_ingress -->|"enqueues job"| node_job_queue
node_api -.->|"serves routes"| node_strategy_config
node_worker -->|"processes jobs"| node_job_queue
node_worker -->|"allocates capital"| node_allocation
node_worker -->|"executes orders"| node_execution
node_worker -->|"syncs balances"| node_accounts
node_allocation -.->|"reserves funds"| node_reservations
node_allocation -.->|"uses pool capital"| node_accounts
node_execution -.->|"dispatches orders"| node_exchange_adapters
node_exchange_adapters -.->|"places orders"| node_exchanges
node_worker -->|"writes fills"| node_ledger
node_worker -.->|"runs reconciliation"| node_reconciliation
node_api -.->|"serves reports"| node_performance
node_api -.->|"authenticates users"| node_identity
node_worker -.->|"uses services"| node_shared
node_signal_ingress -->|"persists signals"| node_postgres
node_job_queue -->|"stores jobs"| node_postgres
node_ledger -->|"stores entries"| node_postgres

click node_api "https://github.com/colochampre/strategy-manager/blob/main/backend/src/strategy_manager/main.py"
click node_strategy_config "https://github.com/colochampre/strategy-manager/blob/main/backend/src/strategy_manager/strategies/infrastructure/router.py"
click node_signal_ingress "https://github.com/colochampre/strategy-manager/blob/main/backend/src/strategy_manager/signals/application/ingest_signal.py"
click node_worker "https://github.com/colochampre/strategy-manager/blob/main/backend/src/strategy_manager/worker.py"
click node_job_queue "https://github.com/colochampre/strategy-manager/blob/main/backend/src/strategy_manager/shared/infrastructure/job_queue.py"
click node_allocation "https://github.com/colochampre/strategy-manager/blob/main/backend/src/strategy_manager/allocation/application/allocate_capital.py"
click node_reservations "https://github.com/colochampre/strategy-manager/blob/main/backend/src/strategy_manager/allocation/infrastructure/repository.py"
click node_accounts "https://github.com/colochampre/strategy-manager/tree/main/backend/src/strategy_manager/accounts"
click node_exchange_adapters "https://github.com/colochampre/strategy-manager/tree/main/backend/src/strategy_manager/execution/infrastructure"
click node_execution "https://github.com/colochampre/strategy-manager/blob/main/backend/src/strategy_manager/execution/application/place_order.py"
click node_ledger "https://github.com/colochampre/strategy-manager/blob/main/backend/src/strategy_manager/ledger/infrastructure/repository.py"
click node_reconciliation "https://github.com/colochampre/strategy-manager/tree/main/backend/src/strategy_manager/reconciliation"
click node_performance "https://github.com/colochampre/strategy-manager/blob/main/backend/src/strategy_manager/performance/infrastructure/performance_router.py"
click node_identity "https://github.com/colochampre/strategy-manager/tree/main/backend/src/strategy_manager/identity"
click node_postgres "https://github.com/colochampre/strategy-manager/blob/main/backend/src/strategy_manager/shared/db.py"
click node_shared "https://github.com/colochampre/strategy-manager/tree/main/backend/src/strategy_manager/shared/application"

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_api,node_strategy_config,node_identity,node_tradingview toneBlue
class node_signal_ingress,node_worker,node_exchange_adapters,node_execution toneAmber
class node_allocation,node_reservations,node_accounts toneMint
class node_ledger,node_reconciliation,node_performance toneRose
class node_job_queue,node_postgres,node_shared,node_exchanges toneIndigo
```

## Components

### API and strategies

- [API application](https://github.com/colochampre/strategy-manager/blob/main/backend/src/strategy_manager/main.py): `backend/src/strategy_manager/main.py`
- [Strategy configuration](https://github.com/colochampre/strategy-manager/blob/main/backend/src/strategy_manager/strategies/infrastructure/router.py): `backend/src/strategy_manager/strategies/infrastructure/router.py`
- [User identity](https://github.com/colochampre/strategy-manager/tree/main/backend/src/strategy_manager/identity): `backend/src/strategy_manager/identity`

### Signal to execution

- [Signal ingress](https://github.com/colochampre/strategy-manager/blob/main/backend/src/strategy_manager/signals/application/ingest_signal.py): `backend/src/strategy_manager/signals/application/ingest_signal.py`
- [Background worker](https://github.com/colochampre/strategy-manager/blob/main/backend/src/strategy_manager/worker.py): `backend/src/strategy_manager/worker.py`
- [Exchange adapters](https://github.com/colochampre/strategy-manager/tree/main/backend/src/strategy_manager/execution/infrastructure): `backend/src/strategy_manager/execution/infrastructure`
- [Order execution](https://github.com/colochampre/strategy-manager/blob/main/backend/src/strategy_manager/execution/application/place_order.py): `backend/src/strategy_manager/execution/application/place_order.py`

### Capital and accounts

- [Capital allocation](https://github.com/colochampre/strategy-manager/blob/main/backend/src/strategy_manager/allocation/application/allocate_capital.py): `backend/src/strategy_manager/allocation/application/allocate_capital.py`
- [Reservations](https://github.com/colochampre/strategy-manager/blob/main/backend/src/strategy_manager/allocation/infrastructure/repository.py): `backend/src/strategy_manager/allocation/infrastructure/repository.py`
- [Account balances](https://github.com/colochampre/strategy-manager/tree/main/backend/src/strategy_manager/accounts): `backend/src/strategy_manager/accounts`

### Records and reporting

- [Append-only ledger](https://github.com/colochampre/strategy-manager/blob/main/backend/src/strategy_manager/ledger/infrastructure/repository.py): `backend/src/strategy_manager/ledger/infrastructure/repository.py`
- [Position reconciliation](https://github.com/colochampre/strategy-manager/tree/main/backend/src/strategy_manager/reconciliation): `backend/src/strategy_manager/reconciliation`
- [Performance reports](https://github.com/colochampre/strategy-manager/blob/main/backend/src/strategy_manager/performance/infrastructure/performance_router.py): `backend/src/strategy_manager/performance/infrastructure/performance_router.py`

### Shared runtime

- [Job queue](https://github.com/colochampre/strategy-manager/blob/main/backend/src/strategy_manager/shared/infrastructure/job_queue.py): `backend/src/strategy_manager/shared/infrastructure/job_queue.py`
- [PostgreSQL](https://github.com/colochampre/strategy-manager/blob/main/backend/src/strategy_manager/shared/db.py): `backend/src/strategy_manager/shared/db.py`
- [Shared application services](https://github.com/colochampre/strategy-manager/tree/main/backend/src/strategy_manager/shared/application): `backend/src/strategy_manager/shared/application`

### Other components

- **TradingView**
- **Trading exchanges**

## Connections

- TradingView → API application: sends alerts (evidence: `README.md`)
- API application → Signal ingress: accepts signals (evidence: `README.md`)
- Signal ingress → Job queue: enqueues job (evidence: `backend/src/strategy_manager/signals/application/ingest_signal.py`)
- API application → Strategy configuration: serves routes
- Background worker → Job queue: processes jobs (evidence: `README.md`)
- Background worker → Capital allocation: allocates capital (evidence: `README.md`)
- Background worker → Order execution: executes orders (evidence: `README.md`)
- Background worker → Account balances: syncs balances (evidence: `README.md`)
- Capital allocation → Reservations: reserves funds
- Capital allocation → Account balances: uses pool capital
- Order execution → Exchange adapters: dispatches orders
- Exchange adapters → Trading exchanges: places orders
- Background worker → Append-only ledger: writes fills (evidence: `README.md`)
- Background worker → Position reconciliation: runs reconciliation
- API application → Performance reports: serves reports
- API application → User identity: authenticates users
- Background worker → Shared application services: uses services
- Signal ingress → PostgreSQL: persists signals (evidence: `README.md`)
- Job queue → PostgreSQL: stores jobs (evidence: `README.md`)
- Append-only ledger → PostgreSQL: stores entries (evidence: `backend/src/strategy_manager/ledger/infrastructure/repository.py`)
