Step 1
Curated public-domain sources
Behind the scenes the source list is curated, not scraped. Each page entry in bluebolt-sources.json is hand-picked by the operator and carries its provenance mirror (Digital Comic Museum, Comic Book Plus) plus notes describing the page. Replacing an entry is a one-line JSON edit — the rest of the pipeline reads it verbatim at boot.
Step 2
Rights assertion, stamped inline
Blue Bolt #1 (1940) sits in the U.S. public domain because its copyright was not renewed. The orchestrator reads the rights_assertions block from bluebolt-sources.json (status public-domain, country US, year_published 1940) and surfaces it both on the hero badge and on the source list, so the public-domain claim is auditable from the UI rather than buried in a comment.
Step 3
Panel detection (LlamaGen, with GPT-4o fallback)
For every page, detectPanelsOnPage runs against the image. The orchestrator prefers LlamaGen panel+vision when useLlamaGen is set and LLAMAGEN_API_KEY + LLAMAGEN_BASE_URL env vars are present; the orchestrator also routes to the GPT-4o path when LlamaGen returns an empty panel list. The GPT-4o fallback is required for the POC to make progress while the operator confirms the vendor contract — it is not a degraded secondary path, it is the baseline.
Step 4
Speech-bubble extraction and re-paste
When the detector reports bubble boxes (page-relative bbox in image space), buildBubblePatches(pageImageUrl, bubbles) crops each bubble as a small RGBA PNG and uploadBubblePatches(episodeId, index, patches) registers the contact sheet for that panel. The bubble overlay is only built for panels that actually have detected bubble boxes — panels without bubbles skip the seam cleanly. Coordinates are page-relative, not panel-crop-relative, so bubbles stay anchored to "where they were in the comic" no matter how the camera moves.
Step 5
Per-panel render through the animation pipeline
Each surviving panel becomes an EpisodePanel row. The renderer cycles effects in the order slow-zoom, pan, shake — pickEffect(index) wraps around — and calls runAnimationPipeline(panel, opts) per panel with the bubble overlay plumbed through when one exists. Duration is computed from speechBubbles count and the actionLines flag via computePanelDuration, then clamped between 3 and 10 seconds. The result is a panel MP4 written back to R2 with an outputUrl.
Step 6
ffmpeg concat stitch into the master MP4
stitchCompletedPanels walks the list of outputUrls, downloads each MP4 into a temp directory, and writes a list.txt that the ffmpeg concat demuxer consumes with -f concat -safe 0 and -c copy so the streams are re-muxed without a re-encode. The resulting out.mp4 is uploaded to R2 as bluebolt-<episodeId>.mp4 via polsia.com/api/proxy/r2/upload, and the Episode.outputUrl is updated to the master in one final transaction.
Step 7
Optional 9:16 social highlight (Pika, with ffmpeg fallback)
When the operator requests a panel-range clip, the route handler submits a Pika synthesis job through pika-clip.ts — submitPikaClip drives the call, and only runs when PIKA_API_KEY and PIKA_BASE_URL are set. If Pika is unconfigured or any stage rejects, the clip path falls back to ffmpeg concat over the rendered panel MP4s, so the highlight step never blocks the POC. The orchestrator only creates Episode and EpisodePanel — there is no separate per-page row, the index in the rendered output is the panel orderIndex.