How trafficinc/sam-simulator works
This is a modular air-defense simulation lab: hostile units generate truth-state, the shield evaluates tracks and assigns defensive effectors, and the hub brokers role updates into an operator-facing dashboard and scenario assessment. The principal loop runs through separate Pilot and Shield clients exchanging snapshots with the Hub. The graph also preserves scenario authoring, shared contracts/configuration, and dashboard capabilities. Unsampled frontend and configuration details are included only where the README or tree supports their role; edges reflect documented or excerpted wiring.
Main entry points: broker.py WebSocket broker · config_loader.py Scenario loader · app.js Tactical dashboard · app.py Hub API
Components 18
Hub and dashboard
- Hub API
hub/app.py - WebSocket broker
hub/broker.py - World state and assessment
shared/messages.py - Tactical dashboard
frontend/assets/app.js
Hostile simulation
- Pilot client
pilot/client.py - Hostile truth model
pilot/truth.py - Scenario templates
scenarios/base.py - Scenario loader
scenarios/config_loader.py - Raid scenarios
scenarios/default_layered_raid.py - Saturation raid
scenarios/group_saturation_raid.py
Air defense
- Shield client
shield/client.py - Doctrine and engagement engine
shield/logic.py
Contracts and configuration
- Role message contract
shared/messages.py - SAM battery configuration
shared/sam_config.py - Defended-zone configuration
shared/zone_config.py - Scenario configuration
config/scenarios - Defense configuration
config
Other components
- Operator
Connections 23
- Operator → Tactical dashboard: operates
README.md - Tactical dashboard → Hub API: requests controls
README.md - Hub API → WebSocket broker: routes WebSockets
hub/app.py - WebSocket broker → World state and assessment: merges updates
hub/broker.py - WebSocket broker → Tactical dashboard: broadcasts snapshots
hub/broker.py - Hub API → Tactical dashboard: hosts interface
hub/app.py - Pilot client → WebSocket broker: sends role updates
README.md - WebSocket broker → Pilot client: broadcasts snapshots
hub/broker.py - Pilot client → Hostile truth model: generates tracks
pilot/client.py - Hostile truth model → Scenario templates: uses templates
pilot/truth.py - Scenario loader → Scenario templates: builds definitions
scenarios/config_loader.py - Scenario loader → Raid scenarios: fallback definitions
scenarios/config_loader.py - Scenario loader → Saturation raid: fallback definitions
scenarios/config_loader.py - Scenario loader → Scenario configuration: loads JSON scenarios
scenarios/config_loader.py - Shield client → WebSocket broker: sends role updates
README.md - WebSocket broker → Shield client: broadcasts snapshots
hub/broker.py - Shield client → Doctrine and engagement engine: evaluates snapshots
shield/client.py - Doctrine and engagement engine → Role message contract: uses snapshot helpers
shield/logic.py - Doctrine and engagement engine → SAM battery configuration: loads batteries
shield/logic.py - Role message contract → SAM battery configuration: loads battery defaults
shared/messages.py - Role message contract → Defended-zone configuration: loads defended zones
shared/messages.py - SAM battery configuration → Defense configuration: reads battery settings
- Defended-zone configuration → Defense configuration: reads zone settings