A bachelor party app with its own economy
Guests earn the game's currency in tournaments, duels and easter egg hunts, and the three with the most at the end of the weekend win prizes. One person runs the game and can correct almost anything, while everyone else follows on their phones.

Context
Bachelor Companion was made for one bachelor party weekend. Guests collect a currency, named after the groom’s surname, in tournaments, 1v1 duels, a quiz about the groom and side quests, and hunt for easter eggs. Some eggs are hidden in the app, and some are printed as QR codes and placed around the venue. Whoever has the most at the end of the weekend wins. The top three had moonshine waiting, plus a T-shirt for first and a cap for second, both with a picture I made of everyone who took part.
The currency can also be spent in the shop, on buffs for yourself or on troll items against the leader or your next opponent. The economy was set up so that a purchase could pay off, even though whatever is spent no longer counts at the end.
I built it alone in September 2025. The same month, 12 people used it for a weekend. In 2026 I made a public demo with synthetic data, where anyone can sign in as the admin.
Problem and constraints
One of those 12 people ran the game, in the middle of the party. To leave a way out for anything unexpected, almost everything could be changed from the admin panel: the bracket after it was generated, how many wins a match is played to (a final to one instead of three, to save time), shop prices through discounts to get people buying, the list of players in case someone dropped out, and the eggs, which could be reset and claimed again once hidden.
For balances, being able to edit was not enough. Mistakes were easy to make, so every entry had to come undone with the balances back exactly where they were. The prizes went by the currency, so no balance could go wrong or drop below zero.
A tournament bracket had to work for any number of players, not only 8 or 16. Every price in the shop had to be payable in paper notes, and the notes in the game could not make 10 or 30.
Decisions
Decision
Change a balance with one conditional operation in the database, and store the balance after each entry.
Alternatives
- Work the balance out from the sum of all entries each time it is read. Always right, but every ranking and every check adds up the whole history.
- Read the balance, check it and write the new one, at a stricter isolation level that retries on conflict. Correct too, but every caller has to handle the retry.
Why
The database adds the amount only if the result stays at zero or above. If it would not, nothing changes and the app refuses the entry. The check and the write are one operation, so two entries at the same moment cannot overwrite each other. Each entry stores the balance it left, and the history reads like a bank statement.
The price is a balance kept in two places: on the person and in their last entry. Code that changed the balance without an entry would make the two disagree. So every change to a balance goes through one function.
Decision
Undo every kind of payout the same way: net its entries, and refuse if anyone would drop below zero.
Alternatives
- An undo written for each action: matches, duels, quiz answers, the audience bonus, whole tournaments. Each one simpler on its own, and five sets of rules to keep right.
Why
Every payout carries the id of the match, duel or quiz question it belongs to. To undo one, the app adds up those entries per person, checks that nobody would go below zero, and writes the opposite. Undoing a whole tournament is the same operation over more entries. A double-points bonus used up by the payout comes back with the undo.
A single entry can also be undone from the history, once. The reversal points at the entry it cancels, so undoing the whole match later does not take the money back twice.
A payout without an id cannot be undone, so every new kind of payout has to carry one. The rule is written down in the repository.
Decision
One shared admin password and a signed session, no user accounts.
Alternatives
- Accounts for everyone through an auth library. Guests would sign in, and the app would know who did what.
Why
Guests only look at the app and claim the eggs they find, and neither needs an account. One person enters everything else. The password gets them a session token signed with HMAC-SHA256, with its expiry inside. The token is checked with Web Crypto, so the same code runs in Next.js middleware and in the route handlers. The middleware lets a change to data through only from a short public list, and each admin route also checks the session itself.
The app does not record which admin changed what. With one admin, there was no need.
Evidence
The screenshots show the demo’s made-up data, not the real weekend.




Outcome
The easter eggs went down well, both the ones in the app and the printed ones. So did the side quests: plenty of people wanted the reward for catching a fish. There were also a lot of 1v1 duels in all sorts of games, from coin tosses for points to billiards and badminton.
Nobody bought double points or a troll item in the shop. We finished one tournament, coin tossing, losers bracket included, because every match there went quickly. A billiards tournament got halfway. The weekend turned out a bit too short to try everything.
I collected the printed eggs once they were found and hid them again. Anyone who had scanned one had its address in their browser history and could claim it a second time. Only a gentleman’s agreement stood in the way.
A year after the weekend I went back to the code, no longer for the game but for myself: I wanted to be happier with it. The API got input validation with Zod, and tests now cover the bracket, the prices, the sessions and the ledger.
What I would not repeat
Going to production for the first time the day before the trip. The build on Netlify kept failing on errors the development server had never shown, and the afternoon went on retyping every API route for Next.js 15.
At the venue, generating a bracket timed out. On the slow server it ran longer than Prisma lets a transaction run by default. I had no laptop, so I pushed the fix, a 60-second limit for that one transaction, from my phone through GitHub’s editor. On Vercel the same bracket takes about 2 seconds, so it was probably the server rather than the code. A week in production before the trip would have brought both problems out earlier.
Reading a balance and writing it in a separate step. Two entries at the same moment could overwrite each other. Luckily that never happened, and I only found and fixed the bug in December 2026, while getting the app ready for this case study.
Adding features up to the last minute. The more I built, the more ideas I had, and I barely finished in time. For the last four days I slept about four hours a night, and I was worn out on the day we left.
Next time I would make more eggs, in the app and on paper, so the same ones would not need hiding again. The eggs were what everyone liked most: months after the weekend, the guests still talk about how much fun they had hunting for them, above all the printed ones hidden around the venue.