Building a three-question quiz that finds your breakup song
Most songs are about falling into love or out of it. I was explaining that to my kid, and I added that when it happens to you, you should find the song that speaks to you.
The conversation stayed with me, because it sounded like a fun project to help people find that song. So, I took the idea and built it the way I would lead any project. The result is Find Your Breakup Song (mozum.com), a quiz that takes three taps on a phone.
How it works
In three questions, the quiz seeks to learn who ended it, how you feel, and which world you live in.
The logic that chooses the song is tied to your answers, and the questions and answers can change every time, for a slightly different result. You get a lead single and three B-sides from a catalog of 3,281, with links to six music services. It is written for adults, so explicit songs are in.
How it is built
It is a React 19 app built with Vite, styled with Tailwind CSS and daisyUI, with no router and no state library.
The matching engine is plain JavaScript with no React, so the same code runs in the page, in the unit tests, and in a simulator that plays 200,000 visits.
The song data starts as pipe-separated values (PSV). Each song is one line of 15 fields with a pipe character between them, so a title with a comma in it needs no quoting. There are 238 of these files, and scripts check and merge them into one catalog. The source files are for writing and checking the data, and none of them reach the browser as they are.
At build time the questions and answers become a JSON array with no field names. The songs become binary columns, one typed array per field, with titles and artists in a shared string table. Everything is compressed with deflate, scrambled with a key that is new on every build, and written into the page as one base64 string. The browser unpacks it with its built-in DecompressionStream.
The output is a single HTML file of about 400 kilobytes, which can be served from anywhere that serves HTML. There is no server code, no AI at runtime, and all logic is in the app.
The catalog
The list of songs matters more than the code in an app like this. The catalog was drafted in batches by genre and decade. A list that long written from memory will contain wrong years, wrong artists, and the occasional song that does not exist. So a script checked every row against MusicBrainz, a public database, and nothing unconfirmed ships.
I aimed for 5,000 songs and stopped at 3,281, because a made-up or misfiled song costs more trust than a missing one.
Leading the build
Claude applied the app design and looked for songs, and I made the decisions. Each one is written down in a design document, now on its eighth draft.
The quiz is live at mozum.com. It is optimized for mobile. Try it out, hopefully you don't have a need.
Photo source: https://photos.robertstowe.com/texas
Comments
No comments yet. Start the discussion.