# agustrisna170892-afk/alpaca-0dte-trading-terminal architecture

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

- Interactive diagram: https://gitdiagram.com/agustrisna170892-afk/alpaca-0dte-trading-terminal
- Repository: https://github.com/agustrisna170892-afk/alpaca-0dte-trading-terminal

## Overview

The README describes an asynchronous Alpaca options terminal and its operator-to-order workflow, but the supplied tree contains no runtime source excerpts. The graph therefore captures documented subsystems and relationships only; implementation paths are unknown. The README also mentions offline replay, but does not identify its implementation or connect it to a specific subsystem.

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Operator Interface"]
  node_terminal["Terminal UI"]
  node_sanity["Sanity Funnel"]
end

subgraph group_trading["Trading Engine"]
  node_surveillance["Surveillance"]
  node_universe["Universe Selector"]
  node_gate["Order Gate"]
  node_pricing["Limit Pricing"]
  node_execution["Order Lifecycle"]
  node_background["Background Reconciliation"]
end

subgraph group_state["State and Integrations"]
  node_sqlite[("Local SQLite")]
  node_replay["Offline Session Replay"]
end

node_operator(("Operator"))
node_broker["Alpaca Broker API"]
node_enrichment["Optional Enrichment"]

node_operator -->|"uses"| node_terminal
node_terminal -->|"confirms structure"| node_sanity
node_terminal -->|"receives signals"| node_surveillance
node_terminal -->|"requests orders"| node_gate
node_sanity -->|"confirms order"| node_gate
node_surveillance -->|"ranks candidates"| node_universe
node_gate -->|"approves orders"| node_pricing
node_pricing -->|"prices orders"| node_execution
node_execution -->|"submits orders"| node_broker
node_background -->|"reconciles state"| node_broker
node_background -->|"manages exits"| node_execution
node_surveillance -->|"consumes feeds"| node_broker
node_surveillance -.->|"uses optional data"| node_enrichment
node_sanity -->|"persists tags"| node_sqlite
node_execution -->|"persists activity"| node_sqlite
node_replay -.->|"reads sessions"| node_sqlite

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_terminal,node_sanity toneBlue
class node_surveillance,node_universe,node_gate,node_pricing,node_execution,node_background toneAmber
class node_sqlite,node_replay,node_broker toneMint
class node_operator,node_enrichment toneIndigo
```

## Components

### Operator Interface

- **Terminal UI**
- **Sanity Funnel**

### Trading Engine

- **Surveillance**
- **Universe Selector**
- **Order Gate**
- **Limit Pricing**
- **Order Lifecycle**
- **Background Reconciliation**

### State and Integrations

- **Local SQLite**
- **Offline Session Replay**

### Other components

- **Operator**
- **Alpaca Broker API**
- **Optional Enrichment**

## Connections

- Operator → Terminal UI: uses (evidence: `README.md`)
- Terminal UI → Sanity Funnel: confirms structure (evidence: `README.md`)
- Terminal UI → Surveillance: receives signals (evidence: `README.md`)
- Terminal UI → Order Gate: requests orders (evidence: `README.md`)
- Sanity Funnel → Order Gate: confirms order (evidence: `README.md`)
- Surveillance → Universe Selector: ranks candidates (evidence: `README.md`)
- Order Gate → Limit Pricing: approves orders (evidence: `README.md`)
- Limit Pricing → Order Lifecycle: prices orders (evidence: `README.md`)
- Order Lifecycle → Alpaca Broker API: submits orders (evidence: `README.md`)
- Background Reconciliation → Alpaca Broker API: reconciles state (evidence: `README.md`)
- Background Reconciliation → Order Lifecycle: manages exits (evidence: `README.md`)
- Surveillance → Alpaca Broker API: consumes feeds (evidence: `README.md`)
- Surveillance → Optional Enrichment: uses optional data (evidence: `README.md`)
- Sanity Funnel → Local SQLite: persists tags (evidence: `README.md`)
- Order Lifecycle → Local SQLite: persists activity (evidence: `README.md`)
- Offline Session Replay → Local SQLite: reads sessions
