Inside Gaim.zone: A Fully Serverless Platform for Running Local Sports Leagues
League management, player registration and a live, real-money-free bidding room for up to 160 players — on Lambda, API Gateway, DynamoDB and Step Functions, with no server we manage.
Gaim.zone is an app for running local sports leagues: player registration, franchise management, live player auctions, and match schedules — built for cricket, football and half a dozen other sports, played by groups who used to organise all of this in a WhatsApp group and a notebook. None of it runs on a server we manage. Everything — the API, the real-time auction room, the background jobs — runs on AWS Lambda behind API Gateway, backed by DynamoDB, S3 and Step Functions, with the whole stack defined in AWS CDK.
This post is the tour we wish we'd had when we started: how the pieces fit together, why we split the backend the way we did, and three mistakes that taught us more about serverless than any tutorial did.
The shape of the backend
There is no single "backend" service. The product splits cleanly along domain lines, and the backend splits the same way — a small family of independently deployed services, each with its own AWS CDK stack, its own DynamoDB tables, and its own Lambda functions behind its own API Gateway. Roughly:
- League — league creation, schedules, squads, sponsors. The biggest service, and the one most other services end up calling.
- Player and Franchise — profiles, registration, enrolment requests.
- Auction — the live bidding engine. Its own service because its traffic shape is nothing like the rest: near-silent for days, then a room full of people bidding in real time for two hours.
- User and Association — accounts, organisations, roles and permissions.
- A delivery-worker service that owns every push notification and WhatsApp message, so no other service has to know how to talk to a notification provider.
A single CloudFront distribution sits in front of all of them, routing by path prefix to the right service — the app only ever talks to one hostname. Internally, services call each other over plain authenticated HTTP, never by reading another service's data directly.
Correction, added after we went back and actually checked: this section originally said each service keeps its own DynamoDB tables too. It doesn't. Thirteen of them write into one shared table — a single-table design, not sixteen separate ones — and only three keep a table of their own, for reasons specific to each. We wrote up the real shape of that separately, in a dedicated post, once we'd gone looking at what was actually running in production.
The auction room: WebSockets plus a state machine
The auction is the part of the product people actually watch — up to sixteen franchises bidding live for a pool of as many as 160 players, each lot settled in a thirty-second window that a bid extends. The room is an API Gateway WebSocket API: every connected phone or browser holds a connection, and every bid, sale or pause is a message broadcast to the room over those connections, fanned out from a single Lambda function.
The interesting design decision isn't the WebSocket layer — it's how we represent a running clock in a system with no servers sitting there counting seconds. A lot's deadline is a single absolute timestamp stored in DynamoDB, not a timer object anywhere. A Step Functions execution sleeps until that timestamp, wakes up, and re-reads the same field before deciding whether to close the lot.
// Simplified shape of what the closure step does on wake:
const lot = await readLot(auctionId, lotId);
if (lot.auction_ends_in > now()) {
// Someone moved the deadline while we slept — go back to sleep
// until the NEW time instead of closing early.
await sleepUntil(lot.auction_ends_in);
return;
}
await closeLot(lot);That one property — the deadline is data, not a running timer — is what makes every owner control on the lot (extend the clock, pause it, close it early) a single conditional write instead of a small distributed-systems problem. Pausing a lot is just moving its deadline into the past and remembering how much time was left; resuming restores the deadline and lets the sleeping execution notice for free. We didn't design it this way on day one — we backed into it after the first version, which kept a countdown in application memory, lost the plot the moment a bidder's phone reconnected mid-lot.
Three things DynamoDB taught us the hard way
1. A transaction can't touch one item twice
Closing a sold lot already writes several things in one transaction: the team's remaining points, the item's new owner, the activity log. We later added a feature that let an owner sell a paused lot directly, and its first version added extra condition checks onto rows that the existing closure code already wrote in the same transaction. DynamoDB refuses that outright — a TransactWriteItems call that references the same item twice fails with a ValidationException, full stop, regardless of what the two writes actually say. The fix wasn't a workaround; it was folding the new guard into the same write the builder already produced, so every item appears in the transaction exactly once. We added the same check to our local test double for DynamoDB once we understood it, so the next feature that makes this mistake fails in a unit test, not in front of a room full of bidders.
2. Lambda's recursion guard is watching your event loops
Part of the auction pipeline reacts to its own events — a state change triggers a broadcast, which can trigger a follow-up state change. That's an easy shape to get slightly wrong, and when we did, Lambda's built-in recursion detection stepped in and silently terminated the loop partway through — which is the safe outcome for your AWS bill, and a confusing one for a bidder watching a lot that simply never resolved. The real fix was breaking the cycle in our own code; the detection just made the symptom visible quickly instead of as a runaway invocation count three hours later. It's a good reminder that "serverless" doesn't mean reasoning about control flow goes away — it means the platform has guard rails for the control-flow bugs you will eventually write.
3. Design for "every auction must finish"
An auction that stalls — host disconnects, a device crashes mid-lot, nobody taps anything for ten minutes — isn't a bug report, it's a league that can't run its season. So that became a product rule, not just an engineering nice-to- have: however an auction is created, it has to be able to run to completion. In practice that's an idle-timeout that auto-finishes a silent auction, a "fill the rest at base price" action for whatever's left unsold, and an admin-only rescue path, behind its own authorization check, for the handful of cases neither of those covers. We keep a written matrix of every way an auction can be created and what happens to it in each failure mode — it's the kind of document that's boring to write and has saved us from shipping the same outage twice.
Everything else, briefly
- Storage. DynamoDB for everything transactional, S3 + CloudFront for player photos, league crests and exported PDFs — presigned at read time, nothing served directly off a public bucket.
- Background work. SQS queues decouple anything that doesn't need to block a response — the notification worker, league-sync jobs, analytics writes.
- Infrastructure. Every service is a CDK app. Dev and prod are separate AWS accounts, not separate stacks in one account — a mistake in a dev IAM policy or S3 bucket policy can't reach production data because there is no production data in that account to reach.
- Static frontends. This site and our browser-playable practice auction are both statically exported Next.js / Flutter-web builds served from S3 through the same CloudFront distribution — no origin server for either.
What we'd tell someone starting this today
Pick the boundary between services on domain lines before you pick anything else — ours have moved less in two years than almost any other architectural decision we made. Treat a "timer" in a distributed system as data to be read, not state to be held in memory. And write down, in plain language, what happens when the thing you built fails halfway — because in a system with no server to ask "what state were you in?", that document is often the only source of truth you have left.
We'll be writing more from this codebase — the real-time presence layer behind the auction room, how we test a DynamoDB-backed state machine, and the S3 bucket-policy mistake that taught us to audit every CDK-managed policy by hand.
See the auction room in action
Run a free practice auction in your browser — no sign-up required to watch, no real money anywhere in the bidding.
🎯 No real-money auctions · Pure strategy · Free to download