system lane · 2026
Lumen List
A family gift registry that keeps gifts a surprise at the database level, so a gift owner can never see who claimed the items on their own list.
- data (not covered)
- model (not covered)
- eval (covered)
- serve (covered)
- monitor (not covered)
Live at lumenlist.app and used by a few families. Runs on AWS for pennies a month, and a database test suite proves on every PR that owners can't see claims.
stackNext.jsTypeScriptPostgreSQLRow Level SecurityNeonDrizzleBetter AuthAWS LambdaCloudFrontTerraform
linksFamilies share wishlists and claim gifts for each other so nobody buys the same thing twice. The rule that keeps gifts a surprise is enforced with Postgres row-level security policies, so even a bug in the app can’t show someone who claimed the items on their own list.
I designed and built it with Claude Code.
Architecture
A page request reaches CloudFront, which serves static files straight from S3 and sends everything else to one Lambda running the Next.js app. The Lambda is stateless, so a request carries everything it needs and nothing is kept between invocations.
The Lambda talks to a single Neon database through two doors that never overlap. Better Auth uses the auth_service role to read and write sessions and passwords, and it can’t see a gift. Every other query goes through app_user, which can’t see the auth tables and can’t skip row-level security. A third role, the database owner, only runs migrations from the pipeline and never exists inside the Lambda.
How data flows
- A request arrives with a session cookie. Better Auth checks it and caches the result for five minutes so most requests skip the auth tables.
- A server action calls
withUser(userId), which opens a transaction and sets the user id on it. - Postgres applies the policies to every query in that transaction. Without a user set, each app table returns zero rows.
- Anything that has to cross a family boundary, such as accepting an invite or previewing who invited you, goes through a small
SECURITY DEFINERfunction that checks its own inputs and returns only what the caller needs.
How the surprise is protected
The policy on claims lets you see a claim if you made it, or if you share a family with the gift’s owner and aren’t the owner. The owner is excluded by the database, so a bug in a page, an API route or a future feature can’t leak a claim. A database test suite runs the policies against Postgres 18 in Docker on every pull request and proves it. Playwright end-to-end tests cover the full flows, and refuse to run against production.
Environments
Dev, staging and production each get their own Neon branch, and develop, the release branches and main deploy to the matching one. The dev and staging branches are created empty from an empty production branch, so no real wishlist or email address exists outside production. Since auth lives in the same database, branching copies the auth data and the app data together. A demo family seed fills a dev branch for testing, and a nightly job dumps production and checks row counts.
Cost
Neon runs on its free tier and AWS costs pennies a month, since Lambda and CloudFront only bill for use. The one fixed cost is the yearly domain registration at Cloudflare.
Decisions and tradeoffs
- Supabase to Neon and Better Auth. I wanted more control over the data, and I wanted to avoid the pauses Supabase applies to inactive projects. The row-level security policies moved over without trouble, and an importer kept every user’s id and password hash so nobody had to sign up again. It checked row counts, logins and the surprise rule against the backup before cutover.
- Self-hosted auth. Auth data lives in the same database as everything else, so it branches and tests locally with it, and there is no per-user billing.
- Hosting on AWS. Vercel’s free plan doesn’t build repositories owned by an organization, so the move to AWS happened when the repo moved to one.
What I’d do differently
I started building from an idea without thinking through edge cases, administration, or where the app was going. I made some easy early choices and had to reverse them later. Planning more up front would have saved that rework, as long as I picked scalable options without over-engineering for users I don’t have.