Skip to content
Go back

The web app: preparing a set on a phone

Updated:

Preparing a set on a phone means picking songs, submitting a render, and getting a video ready for a larger screen. The editor needs to respond quickly. Encoding a whole service can take minutes.

That gave me a useful division: the web app accepts and tracks the work, while a separate worker produces the files. They share a database and object storage, with a queue between submission and rendering.

This is part of Stream of Worship, a series. Previous: The songset constructor. Next: Offline worship playback.

One backend, several clients

The Next.js app serves browser sessions and JSON APIs. Android uses those APIs too. A Cast receiver is different: it needs a playable media URL without having to sign in to the app.

The auth proxy redirects unauthenticated page requests to login, but returns JSON with status 401 for protected API requests. API handlers still check authorization and ownership. Public share and projection routes have their own access paths.

This distinction is small but necessary. A native client expecting JSON can’t do anything useful with an HTML login page, and a successful redirect isn’t a successful API response. The proxy tests make that difference explicit.

Catalog metadata, recordings, songsets, and render jobs live in Postgres. Text search uses titles, pinyin, and credits. Similar-song discovery uses stored embeddings. I wouldn’t describe those as one general hybrid search system: the retrieval routes serve different requests.

Submit a job, then read it again

The render endpoint validates the request, checks access and limits, inserts a job, and dispatches it. If dispatch fails, it marks the job failed. An active-job guard prevents another render from stacking up for the same set, and stale jobs can be reconciled rather than blocking it indefinitely.

The dispatcher supports SQS and a REST mode. SQS is the default. It sends job, songset, and user identifiers rather than a serialized song list.

The worker pipeline reads the database, fetches source assets, mixes audio, renders video, uploads the artifacts, and updates the job. Reading the plan at execution time avoids a second serialized copy in the message, but it also means the message isn’t an immutable snapshot of the set at submission.

Polling is enough for this screen

The submitted screen polls every ten seconds. A transient fetch error leaves the job alone and allows another tick. A 401 or 403 stops polling and asks the user to sign in; it doesn’t mean the render failed. A 404 or 410 ends the screen’s attempt to track that job.

The README still lists an SSE events endpoint, but that route isn’t present in this revision. The client implementation and its tests are the useful references here. I would remove the stale documentation rather than make readers work out which transport exists.

Give the TV a file it can fetch

The logged-in controller mints a presigned storage URL and passes it to the Cast receiver. Lyrics are baked into the MP4, so that receiver doesn’t need the catalog or the user’s cookie. The controller requests a four-hour URL for Cast playback to allow setup and a service.

Chapters arrive as a JSON sidecar through an app proxy. That keeps the browser from depending on a cross-origin storage fetch for chapter data. Codec support and network access still matter; the code can’t establish that every TV or venue network will work.

For a prepared service, the next step is offline playback. A URL that lasts four hours is helpful while online. A downloaded copy needs a different boot and delivery path.


Share this post on:

Previous Post
The songset constructor: searching within a worship arc
Next Post
Offline worship playback: downloading the player as well as the video