GAME ROOM ← Quackers
The Engine Room

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
01

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.

System map. The code repository publishes to GitHub Pages, which sends the game to the browser. The browser sends requests to the game Worker, quackers-api. That Worker asks the private quackers-words Worker to check names and ideas. A separate quackers-stats Worker serves the grown-ups' stats page. Both quackers-api and quackers-stats read and write the D1 database. DELIVERY Code repository src/ + build script open source on GitHub GitHub Pages serves the built game at quackersgame.com files, once ON YOUR DEVICE Browser: the game worlds, ducks, mini games, shop saves your progress in local storage keeps a small queue of stats to send HTTPS + JSON request, then reply CLOUDFLARE Worker: quackers-api the game's front door checks every request quackers-words checks names, ideas no public address quackers-stats grown-ups only SQL, in batches D1 database: quackers reachable only by the Workers
Solid arrows are requests, dashed ones are replies. The word checker has no address on the internet at all.
02

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.

Build step. Many source files go into build.py, which outputs a single index.html. src/ yard.js sea.js space.js mini.js social.js name-check.js *.css + more worlds, art, shell build.py stitches index .html ~350 KB
Change a small file, run the build, push. GitHub Pages publishes the new version within a minute or two.
03

A request's trip

Here's what happens, step by step, after you find a duck.

Sequence of one ping. The game saves locally, waits twenty seconds to bundle changes, and posts a ping to the game Worker, quackers-api. It checks the data and the rate limit, writes a batch to D1, and replies ok. Game quackers-api D1 You find a duck. Saved on device. Wait 20 s, so finds close together go as one ping. POST /v1/ping JSON, 6 s timeout Check the data: ID format, allowed words, numbers in safe ranges. Rate limit: under 30 pings a minute? one batch of SQL writes players, daily, totals done { "ok": true } Clear sent stats from the queue. On failure, keep them for later.
The whole round trip usually takes well under a second.

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.

request body (example values)POST /v1/ping
{
  "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.

04

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.

Public

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.

Private

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.

Grown-ups

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.

EndpointWhat it does
POST /v1/pingTakes the game's progress summary and events. Updates the player's row, the players-per-day list and the shared totals.
GET /v1/boardReturns 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/boardSets your leaderboard nickname, once it passes the name check and nobody else has it.
GET /v1/ideasThis month's approved ideas with their hearts, your own ideas and their status, and last month's winner.
POST /v1/ideasSuggests a new duck or world. It goes into a waiting line, not onto the board.
POST /v1/ideas/voteAdds 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/forgetDeletes everything stored for your device.
Leaderboard

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.

Idea Box

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.

Friend link

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.

Bots

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.

05

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.

Linked to a random device ID

Per device

Needed so the leaderboard, Idea Box and friend links work for you. All of it is deleted by the forget button.

playersDucks found, worlds, Pond Points, best levels, last world and screen, device type, country and state, first and last day played, player or bot, and the kind of place it came from, like a search engine or a friend link.
dailyWhich days a device played. Kept 90 days for a players-per-day chart.
boardLeaderboard nickname, and whether it's hidden.
ideas · idea_votesIdeas and hearts. The link to the device is removed when the month ends.
friends · referralsYour share code and how many joined. For a new player, only that they were counted, not who invited them.
Totals only

Not linked to anyone

Just counters. No device ID is stored with them, so they can't be traced back to a player.

duck_findsHow many times each duck has been found.
levelsTries and wins per mini game level, to tune difficulty.
shop · earnWhat gets bought, and where Pond Points come from.
sessionsHow long a play session lasts, under its own throwaway ID.
visits · citiesVisits per city per day, as a count only, with bots counted apart from players.
Housekeeping

For the system

Tables the Workers use to protect themselves.

limitsShort-lived counters for rate limits.
usageDaily request and row counts, to stay inside the free plan.

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.

how a duck find is counted (simplified)SQL
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.
06

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.

Identity

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.

Network

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.

Choice

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.

Review

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.

Deletion

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.

Separation

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.

07

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.

ActionLimit per device
Game pings30 a minute. Extras are told to slow down, and nothing is lost.
Nickname changes5 an hour
Idea suggestions10 tries an hour, 3 ideas a month
Hearts60 an hour
Friend-link claims10 an hour, and 3 credits a day per sharer
Forget requests5 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.

Exponential back-off. After failures one to seven, the game waits 1, 2, 4, 8, 16, 32 and then 60 minutes before trying again. WAIT AFTER EACH FAILURE (MINUTES) 0 60 1 2 4 8 16 32 60 1st2nd3rd 4th5th6th7th+ FAILURES IN A ROW
Exponential back-off: each wait doubles, up to a cap. One success resets it.

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 planAllowance
Worker requests100,000 a day
Database rows read5,000,000 a day
Database rows written100,000 a day
Database storage500 MB
08

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.

09

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.

Health monitoring. A watcher runs three times a day and calls the health check, which checks the Worker, the database and usage. The result is ok, near limit at 70 percent or more, or down. Near limit or down sends an alert. Watcher runs 3 times a day Health check Worker up? Database up? Usage as a % of each daily limit oknothing to do near limitany use ≥ 70% downerror 503 alert a grown-up
Monitoring only reads totals. It never looks at a player's data.