How Quackers works, behind the curtain
Quackers is a duck-finding game that Mitchell designs and builds with his dad. On the surface it's hidden ducks, worlds and mini games. Underneath, it's a small but real web system: a static front end, a serverless API split into three small programs, and a database with strict rules about what it keeps. This page walks through all of it.
- Front end
- Plain HTML, CSS, JS
- Hosting
- GitHub Pages
- API
- 3 Cloudflare Workers
- Database
- Cloudflare D1 (SQLite)
- Cost to run
- Free plan
The map: three parts, two jobs
Almost every app online splits into the same pieces: what you see, the code that answers questions, and the place where answers are stored.
The front end is the game itself. GitHub Pages hands your browser a set of files once, and from then on the game runs entirely on your device. Your progress is saved right there too, in the browser's local storage.
The Workers are small programs that run on Cloudflare's network, close to wherever the player is. Each one only wakes up when a request arrives, does its job in a few milliseconds, and goes back to sleep. That's what "serverless" means: no computer of ours sitting there waiting. Quackers has three, and each has one job: quackers-api answers the game, quackers-words checks words, and quackers-stats runs the grown-ups' stats page.
D1 is the database. It's SQLite, the same database engine that's inside most phones, run by Cloudflare. Only the Workers can reach it. The game never touches the database directly.
Notice the two separate jobs. Delivering the game is one job (GitHub). Shared things like the leaderboard and the Idea Box are another (Cloudflare). If the second one is down, the game still plays.
The front end: one file, built from many
No framework, no app store, no install step. The whole game ships as a single web page.
While it's being built, the game lives in about 30 small source files: one per world (yard, manor, sea, snow, theater, city, mall, space), one for the mini games, one for the leaderboard and Idea Box, the art, the styles, and so on. Small files are easier to change without breaking something else.
A short Python script, build.py, stitches them into one index.html of roughly 350 KB. That's the file GitHub Pages serves. One file means one download, and the game is ready.
Because it's a web app with a manifest, you can add it to a phone's home screen and it opens full screen like a real app.
Your save game never leaves your device. The browser keeps which ducks you found, your Pond Points and your settings in local storage. The server only gets a summary for stats and the leaderboard, and the game never waits for it. If the network is gone, you keep playing.
A request's trip
Here's what happens, step by step, after you find a duck.
A request is a message from the game to a Worker. Pings go to the game Worker, quackers-api. It goes to an address called an endpoint, like /v1/ping, and carries data in JSON, a simple text format for lists and labelled values. Every request travels over HTTPS, so it's encrypted on the way.
This is roughly what a ping looks like. The ID is random letters and numbers the game makes the first time it runs. Nothing in it says who you are.
{
"pid": "r7k2…random…m9qx", // random device ID
"device": "tablet", // phone, tablet or computer
"mode": "app", // home-screen app or browser
"ducks": 42,
"worlds": 3,
"points": 1280,
"games": { "egg": 6, "jump": 4 }, // best level
"where": { "world": "sea", "screen": "reef" },
"ev": [ { "t": "try", "g": "egg", "l": 6, "win": true } ]
}
The rule every backend follows: never trust the client. Anyone can send anything to a public endpoint, so the game Worker re-checks every field. An ID that isn't 16 to 40 letters and numbers is turned away. A device that isn't one of the three allowed words is dropped. Duck counts are capped at 500 and levels at 10, and long lists are cut short. Bad data never reaches the database.
The Workers: three programs, one job each
The backend used to be one program that did everything. Now it's split into three, so each piece only has the power it needs.
quackers-api, the game's door
The only Worker the game talks to. It takes pings, runs Top Ducks, the Idea Box and friend links, handles the forget button, sorts out bots, answers the health check and runs the daily cleanup.
quackers-words, the word checker
Holds the list of words that aren't allowed and answers one question: is this text OK? It has no web address, so nobody on the internet can reach it. Only the game Worker can, through a service binding, a private connection inside Cloudflare.
quackers-stats, the control room
Serves the stats page, where a grown-up reviews ideas and can hide a leaderboard name. It needs a grown-up's sign-in, and the game never talks to it.
This idea has a name: least privilege. Each part gets only what its job needs. The game's public door has no grown-up tools in it, so a mistake there can't reach them. And each Worker can be updated on its own without touching the others.
A Worker looks at which endpoint a request came to and runs the matching function. These are the doors the game uses, all on quackers-api.
| Endpoint | What it does |
|---|---|
| POST /v1/ping | Takes the game's progress summary and events. Updates the player's row, the players-per-day list and the shared totals. |
| GET /v1/board | Returns the Top Ducks leaderboard: the top 25 by ducks found, then worlds finished, then who joined the board first. Also your own rank if you're further down. |
| POST /v1/board | Sets your leaderboard nickname, once it passes the name check and nobody else has it. |
| GET /v1/ideas | This month's approved ideas with their hearts, your own ideas and their status, and last month's winner. |
| POST /v1/ideas | Suggests a new duck or world. It goes into a waiting line, not onto the board. |
| POST /v1/ideas/vote | Adds or removes your one heart on an idea. |
| /v1/friend/… | Makes your friend-link code, counts friends who joined, and credits the link when a new player finds their first duck. |
| POST /v1/forget | Deletes everything stored for your device. |
Names checked twice
The game checks a name as you type, for instant feedback. The real gate is quackers-words: the game Worker asks it about every nickname and idea. It blocks rude words (including tricks like swapping letters for numbers), websites, usernames, schools, grades and too many digits. If the checker can't answer, the name waits instead of slipping through.
A grown-up reads every idea
Each player can suggest 3 ideas a month. A filter catches personal details first, then a grown-up approves or declines each one before anyone else can see it. Approved ideas collect hearts, one per player, and the idea with the most hearts wins the month.
Hard to cheat
A friend link carries a random 8-character code that leaves out look-alikes like l, 1, o and 0. It only counts if the new device really is new (it first played after the link was made, in the last two days) and has found a duck. Each sharer can earn at most 3 credits a day.
Players, idle visits and bots
Not every visit is a kid playing. Search engines and other programs load the game too. The game Worker sorts each device into player, idle or bot, using clues like whether it played at all or came from a data center, so the numbers count real players.
The database: what's kept and why
A database is a set of tables, like spreadsheets with strict columns. Quackers has 16 of them, and the most important design choice is which side of the wall each one sits on.
Per device
Needed so the leaderboard, Idea Box and friend links work for you. All of it is deleted by the forget button.
Not linked to anyone
Just counters. No device ID is stored with them, so they can't be traced back to a player.
For the system
Tables the Workers use to protect themselves.
The Workers talk to D1 in SQL, the language almost every database speaks. Values are never pasted into the SQL text. They're passed separately as "bound parameters", which is the standard defence against a classic attack called SQL injection.
A ping turns into several writes at once, sent as a single batch. Either they all happen or none do, so the tables never disagree with each other.
INSERT INTO duck_finds (duck, n)
VALUES (?1, 1)
ON CONFLICT (duck)
DO UPDATE SET n = n + 1;
-- ?1 is filled in safely by the database,
-- never glued into the text.
Privacy and safety by design
Players are kids, so the rule is simple: data privacy comes first, always. These safeguards are built into the code, not just written in a policy.
No accounts, no names
A random device ID stands in for the player. No sign-up, no email, no real name. The only typed text is an optional nickname and Idea Box ideas, and both are filtered.
No IP addresses, no logs
The Workers don't save IP addresses or write request logs. Cloudflare works out a rough country, state and city from the connection. The city is only ever added to a daily count, never stored with a player.
Off switch and Do Not Track
Turning off "Share game stats" in Settings stops all sending. If the browser has Do Not Track on, the game sends nothing at all.
Humans in the loop
No idea is visible to other players until a grown-up approves it, and declined ideas have their text erased right away. Any leaderboard name can be hidden.
A real forget button
One tap sends /v1/forget. The game Worker deletes the device's rows from every per-device table in one batch, takes its hearts back off ideas, and the game starts fresh with a new ID.
Totals stay totals
Anything that doesn't need to be tied to a device isn't. Session lengths even use a separate throwaway ID so they can't be joined back to a player.
Open source, no secrets in the design. Nothing on this page is a secret, and the game's code is public. What stays private is data: player records and the keys a grown-up uses to run things. Those live in the Workers' settings and the database, never in the game's code. Good security doesn't depend on hiding how a system works.
Rate limits and staying on the free plan
The whole backend runs on Cloudflare's free plan. That only works because both sides are careful about how often they talk.
A rate limit caps how many times something can happen in a window of time. The game Worker keeps a tiny counter per device and action in the limits table. Each counter expires on its own, and the Worker says no once it's full.
| Action | Limit per device |
|---|---|
| Game pings | 30 a minute. Extras are told to slow down, and nothing is lost. |
| Nickname changes | 5 an hour |
| Idea suggestions | 10 tries an hour, 3 ideas a month |
| Hearts | 60 an hour |
| Friend-link claims | 10 an hour, and 3 credits a day per sharer |
| Forget requests | 5 an hour |
The game is polite too. It bundles changes, skips a ping when nothing changed, and sends in the background every 5 minutes at most. If a request fails, it backs off: wait 1 minute, then 2, then 4, doubling up to an hour, so a struggling server isn't hammered. If the server says the daily allowance is used up, the game waits until it resets at midnight UTC.
The Workers also count their own work. Every request to the game Worker or the stats Worker adds to one shared daily tally of requests, rows read and rows written, saved in the usage table and compared with the free plan's daily allowance.
Most of the care above exists to keep these numbers small: batching, skipping pings that carry nothing new, and reading only the rows a request needs.
| Free plan | Allowance |
|---|---|
| Worker requests | 100,000 a day |
| Database rows read | 5,000,000 a day |
| Database rows written | 100,000 a day |
| Database storage | 500 MB |
Cleanup: data has an expiry date
The safest data is data you no longer have. Once a day, the game Worker runs a cleanup that deletes anything past its time.
- Right away
A declined idea has its text erased.
- End of each month
Hearts on last month's ideas are removed, and ideas lose their link to the device that sent them. Only the idea and its final count remain.
- After 60 days
Ideas nobody reviewed are deleted.
- After 90 days
Old entries in the players-per-day list and the daily usage counts are deleted.
- After 1 year
A device that hasn't played for a year is deleted entirely, everywhere. Year-old session and city counts go too.
- Every run
Expired rate-limit counters are swept away.
Cleanup rides along with normal traffic. The first game ping of the day starts it, and a once-a-day rate limit on the cleanup itself stops busy days from running it over and over.
It reuses the same delete steps as the forget button, just pointed at every device last seen more than a year ago. One piece of code doing two jobs means the two can't drift apart.
Health monitoring
Software breaks quietly. A health check is how you find out before players do.
The game Worker has a health check that answers three questions: is it up, can it reach the database, and how close is today's usage to each free-plan limit, as a percentage. If the database can't be reached, it answers with error code 503 ("service unavailable") so anything watching knows right away.
A watcher calls the health check three times a day. If it fails, or any limit passes 70%, a grown-up gets an alert. Warning at 70% leaves time to react before anything actually stops.
And if the backend does go down, the design already covers it: the game keeps playing, stats wait in the queue, and the back-off keeps retries gentle until it's back.