# twilliamsa7/syren architecture

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

- Interactive diagram: https://gitdiagram.com/twilliamsa7/syren
- Repository: https://github.com/twilliamsa7/syren

## Overview

Syren ingests live ADS-B reports or archived traces, normalizes aircraft data into FlightState, and runs rule-based detection plus experimental prediction before presenting aircraft and alerts in the map. The principal user flow is live monitoring or selecting a replay date, then inspecting aircraft and optionally requesting a Gemini summary. Separate capabilities include synthetic anomaly simulation and an offline emergency-prediction research pipeline. Edges reflect shown calls, indexed references, or README statements; links for unsampled wiring are omitted or marked unverified.

Main entry points: [`detection/engine.py`](https://github.com/twilliamsa7/syren/blob/main/detection/engine.py) (Detection Engine), [`data/replay.py`](https://github.com/twilliamsa7/syren/blob/main/data/replay.py) (Replay Engine), [`backend/server.py`](https://github.com/twilliamsa7/syren/blob/main/backend/server.py) (API Server), [`data/live_adapter.py`](https://github.com/twilliamsa7/syren/blob/main/data/live_adapter.py) (Live Adapter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingestion["Telemetry &amp; Replay"]
  node_live_adapter["Live Adapter<br/>[live_adapter.py]"]
  node_history["History Manager<br/>[history.py]"]
  node_trace["Trace Export<br/>[trace.py]"]
  node_replay["Replay Engine<br/>[replay.py]"]
  node_flight_state["FlightState Schema<br/>[flight_state.py]"]
end

subgraph group_analysis["Detection &amp; Prediction"]
  node_detection_engine["Detection Engine<br/>[engine.py]"]
  node_detectors["Rule Detectors"]
  node_risk["Risk Aggregation<br/>[risk.py]"]
  node_warning_model["Aircraft Warnings"]
end

subgraph group_experience["Map Experience"]
  node_api_server["API Server<br/>[server.py]"]
  node_map_app["Aircraft Map<br/>[App.tsx]"]
  node_gemini["Gemini Summaries<br/>[gemini.py]"]
end

subgraph group_research["Research Pipeline"]
  node_window_labels["Window Labels<br/>[label_windows.py]"]
  node_features["Feature Extraction<br/>[features.py]"]
  node_event_model["Event Training"]
  node_baseline["Baseline Training<br/>[train_baseline.py]"]
  node_prediction["Model Inference<br/>[predict.py]"]
  node_early_warning["Warning Evaluation<br/>[early_warning.py]"]
end

subgraph group_simulation["Simulation"]
  node_sim_generate["Scenario Generator<br/>[generate.py]"]
  node_sim_run["Flight Runner<br/>[run.py]"]
  node_sim_anomalies["Anomaly Scenarios<br/>[anomalies.py]"]
end

node_operator(("Operator"))
node_adsb["adsb.lol Feed"]
node_archive[("History Archive")]
node_gemini_api["Gemini API"]

node_operator -->|"uses"| node_map_app
node_map_app -->|"requests API"| node_api_server
node_operator -->|"starts replay"| node_api_server
node_api_server -->|"checks history"| node_history
node_api_server -->|"controls replay"| node_replay
node_history -->|"downloads traces"| node_archive
node_adsb -->|"provides reports"| node_live_adapter
node_live_adapter -->|"normalizes reports"| node_flight_state
node_live_adapter -->|"runs detection"| node_detection_engine
node_live_adapter -->|"evaluates warnings"| node_warning_model
node_history -->|"supplies traces"| node_trace
node_replay -->|"loads history"| node_history
node_replay -->|"reads traces"| node_trace
node_replay -->|"runs detection"| node_detection_engine
node_replay -->|"evaluates warnings"| node_warning_model
node_detection_engine -->|"dispatches rules"| node_detectors
node_detection_engine -->|"combines risk"| node_risk
node_operator -->|"asks about aircraft"| node_gemini
node_api_server -->|"starts questions"| node_gemini
node_gemini -.->|"requests summary"| node_gemini_api
node_window_labels -->|"extracts features"| node_features
node_event_model -->|"uses features"| node_features
node_event_model -->|"uses labels"| node_window_labels
node_baseline -->|"uses features"| node_features
node_baseline -->|"uses labels"| node_window_labels
node_baseline -->|"trains inference"| node_prediction
node_early_warning -->|"evaluates alerts"| node_detection_engine
node_early_warning -->|"evaluates warnings"| node_warning_model
node_sim_generate -->|"generates flights"| node_sim_run
node_sim_generate -->|"injects scenarios"| node_sim_anomalies
node_sim_run -->|"emits states"| node_flight_state
node_sim_run -->|"applies anomalies"| node_sim_anomalies
node_sim_run -->|"tests detectors"| node_detection_engine
node_map_app -->|"renders map"| node_map_app

click node_live_adapter "https://github.com/twilliamsa7/syren/blob/main/data/live_adapter.py"
click node_history "https://github.com/twilliamsa7/syren/blob/main/data/history.py"
click node_trace "https://github.com/twilliamsa7/syren/blob/main/data/trace.py"
click node_replay "https://github.com/twilliamsa7/syren/blob/main/data/replay.py"
click node_flight_state "https://github.com/twilliamsa7/syren/blob/main/shared/flight_state.py"
click node_api_server "https://github.com/twilliamsa7/syren/blob/main/backend/server.py"
click node_detection_engine "https://github.com/twilliamsa7/syren/blob/main/detection/engine.py"
click node_detectors "https://github.com/twilliamsa7/syren/tree/main/detection/detectors"
click node_risk "https://github.com/twilliamsa7/syren/blob/main/detection/aggregation/risk.py"
click node_warning_model "https://github.com/twilliamsa7/syren/blob/main/ml/aircraft_warning.py"
click node_map_app "https://github.com/twilliamsa7/syren/blob/main/frontend/src/App.tsx"
click node_gemini "https://github.com/twilliamsa7/syren/blob/main/backend/gemini.py"
click node_window_labels "https://github.com/twilliamsa7/syren/blob/main/ml/label_windows.py"
click node_features "https://github.com/twilliamsa7/syren/blob/main/ml/features.py"
click node_event_model "https://github.com/twilliamsa7/syren/blob/main/ml/event_supervised.py"
click node_baseline "https://github.com/twilliamsa7/syren/blob/main/ml/train_baseline.py"
click node_prediction "https://github.com/twilliamsa7/syren/blob/main/ml/predict.py"
click node_early_warning "https://github.com/twilliamsa7/syren/blob/main/evaluation/early_warning.py"
click node_sim_generate "https://github.com/twilliamsa7/syren/blob/main/simulation/generate.py"
click node_sim_run "https://github.com/twilliamsa7/syren/blob/main/simulation/run.py"
click node_sim_anomalies "https://github.com/twilliamsa7/syren/blob/main/simulation/anomalies.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_live_adapter,node_history,node_trace,node_replay,node_flight_state toneBlue
class node_detection_engine,node_detectors,node_risk,node_warning_model,node_archive toneAmber
class node_api_server,node_map_app,node_gemini,node_gemini_api toneMint
class node_window_labels,node_features,node_event_model,node_baseline,node_prediction,node_early_warning toneRose
class node_sim_generate,node_sim_run,node_sim_anomalies,node_operator,node_adsb toneIndigo
```

## Components

### Telemetry & Replay

- [Live Adapter](https://github.com/twilliamsa7/syren/blob/main/data/live_adapter.py): `data/live_adapter.py`
- [History Manager](https://github.com/twilliamsa7/syren/blob/main/data/history.py): `data/history.py`
- [Trace Export](https://github.com/twilliamsa7/syren/blob/main/data/trace.py): `data/trace.py`
- [Replay Engine](https://github.com/twilliamsa7/syren/blob/main/data/replay.py): `data/replay.py`
- [FlightState Schema](https://github.com/twilliamsa7/syren/blob/main/shared/flight_state.py): `shared/flight_state.py`

### Detection & Prediction

- [Detection Engine](https://github.com/twilliamsa7/syren/blob/main/detection/engine.py): `detection/engine.py`
- [Rule Detectors](https://github.com/twilliamsa7/syren/tree/main/detection/detectors): `detection/detectors`
- [Risk Aggregation](https://github.com/twilliamsa7/syren/blob/main/detection/aggregation/risk.py): `detection/aggregation/risk.py`
- [Aircraft Warnings](https://github.com/twilliamsa7/syren/blob/main/ml/aircraft_warning.py): `ml/aircraft_warning.py`

### Map Experience

- [API Server](https://github.com/twilliamsa7/syren/blob/main/backend/server.py): `backend/server.py`
- [Aircraft Map](https://github.com/twilliamsa7/syren/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Gemini Summaries](https://github.com/twilliamsa7/syren/blob/main/backend/gemini.py): `backend/gemini.py`

### Research Pipeline

- [Window Labels](https://github.com/twilliamsa7/syren/blob/main/ml/label_windows.py): `ml/label_windows.py`
- [Feature Extraction](https://github.com/twilliamsa7/syren/blob/main/ml/features.py): `ml/features.py`
- [Event Training](https://github.com/twilliamsa7/syren/blob/main/ml/event_supervised.py): `ml/event_supervised.py`
- [Baseline Training](https://github.com/twilliamsa7/syren/blob/main/ml/train_baseline.py): `ml/train_baseline.py`
- [Model Inference](https://github.com/twilliamsa7/syren/blob/main/ml/predict.py): `ml/predict.py`
- [Warning Evaluation](https://github.com/twilliamsa7/syren/blob/main/evaluation/early_warning.py): `evaluation/early_warning.py`

### Simulation

- [Scenario Generator](https://github.com/twilliamsa7/syren/blob/main/simulation/generate.py): `simulation/generate.py`
- [Flight Runner](https://github.com/twilliamsa7/syren/blob/main/simulation/run.py): `simulation/run.py`
- [Anomaly Scenarios](https://github.com/twilliamsa7/syren/blob/main/simulation/anomalies.py): `simulation/anomalies.py`

### Other components

- **Operator**
- **adsb.lol Feed**
- **History Archive**
- **Gemini API**

## Connections

- Operator → Aircraft Map: uses (evidence: `README.md`)
- Aircraft Map → API Server: requests API (evidence: `README.md`)
- Operator → API Server: starts replay (evidence: `backend/server.py`)
- API Server → History Manager: checks history (evidence: `backend/server.py`)
- API Server → Replay Engine: controls replay (evidence: `backend/server.py`)
- History Manager → History Archive: downloads traces (evidence: `README.md`)
- adsb.lol Feed → Live Adapter: provides reports (evidence: `README.md`)
- Live Adapter → FlightState Schema: normalizes reports (evidence: `data/live_adapter.py`)
- Live Adapter → Detection Engine: runs detection (evidence: `data/live_adapter.py`)
- Live Adapter → Aircraft Warnings: evaluates warnings (evidence: `data/live_adapter.py`)
- History Manager → Trace Export: supplies traces (evidence: `data/trace.py`)
- Replay Engine → History Manager: loads history (evidence: `data/replay.py`)
- Replay Engine → Trace Export: reads traces (evidence: `data/replay.py`)
- Replay Engine → Detection Engine: runs detection (evidence: `data/replay.py`)
- Replay Engine → Aircraft Warnings: evaluates warnings (evidence: `data/replay.py`)
- Detection Engine → Rule Detectors: dispatches rules (evidence: `detection/engine.py`)
- Detection Engine → Risk Aggregation: combines risk (evidence: `detection/engine.py`)
- Operator → Gemini Summaries: asks about aircraft (evidence: `README.md`)
- API Server → Gemini Summaries: starts questions (evidence: `backend/server.py`)
- Gemini Summaries → Gemini API: requests summary
- Window Labels → Feature Extraction: extracts features (evidence: `ml/label_windows.py`)
- Event Training → Feature Extraction: uses features (evidence: `ml/event_supervised.py`)
- Event Training → Window Labels: uses labels (evidence: `ml/event_supervised.py`)
- Baseline Training → Feature Extraction: uses features (evidence: `ml/train_baseline.py`)
- Baseline Training → Window Labels: uses labels (evidence: `ml/train_baseline.py`)
- Baseline Training → Model Inference: trains inference (evidence: `ml/train_baseline.py`)
- Warning Evaluation → Detection Engine: evaluates alerts (evidence: `evaluation/early_warning.py`)
- Warning Evaluation → Aircraft Warnings: evaluates warnings (evidence: `evaluation/early_warning.py`)
- Scenario Generator → Flight Runner: generates flights (evidence: `simulation/generate.py`)
- Scenario Generator → Anomaly Scenarios: injects scenarios (evidence: `simulation/generate.py`)
- Flight Runner → FlightState Schema: emits states (evidence: `simulation/run.py`)
- Flight Runner → Anomaly Scenarios: applies anomalies (evidence: `simulation/run.py`)
- Flight Runner → Detection Engine: tests detectors (evidence: `backend/demo_server.py`)
- Aircraft Map → Aircraft Map: renders map (evidence: `frontend/src/App.tsx`)
