Architecture
Built for the worst 10 minutes of the year.
The rule: the hot path only touches things that scale horizontally. The spike is absorbed at the edge, admission is metered, inventory is reserved atomically, and payments are idempotent and multi-provider. Search, analytics and the copilot sit off the hot path and can degrade without hurting a sale.
01 / Production target
The platform, at 100k fans in 10 minutes
Clients
Fan web + native app● in prototype
wallet, offline tickets, squads, push
Organizer console● in prototype
self-serve, copilot, live control
Gate scanners● in prototype
offline verify, sync later
Partner API
white-label, embeds, webhooks
Edge
absorbs 100% of the spike
CDN + static event pages● in prototype
pre-rendered, cached at the edge
WAF + bot management
IP/ASN reputation, TLS/JA4 fingerprints
Waiting room● in prototype
PoW, signed tokens, T-0 lottery
Token rate limits● in prototype
per token, not per IP (CGNAT)
Hot path
stateless, autoscaled, metered by admission
Admission controller
rate follows PSP health + stock
Checkout API● in prototype
stateless, idempotent
Inventory● in prototype
sharded Redis counters + Postgres truth, holds with TTL
Payment orchestrator● in prototype
routing, circuit breakers, idempotency
Risk engine
device, behaviour, payment graph
Core
async, event-driven
Orders & ledger
double-entry, append-only
Ticket mint & wallet● in prototype
per-ticket keys, rotating codes
Transfers & resale● in prototype
capped price, re-issue on transfer
Identity & squads
Payouts
T+2 settlement, royalties
Data
PostgreSQL
orders, ledger, tickets
Redis● in prototype
queue, holds, counters
Kafka / Redpanda
outbox → events
ClickHouse
real-time organizer analytics
Intelligence
Organizer copilot● in prototype
LLM + typed tools, human approves
Demand forecasting
Fraud models
02 / One purchase
End to end
- 01Edge. The event page is static HTML from the CDN. Joining the queue costs one PoW and returns a signed token.
- 02T-0 lottery. Tokens issued before T-0 are shuffled with a seed committed in advance, so arriving early buys nothing.
- 03Admission. N tokens/s pass through. N follows payment success, checkout p95 and remaining stock.
- 04Hold. An atomic Lua decrement on a sharded counter plus a hold with a 10 min TTL. No locks across requests.
- 05Pay. One idempotency key per attempt. The router picks a PSP by health and cost; when a breaker opens, it retries on PSP-B with the same key.
- 06Commit. Order + ledger + outbox in one Postgres transaction. Consumers mint tickets, notify and update analytics.
- 07Reconcile. Late PSP webhooks are matched by key and duplicates voided. Expired holds return to the pool.
- 08Gate. HMAC + time window verified offline; scans sync later; duplicates flagged across gates.
03 / This prototype
What actually runs
FrameworkNext.js 16 · App Router · React 19 · TurbopackEvent pages pre-rendered at build (SSG) and served from the CDN; APIs are Route Handlers, deployable on any Node host or container.
Hot stateUpstash Redis (serverless, HTTP)Queue counters, inventory, idempotency keys, rate limits, presence, live stats. Inventory uses a Lua script: check + decrement in one atomic step.
Waiting roomSigned PoW challenges + JWT (jose, HS256)Challenges are HMAC-signed, single-use (SET NX) and expire in 2 min. The queue token is required by checkout.
CheckoutIdempotency-Key + atomic reserve + PSP failoverSame key → same answer, never a second charge. The PSP outage is simulated, but the timeouts and routing are real awaits on the server.
TicketsPer-ticket HMAC keys derived from a platform secretCodes rotate every 15s. /api/gate re-derives the key, checks the window, and blocks duplicates with SADD.
LotteryCommit–reveal draw, verifiable by anyonesha256(seed) is published before entries close; at the draw the seed is revealed and each entry ranks by sha256(seed:entryId). The browser re-verifies both with WebCrypto.
Fan marketWaitlist + listings as Redis FIFO queuesJoining pops a listing, listing pops a waitlister (atomic LPOP, never double-matched). Ownership is proven with the per-ticket key; on claim a new ticket is minted and the old code is revoked at /api/gate.
Festival modeSite map, now/next, bar pre-orders, cashless, SOSBar orders are validated and priced on the server. Queue times and friend positions are simulated in the demo (production: scan rates, POS data, opt-in location).
Ask the festivalClaude Opus 5.5 via the Anthropic SDK, streamedGrounded only in the event’s lineup, map, rules and the fan’s ticket; knowledge block prompt-cached. Without an API key a local answerer uses the same data.
Live statsServer-Sent Events from a Route HandlerOne stream per tab, snapshot every 1.5s from Redis. The p50/p95/p99 shown is measured inside the handlers.
Abuse limitsFixed-window rate limits per IPOn challenge, checkout, gate and the stress test. Being limited shows up as a live counter.
Design systemTailwind CSS v4 · Geist · Geist Mono · motion · View TransitionsFonts self-hosted via next/font (no layout shift, no third-party requests). Route changes use React <ViewTransition>; in-page motion uses springs and respects prefers-reduced-motion.