Decision ADR-0004 · The Lighthouse
DynamoDB single-table design
Accepted ·
Context
Durable data includes visitor profiles, achievements, ELO, garden plants, post stats, leaderboards, daily analytics, pixel events, contact messages and uptime probes.
The access patterns are known up front, and the data volume is small. Writes come in bursts, triggered by events.
Decision
- One on-demand table,
KenilPortfolio, with genericPK/SKkeys, aGSI1for moderation queries, TTL for ephemeral items, and point-in-time recovery. - Leaderboards use
LB#<game>#<period>/<invertedScore>#<userId>, so a single Query returns the top N. - Writes from the real-time server are batched every 2 s using
BatchWriteItem, with ULIDs so retries are idempotent.
Consequences
- + Costs a few cents a month and needs no servers.
- + Reachable from the private EC2 instance through a free gateway endpoint.
- + Demonstrates single-table modelling.
- − Ad-hoc analytics need pre-aggregated items (
DAY#…) instead of SQL.