# Airport Cyber Resilience Simulator — V2

A standalone V2 upgrade of the kiosk-grade airport cyber-attack simulator. A
server-authoritative FastAPI engine runs a **per-second dynamic multiplier math
loop**, scaled to a chosen UK airport's economic profile, and streams live state
to an immersive React + GSAP command-center UI.

## Quick start

```bash
cd airport-cyber-sim-v2
docker compose up --build       # then open http://localhost:8000
```

Local (Python 3.11+):

```bash
cd backend
pip install -r requirements.txt
uvicorn main:app --host 0.0.0.0 --port 8000
```

## Helper scripts

**Windows:** `.\sim.ps1 up | down | logs | rebuild | status | open`
**macOS/Linux/WSL:** `make up | down | logs | rebuild | status`

## What's new in V2

- **Initial Configuration Screen** — pick from **29 UK passenger airports**
  (`data/airports.json`), toggle simulation audio, then Initialize.
- **Dynamic multiplier math engine** — `Total_Loss = Operational_Cost +
  Regulatory_Fines + Mitigation_Costs`, recomputed every second and scaled by
  the airport's `base_revenue_per_sec` and `regulatory_fine_multiplier`.
- **26 infrastructure nodes** (`data/infrastructure.json`) and **9 attack
  playbooks** (`data/playbooks.json`).
- **5-second launch countdown** — the clock, financial bleed and ingress
  indicators do not start until it reaches zero.
- **Crisis Communications** — proactive statement window → reactive media
  barrage (flashing phone/email) → communications blackout, each changing the
  reputational-loss multiplier.
- **Dynamic runway lighting strip** — bright / dimming-flicker / dark, tracking
  the `runway_lighting` node's capacity.
- **Synthesised Web Audio soundscape** — boot swell, countdown ticks, ingress
  thud, line crackle, relay clicks, phone ring, email chirp; toggle any time.
- **Odometer financial ticker** (GSAP) shifting White → Amber → Neon-Red, and
  floating "-£X Regulatory Penalty" text off breached nodes.

Retained from V1: fixed 1920×1080 kiosk layout, touch/mouse hit targets, 90s
idle → attract loop, hover/click node overlays, and explicit NCSC **CAF** +
**UK Cyber Security and Resilience Bill** regulatory alignment.

## Mitigation trade-offs

| Option | Spread effect | Capacity | Cost |
|--------|---------------|----------|------|
| 1 · ISOLATE NODE | Severs links, halts spread | → 0% (runway lights dark) | Max operational bleed |
| 2 · REDUCE / THROTTLE | Slows spread 80% | → 40% (lights dim/flicker) | Moderate |
| 3 · STOP ATTACK (PATCH) | Reverts to normal if 15s patch beats next spread tick | unchanged | £50k flat fee |

## Architecture

| Layer | Tech | Role |
|-------|------|------|
| Backend | Python 3.11 · FastAPI · asyncio · WebSockets | 1 Hz math engine, state machine, crisis comms |
| Frontend | React + htm · GSAP · Web Audio (all vendored) | Config screen, topology map, audio, animation |
| Config | JSON in `backend/data/` | Airports, nodes, links, playbooks — no code changes |

All frontend libraries are vendored under `backend/static/vendor/`, so the
container needs **no runtime internet access**.

## WebSocket protocol (`/ws`)

Client → server: `configure` · `launch` · `mitigate` · `comms` · `reset`
Server → client: `config_ok`, `launch`, `ingress`, `compromised`, `spread`,
`spread_blocked`, `fine`, `mitigation`, `patch_start`, `patch_complete`,
`comms_state`, `metrics`, `tick`, `sim_complete`, `reset`.
