<aside> 🔄

Partly superseded (2026-10-31). This spec described a client-first app with an optional OpenRouter gateway and a Supabase or edge cache. The design has since changed: OpenRouter is a required part of every decode, the app is three-tier (Vercel + Supabase), and MVP 1 is decode-only about the job. The current records are ADR-0006 (three-tier), ADR-0007 (grounded LLM matching), ADR-0008 (data integrity), and ADR-0009 (security, resilience, gates), with the readable versions on the Data Architecture and Security, Resilience & Quality Gates pages. The scale and cost reasoning below still reads true; the "client-first / opt-in gateway" framing is replaced. Scoring is now proportional per ADR-0039 (2026-11-04): a per-hat share with full / partial / none match levels at the 25% line, tools excluded, and the overall title-fit by Formula D over the standard hats. The "match-score inputs" and "matched / missing / out-of-scope" framing in §5 predates it.

</aside>

Scope: the server, database, data-engineering, agent/model, security, and scalability decisions behind MVP #1. Companion to the Technical Requirements & Build Plan. Decode-only MVP, no accounts, opt-in LLM via OpenRouter.

0. Reconciliation: "no backend" vs "server + database"

Hat Check is client-first: the default experience runs entirely in the browser against a bundled framework-data snapshot, with all user work stored on-device. There are no user accounts and no user database, ever.

The only server-side component is a minimal, stateless, serverless inference gateway plus an edge cache. They exist for one reason: to run the opt-in OpenRouter decode safely and cheaply. They never store user identity or user records. If funding becomes "bring your own API key," even this layer can be removed and the client can call OpenRouter directly.

Client (always) + CDN (static) + serverless inference gateway (opt-in only) + edge cache/KV (cost control, no PII) + a build-time data pipeline (no runtime server).

1. System topology

Component Role
Client SPA Static files from a CDN; runs the pipeline (default on-device) and persists to the browser
Framework snapshot Versioned, read-only data artifact on the CDN, loaded and cached by the client
Inference gateway Serverless/edge function; holds the OpenRouter key, injects framework grounding, calls OpenRouter, returns structured results. Stateless; scales to zero
Edge cache / KV Content-hashed decode-response cache + rate-limit counters + anonymous metrics. No PII. TTL'd
Build-time data pipeline CI job that turns the upstream framework into the snapshot + indexes + embeddings

2. Server build: serverless inference gateway

Why serverless/edge: pay-per-use, scales to zero when idle and to millions when busy, no servers to run. The cheapest way to support 1M users whose LLM use is opt-in and bursty.

Responsibilities (only these):

Non-responsibilities: no auth, no sessions, no user storage, no business logic that belongs on the client.

3. Database build: cache & control plane, not user data