Edvard Kristiansen
← Back to vibes
Live

The Hat Knows

Draw names. Keep the secret.

  • TypeScript
  • Hono
  • Cloudflare Workers
  • D1
  • Cloudflare Email
Launch app
The Hat Knows screenshot

The draw

Drawing names sounds trivial until you add rules: couples who shouldn’t draw each other, and nobody getting the same person as in past years. The draw handles both.

  • Graduated repeat guard. It tries to avoid every remembered year’s matches, then backs off one year at a time only when the group is too small to satisfy them all.
  • No deducible matches. A guard is only accepted while every giver still has at least two possible recipients, so nobody can work out their match by elimination.
  • Provably feasible. Bipartite matching checks a valid draw exists before searching, then a cryptographically secure shuffle picks one uniformly. Tests compare against a brute-force oracle and check the distribution is uniform.

Sealed by design

Reveal and organiser links are 256-bit tokens stored only as hashes, and no API returns the pairings to anyone. There are no accounts or passwords — sign-in is by emailed link.

Built in five days.