System architecture / addendum
Scaling nationwide
Load · SLOs · observability · deployment · migration
This page is written the way a systems design interview runs. It starts from what this build actually runs, sizes the national problem, shows where today's design breaks, and then lays out what a mission-critical version would look like and how to get there in stages. Numbers marked as estimates are order-of-magnitude reasoning from public figures, not measurements or quotes.
One idea carries most of the design. Every snapshot already has a revision hash, and every briefing and decision is pinned to one. Content that is addressed by its hash never changes, so the read path can be cached at the edge almost for free. The hard scaling problem is the write path: fetching, decoding and modelling fast enough, for every incident, without hammering free public APIs.
Where we are
Today the build covers USFS Region 2 (Colorado, Wyoming, South Dakota, Nebraska and Kansas). It reads 31 public sources. The app runs on Vercel Pro, and Neon Postgres is the one service still on a free tier, which is the right call while it is under construction and the first thing to change for anything real.
| Piece | What it is today | Real number |
|---|---|---|
| Scheduler | Cloudflare Worker cron, plus a daily Vercel cron as backstop | every 10 min |
| Ingest | One Vercel function builds Region 2 snapshots through an archiving feed client | ≤ 12 incidents, ~42 fetches on the first live run, 300 s limit, 5 min lease |
| Payload archive | Cloudflare R2, gzipped and keyed by SHA-256 | 0.5–1 MB per sweep, ≈ 20 MB/day (estimate) |
| Index and decisions | Neon Postgres free tier | 60 day prune on fetch rows, 0.5 GB cap |
| Model | Rothermel surface and crown fire, in the request | milliseconds per incident |
| LLM | Claude briefings and agents for invited users | $5/day site cap, per-user caps |
| Auth | Google OAuth allowlist, public read-only mode | a handful of users |
| Observability | Vercel logs, ingest_runs table, the audit view | no alerting, no on-call |
What is already right, and survives the move: envelopes that record every request and its fetch time, freshness judged per source, revision-hashed snapshots, a briefing floor that never needs the LLM, an append-only decision log, and replay. Those are the properties a mission-critical system needs. The work ahead is mostly plumbing around them.
National requirements
Nationally the load is seasonal and spiky. Most days are quiet; a few weeks a year, several geographic areas are at preparedness level 4 or 5 at once, and that is exactly when the system has to hold.
| Dimension | Order of magnitude | Why it matters |
|---|---|---|
| Fires | About 60,000 wildfires a year (NIFC 10-year average); hundreds of open incidents in peak season, 60 to 100+ of them large | Tracked incidents grow ~25× from Region 2 today |
| Geography | 10 GACCs, CONUS plus Alaska and Hawaii | Natural partition key and blast-radius boundary |
| Users | Dozens of incident management teams, every GACC coordination center, local dispatch, agency administrators, cooperators | A few thousand concurrent internal users on a peak day; public traffic can spike far higher during evacuations |
| Detections | VIIRS from three satellites, MODIS, and GOES scans every 5 minutes (1 minute in mesoscale sectors) | Tens of thousands of points on a bad day, arriving in bursts after each overpass |
| Weather | HRRR hourly at 3 km, about 1.9 million grid cells, 18 to 48 hours out | Upwind and afternoon wind shifts are the core value, so this is the critical feed |
| Freshness targets | Detections within minutes of publication; perimeters within one publication cycle; HRRR within an hour of the run | These become the SLIs below |
Capacity math, and where it breaks
Today each incident fans out into its own weather, forecast and context calls, about 15 per incident. That is fine for 12 incidents and breaks at national scale.
| Quantity | Region 2 today | National peak (estimate) |
|---|---|---|
| Incidents tracked | ≤ 12 | ~300 |
| Upstream calls per sweep | ~42 | ~4,500 with per-incident fan-out |
| Upstream calls per day at 10 min | ~6,000 | ~650,000 |
| Archive written | ≈ 20 MB/day | ~0.5 GB/day before grids; HRRR subsets add a few GB/day |
| Index rows (Postgres) | ~6 MB/day (estimate) | ~150 MB/day, partitioned and pruned |
| Briefings | on demand, capped at $5/day | ~100 large fires × 6 per day, plus agents: tens to low hundreds of dollars a day |
| Map payload | raw GeoJSON per page | national perimeters and detections need vector tiles |
Where the current design breaks, roughly in the order it would happen:
- Upstream quotas. Open-Meteo's free tier is non-commercial and limited to 10,000 calls a day. National point queries blow through it in an hour. Fix: fetch HRRR and GOES as grids from NOAA's open data buckets and sample locally (the fan-in above).
- One function, one lease. A single 300 s function and a single 5 minute lease mean one writer working serially. Fix: a queue keyed by source and GACC, many idempotent workers, and per-partition leases.
- Storage tiers. Neon's 0.5 GB cap lasts days at national volume. Fix: paid Postgres with PostGIS, partitioned by GACC and day, with read replicas.
- Hosting terms. Vercel Pro allows commercial use and crons as often as every minute, so a pilot can stay on it. Fix: containers or functions on AWS for anything sold to an agency that requires them.
- Client maps. Raw GeoJSON is fine for one incident and too heavy for a national view. Fix: a tile pipeline (PMTiles or a tile server) keyed by revision, behind the CDN.
- LLM spend. Per-request generation does not scale with viewers. Fix: generate once per snapshot revision after ingest, cache by hash, and budget per tenant.
- Operations. No alerting means a stale feed is found by a user. Fix: SLOs, burn-rate alerts and an on-call rotation (sections 5 and 6).
Target architecture
The target keeps today's stages and changes how they are wired: queues between stages, workers that can be retried safely, storage partitioned by geographic area, and work triggered by change instead of by page views.
| Stage | Design | Why |
|---|---|---|
| Scheduling | One scheduler per source at its own cadence, using ETag and If-Modified-Since; S3 new-object notifications for HRRR and GOES | Fetch when data changes, not on a clock |
| Queue | SQS or Cloudflare Queues, keyed by source × GACC, with dead-letter queues and a retry budget | Volume is about a gigabyte a day; a log like Kafka adds cost without need until replay streams matter |
| Fetch workers | Idempotent on request hash × time bucket; write raw payload first, then normalize | A retry or duplicate delivery never double-writes |
| Storage | Object storage for raw payloads and gridded data (Zarr or COG); PostGIS partitioned by GACC and day for normalized rows, snapshots and decisions | Spatial queries stay local to a cell; old partitions drop cheaply |
| Snapshot and model | A change event (revision hash moved) triggers the snapshot builder, then model workers; ML inference on CPU is enough for the corrected physics model | Compute follows data changes, not viewers |
| Briefings and agents | Generated once per revision, cached by hash, budgeted per tenant; the template briefing is always produced first | The LLM is additive and never on the critical path |
| Serving | Snapshot API and vector tiles, immutable by revision hash, behind a CDN; the console polls a tiny "latest revision" endpoint | Thousands of viewers of one fire cost one origin read |
| Cells | One cell per group of GACCs, each with its own queue, workers and database partition set | A surge in California cannot starve the Rockies |
Reliability
The measures that matter to an IC are freshness and whether the page answers, not CPU. The SLIs are written from the user's side, and the targets tighten between the pilot and mission-critical stages.
| SLI | How it is measured | Pilot SLO | Mission critical SLO |
|---|---|---|---|
| Feed freshness | Share of minutes each tier-1 feed (FIRMS, WFIGS, HRRR, NWS alerts) is within its freshness limit, per GACC | 99% in season | 99.9% in season |
| Snapshot lag | Time from a feed change landing to a new snapshot revision | p95 < 10 min | p95 < 2 min |
| Console availability | Successful console and API responses, from synthetic probes in each GACC | 99.5% monthly | 99.95% monthly (~22 min) |
| Briefing latency | Time to a cited briefing for the current revision | template p95 < 2 s; Claude p95 < 60 s | template p95 < 1 s; Claude pre-generated before the first viewer |
| Briefing correctness | Share of statements with a valid citation; eval pass rate on the backtest set | 100% citations (hard gate) | 100% citations; eval regressions block release |
| Decision durability | Decisions acknowledged and later readable | no loss | no loss, synchronous replica |
Error budgets are spent in season and earned back out of season: risky migrations, schema changes and model upgrades land between November and March, and a freeze on non-urgent changes starts when national preparedness reaches level 4.
| Failure | What the IC sees | Exists today? |
|---|---|---|
| An upstream feed is down | Last good copy with its age in amber; the briefing says which input is stale | Yes |
| LLM provider is down or over budget | The template briefing, fully cited | Yes |
| Snapshot changed under a decision | A warning listing what changed, with an override that is recorded | Yes |
| Database primary is lost | Read-only from the replica and archive; decisions queue client-side and replay in order | No |
| Region is lost | Fail over to the warm standby region | No |
| No connectivity at the ICP | The edge kit keeps working on cached data and syncs later | No |
| Data | RPO | RTO | Reasoning |
|---|---|---|---|
| Decision log | 0 | 15 min | A legal record; synchronous replica, append-only and hash-chained |
| Snapshots and briefings | ≤ 15 min | 15 min | Rebuildable from the archive by hash |
| Feed archive | ≤ 1 h | 1 h | Mostly re-fetchable upstream; cross-region object copy |
| Model artifacts | per release | 1 h | Versioned in object storage, pinned per snapshot |
Observability
Today the audit view shows the last ingest run and Vercel keeps logs. That is enough to debug, not to operate. The mission-critical version adds:
- One trace per incident revision. OpenTelemetry spans from fetch to normalize to snapshot to model to briefing, tagged with source, GACC and revision hash, so “why is this briefing old” is one query.
- A feed-freshness board. Age of every source in every GACC against its limit. It is the first screen on-call opens, and it doubles as a public status page.
- Queue and worker metrics. Lag per partition, retry and dead-letter rates, and upstream error codes, so a NASA or NOAA outage is distinguished from ours.
- LLM telemetry. Tokens, dollars and latency per incident and tenant, cache hit rate by revision, citation-failure rate, and nightly eval scores on the backtest set.
- Alerting on burn rate. Multi-window SLO burn alerts (fast over 1 hour, slow over 6 hours) page on-call; everything else is a ticket. Each tier-1 feed has a runbook.
- On-call. A follow-the-sun or two-site rotation of at least six engineers in season, with incident review after every page. Audit and access logs go to write-once storage.
Deployment models
| Model | Who it serves | Shape | Main cost |
|---|---|---|---|
| Commercial SaaS | Counties, states, utilities, contractors | Multi-tenant on a commercial cloud, SOC 2, tenant isolation by row and by cell | Lowest; fastest to sell |
| FedRAMP on GovCloud | USFS, DOI agencies, federal IMTs | AWS GovCloud, FedRAMP Moderate to start, agency SSO (PIV, Login.gov, USDA eAuth); Claude through Amazon Bedrock in GovCloud | A 12 to 18 month authorization effort and a continuous monitoring program |
| Agency-hosted | A state or agency that must run it themselves | The same containers and Terraform, delivered into their account | Support and upgrade burden |
| Edge kit | An incident command post with poor connectivity | A rugged box running k3s, Postgres and cached tiles; template briefings and the model run locally; syncs over Starlink or cellular | Hardware, logistics, and sync design |
The decision log is already append-only and hash-chained, which makes edge sync tractable: two logs merge by ordering entries, not by resolving conflicts. The security and ATO path follows from that design:
- Classify the data. Public feeds are public. Resource positions, decisions and pre-release intelligence are controlled; decisions are federal records.
- Map to NIST 800-53. Identity, audit, encryption at rest and in transit, configuration management, incident response. Most controls inherit from the cloud provider.
- Supply chain. SBOMs, signed builds, pinned dependencies, and model artifacts versioned like code.
- LLM boundary. Prompts carry only the snapshot facts the briefing cites; no secrets, no free-text PII; every output is logged with its inputs by hash.
- Interoperability. IRWIN for incident identity, TAK and Cursor-on-Target out to the field, AVL in when agencies share it.
Phased migration
Each phase is usable on its own, and each one is triggered by a real limit, not by ambition. The costs below are itemized from approximate public list prices for a month in fire season. They are planning estimates, not quotes, and they leave out salaries.
| Phase | Trigger | What changes | Monthly cost (estimate) |
|---|---|---|---|
| 0 · Today | Under construction | Region 2, Vercel Pro, Neon free tier, one function | about $20 plus up to ~$150 of LLM |
| 1 · Western pilot | A real user group in two to four GACCs | Paid Postgres with PostGIS, grid fetch for HRRR and GOES, Cloudflare Queues, SLO dashboards, pre-generated briefings | ~$150 infrastructure, $300 to $2,000 LLM |
| 2 · National, lean | Paying tenants across CONUS | Stay on Cloudflare and managed Postgres: Workers and Queues, R2, PMTiles, one small container for GRIB decoding, Grafana Cloud | $700 to $2,500 infrastructure, $1,000 to $6,000 LLM |
| 2b · National, full AWS | Customers who require AWS or SOC 2 evidence from it | Aurora PostgreSQL with a replica, Fargate workers, CloudFront and WAF, a paid observability vendor, SOC 2 tooling | $8,000 to $18,000 including LLM |
| 3 · Mission critical | Federal adoption | GovCloud in two regions, FedRAMP Moderate, cells by GACC, edge kits, 99.95% SLO, formal DR tests | $15,000 to $30,000 infrastructure, plus ~$15,000 to $25,000 of compliance |
| Line item | Pilot | National, lean | National, full AWS | Federal (GovCloud) |
|---|---|---|---|---|
| App hosting | Vercel Pro, ~$50 | Vercel Pro or Workers, $150 to $400 | Fargate and ALB, $800 to $1,500 | Fargate in two regions, $2,000 to $4,000 |
| Ingest and queues | Workers Paid, ~$10 | Workers and Queues, $50 to $200 | SQS and Lambda, ~$50 | SQS and Lambda, ~$100 |
| GRIB decoding and tiles | in the ingest worker | one small container, $50 to $150 | Fargate tasks, $200 to $400 | Fargate in two regions, $400 to $800 |
| Postgres with PostGIS | $20 to $70 | primary and replica, $300 to $800 | Aurora with a replica, $1,500 to $2,500 | Aurora in two regions, $4,000 to $6,000 |
| Object storage | R2, ~$1 | R2, $15 to $50 (no egress fees) | S3, $100 to $300 | S3 with cross-region copy, $300 to $600 |
| CDN, egress and WAF | included | included with Cloudflare | CloudFront and WAF, $500 to $1,700 | $1,000 to $3,000 |
| Networking | none | none | NAT gateways, $100 to $300 | $300 to $800 |
| Observability | Grafana Cloud free | Grafana Cloud and Sentry, $50 to $300 | Datadog-class vendor, $2,000 to $5,000 | FedRAMP SIEM and logging, $3,000 to $8,000 |
| Security tooling | none | none | SOC 2 platform, $1,000 to $2,000 | scanning and posture tools, $1,000 to $3,000 |
| Agency SSO | Google OAuth | $0 to $500 | $0 to $500 | PIV and Login.gov integration, mostly staff time |
| On-call paging | none | ~$150 | ~$150 | ~$300 |
| Edge kits | none | none | none | about 20 kits amortized over three years, ~$3,000 |
| LLM briefings and agents | $300 to $2,000 | $1,000 to $6,000 | $1,000 to $6,000 | Claude on Bedrock GovCloud, $2,000 to $8,000 |
| Audit and authorization | none | none | included above | third-party assessment and continuous monitoring, ~$15,000 to $25,000 amortized |
The lean national design does the same work as the full AWS one: the data is about a gigabyte a day, which one Postgres primary, a queue and a few workers handle easily. The full AWS column is worth paying for only when customers need it, usually for SOC 2 evidence, an existing AWS contract, or a later move into GovCloud.
Why the federal version costs several times the national one, at the same load:
- Authorized services only. Vercel, Neon and most of Cloudflare are out. GovCloud list prices run roughly 20 to 30% above commercial AWS.
- A second live region. A 99.95% target with a decision log that cannot lose a write needs a standby region that is always running, which roughly doubles the infrastructure.
- Mandatory tooling. FedRAMP logging and SIEM, vulnerability scanning, FIPS-validated encryption and a WAF are fixed costs that do not shrink with load.
- Audit and continuous monitoring. An annual third-party assessment and monthly monitoring reports cost about as much as the hosting. The 12 to 18 month authorization effort is mostly staff and sits outside these numbers.
Tradeoffs an interviewer would push on
| Question | Answer |
|---|---|
| Why not Kafka? | About a gigabyte a day of payloads. Queues with dead-letter handling are simpler and cheaper; a log becomes worth it when many consumers need to replay streams. |
| Why Postgres and not a time-series database? | The queries are spatial and relational (which detections sit inside which perimeter). PostGIS does that well; time partitioning covers the time-series need. |
| Push or pull? | The sources are pull-only HTTP. Pull with conditional requests, and use object-store notifications where NOAA offers them. |
| What is the unit of consistency? | One incident snapshot revision. Everything downstream is keyed by its hash, so readers never see a half-updated picture. |
| Is the LLM on the critical path? | No. The template briefing is the floor and is always produced. The LLM adds, it never gates. |
| Why not a one-minute cadence everywhere? | Most sources publish far less often. Cadence follows each source, and change events drive the rest. |
| Multi-tenant or one deployment per agency? | Multi-tenant cells for commercial; the same artifacts deployed per agency where authorization demands it. |
| How does it handle one fire with 10,000 viewers? | Immutable, hash-addressed snapshots and tiles behind a CDN; the origin serves only a small "latest revision" pointer. |
| How do you test a system like this? | Recorded fixtures for every adapter, historical backtests for the model, replay of real decisions, and game days that kill a feed or a region in the off season. |
Back to the system architecture.