Back to my projects

Puzzle Generation Engine

Puzzle Generation Engine

Built first for personal reasons. In 2026, it became a way to test whether I could ship production-ready software by directing AI agents.

Where it started

In 2022 I left Malaysia and came home to India to be closer to my family.

My father was showing early signs of Alzheimer's. His doctor suggested puzzles to keep his mind engaged. I knew I could design and build the right ones for him. I built the content with ChatGPT, created the puzzles with a third-party tool and designed the books with Midjourney, Ideogram, Adobe Illustrator and Vectorizer. Much of that work happened through long days and nights at the hospital.

Generating the content for each book took me more than two weeks.

If a third-party tool could generate these puzzles, I could build my own workflow and cut the time spent generating the content.

From two weeks to two minutes

In 2025 I did exactly that. I replaced the third-party tool with my own pipeline, built in n8n with AI. Generating the content for a book went from more than two weeks to 1 minute 58 seconds. That was content generation only. I still laid out and prepared the book in Illustrator.

It worked well, but I didn't believe it would scale for public use.

Version 1 showed me where the gaps were

Next, I moved the work out of n8n and into code. I designed a puzzle generation engine in Python as separate services, with an orchestrator that could send work back when a step fell short. The design was written down in full. What the agents built was different: one long chain of steps in a single file, running in one direction with no way back.

Testing exposed a problem with cleaning: it removed unsuitable words without asking for replacements. The only defence was to ask the AI for more words than needed and hope enough survived. When too few did, the engine threw the whole list away and started again, paying for every word a second time.

I had assumed written requirements would be enough. They weren’t. Nothing checked whether the implementation followed the design. The next version needed checks against that design and a way to recover when a step failed, or close the request cleanly when it could not be completed.

Version 2 let the code decide

A few months later I rebuilt the engine from the ground up. No code from version 1 was carried over unchanged. This time, each requirement came with a check against the implementation. Three decisions shaped it.

Separate services, with checked boundaries. Each step became its own service with one job: read the request, generate the words, clean them, build the puzzle, validate it, store it. An orchestrator calls them in turn, and the services never call each other. Automated tests flag any change that would wire them back together. This is what version 1 lacked: the orchestrator can send work back to an earlier step.

Code checks what the AI generates. The AI proposes words and clues. Deterministic code builds each puzzle under the rules for its type and difficulty. A puzzle that fails those checks is not released. For a crossword, that includes proving no other arrangement of its candidate answers fits the grid. An AI pass then audits the words and clues against the theme.

Repair instead of discard. Discarding a nearly complete puzzle means paying to generate its content again. When cleaning removes words, the engine asks for exactly the number missing. When a crossword cannot be built from the words it has, it asks for more words rather than starting over. The cost of every AI call is set aside before it is made, each request has a hard spending limit, and the real cost is settled afterwards. Interrupted requests are designed to resume from saved checkpoints without duplicate processing. A request that cannot be completed is closed cleanly.

What it does today

You describe a theme in plain words, something like "rock bands from the 80s". You choose a crossword, word search, word scramble or missing-vowels puzzle and one of three difficulty levels. The engine returns a puzzle that has been built, checked and stored. A web platform with passwordless sign-in sits on top, where puzzles can be played in the browser, saved and picked up again later.

Underneath, it runs as Python services on Modal, with Supabase for data and sign-in, a Next.js front end on Vercel, Upstash Redis for rate limiting and AI models reached through OpenRouter.

How I built it

I built it as a product manager directing AI agents. Claude Code and Codex worked in fixed roles, coordinated through Herdr. A coordinator agent runs the loop. One plans. One builds. A different one verifies the work at every gate: each database change, deployment and paid AI run. Nobody checks their own work. I set the goal, the limits and what counts as done. Every release was independently verified before it went out.

It was not a straight line. Early on I wrapped every task in process: specs, plans, reviews of reviews. The paperwork grew faster than the product. Learning when a check earns its place, and when to step back, became part of the project. I wrote about that in I Stopped Coordinating Every Agent by Hand.

Where it stands

The engine is built and in private use. The web platform is in private testing. Payments, admin tools and support come next, when customers get paid access.

Where it goes from here is still being decided. The direction I keep coming back to is puzzle packs for older adults, made to be printed and worked through on paper. The way my father's were.