A Spotify-Wrapped-style story engine for two people and two time zones — tap-through cards, a dot-rendered Earth, music underneath, and a share card at the end.
It plays end to end with nothing configured: npm install && npm run dev runs the whole show on a
fictional demo couple — no account, no OAuth, nothing to supply.
![]() |
![]() |
![]() |
| Real geography, real arc. | A stat card mid-hold. | The card it ends on. |
Live demo: https://demo.longdistancewrapped.com
Two years of a relationship happened over a phone; the record was a Signal export. The bar was that it feel indistinguishable from a commercial year-in-review, on her phone, opened once. There is no second first impression, so every card ships polished or not at all: 60fps on a mid-range phone, no flash of unstyled anything, no card less finished than the one before it.
- Eighteen cards between a tap-to-open gate and the finale, in four chapters that are times of day — night, deep night, golden hour, dawn. A chapter change is a sky change and a bed change: four tracks, dipped to silence between them, never crossfaded.
- A dot-rendered Earth from a packed 2.5° land grid: the true great-circle arc between the cities, a day/night terminator shading every dot, and a camera each card hands to the next, so globes travel rather than cut.
- Figures that reconcile across cards, under test — the share card's two columns rebuild the
corpus the library card counts out loud (38,214 + 29,655 = 67,869 messages), asserted in
whoWeAre.test.tsandshareSummary.test.ts. - Pacing measured off a 41.28-second screen capture, one frame a second: ~8 seconds a card, two events. A headline holds alone for 3400ms before the wink — an early draft guessed 600–900ms and was five times too fast.
- A quiz that replaces the tease beat of the reveal after it, distractors taken from the real ranking. It never traps you: no timer until answered, a forward tap advances anyway.
- A 1080×1920 share card rendered client-side with
html-to-image— and a fictional couple in it: every figure, date and quoted message is invented, and listed indocs/demo-show.md.
The engine (src/engine/) is the stories player: one requestAnimationFrame clock, tap zones,
progress bar, pause, auto-advance, audio, preloading, chapter palettes.
The cards (src/cards/) are one folder each, recomposed from the motion vocabulary in
src/cards/primitives/. A card fulfils CardProps — isActive, isPaused, an api — and reads
colour only through the CSS variables the engine writes on the stage.
The data (src/data/) is the run sheet and the figures: deck.ts, chapters.ts, tracks.ts,
geo.ts, visits.ts, one typed module per card in stats/.
The rule between them is stated as absences: the engine never imports a card, a card never imports
engine internals, deck.ts holds no logic and no literal duration — every durationMs comes from
the card that computed it. Adding a card is a folder plus one entry:
export const deck: CardDefinition[] = [
// The gate. Manual, always — the press unlocks audio.
{ id: "gate", component: TapToOpen, advance: "manual", chapterId: NIGHT.id, trackId: "opening" },
// C05 · A Library of Us — the reference card.
{
id: "c05-library-of-us",
component: LibraryOfUs,
advance: "auto",
durationMs: LIBRARY_OF_US_DURATION_MS,
chapterId: NIGHT.id,
},
// C28 · Quiz — no timer until answered; a tap still advances.
{
id: "c28-three-am-quiz",
component: ThreeAmQuiz,
advance: "interactive",
chapterId: DEEP_NIGHT.id,
trackId: "crossing",
},
// Last in the deck, which makes Replay `api.next()`.
{
id: "finale",
component: makeFinaleCard({ summary: shareSummary, copy: finaleCopy }),
advance: "manual",
chapterId: DAWN.id,
preload: sharePreload,
},
];docs/architecture.md is the codemap: every file, the frozen contract, the
cross-cutting rules.
Nothing touches the network. flatten.py turns a Signal backup's JSONL into one DuckDB file,
stamping every message with both wall clocks; ask.py hands a local model the schema, not the
corpus, and has it write SQL, so every number is exact and printed before it runs. Message bodies
never reach the model's caller — q.py refuses to print rows containing them.
Signal backup → JSONL → DuckDB (flatten.py) → a local LLM writes SQL (ask.py, LM Studio,
localhost only) → the author reviews → typed src/data/stats/*.ts → tests reconcile them
Setup and the traps in the views: tools/analysis/README.md. What to
do with the numbers: docs/writing-a-show.md.
Prerequisites: Node 22; ffmpeg to cut a music bed; LM Studio if you run the analysis.
git clone <your fork> long-distance-wrapped && cd long-distance-wrapped
npm install && npm run devThat plays the demo. Then, in order:
-
src/data/geo.ts— your two cities.export const MY_CITY: City = { id: "yvr", name: "VANCOUVER", timeLabel: "10:12 PM", latitude: 49.2827, longitude: -123.1207, vector: toVector(49.2827, -123.1207), tone: "cool", }; export const YOUR_CITY: City = { /* same shape, tone: "warm" */ }; export const DISTANCE_KM = 8159; export const ARC_MIDPOINT = { latitude: 58.5, longitude: 174.0 } as const;
geo.test.tsre-derivesDISTANCE_KMfrom the coordinates and fails until it matches;node docs/mockup/landmask.mjsprintsARC_MIDPOINTfor your pair. CheckSUN_DIRECTIONtoo — the test asserts one city lit, one dark. -
src/data/visits.ts— your trips, as windows plus the days actually in the same room. Four cards check against this rather than the messages, because a visit is the absence of a signal. -
src/data/stats/*.ts— one typed module per card. Write the fact sheet first:docs/demo-show.mdis the one the shipped modules came from. -
src/data/tracks.tsandpublic/audio/— four beds, 118 seconds each; theffmpegline is intracks.ts. -
src/assets/photos/— webp, ≤1600px, ≤400KB.tools/placeholders/make-photos.pydraws sky placeholders if you have none. -
The cards. Copy lives in each card component, not the data layer, because it is writing rather than data — rewriting the show means editing
src/cards/<Name>/<Name>.tsx.src/cards/LibraryOfUs/is the reference.
Leave alone: src/engine/ and src/cards/primitives/.
Deploy: npm run build writes a static dist/; the project has no environment variables
anywhere. It was built for Cloudflare Workers static assets
(docs/deploy.md), but any static host serves dist/.
npm run dev · build · typecheck · test · lint · format. One gate:
npm run build && npm run typecheck && npm run test && npm run lint349 tests across 37 files cover what can be wrong silently: the story reducer and clock, deck
validation, the audio and quiz state machines, the geography, and every stats module against its
neighbours. Card visuals are not unit tested — those are checked in a browser at
390×844 under 4× CPU throttle and on a real phone. TypeScript is strict, files are capped at 300
lines soft and 500 hard, and CLAUDE.md is the house rulebook.
The engine landed in a day; the eighteen cards took the two days after it. Both were built by
parallel coding agents working from written specs against a frozen contract: src/engine/types.ts
was declared unchangeable, each chunk owned an exclusive list of files, and nothing merged until it
passed the gate above. deck.ts was the one file no card agent owned — each returned the entry it
would have added. Watching the finished deck on the phone it was built for produced nineteen fixes
across sixteen cards, every one the same fault: a figure on screen with nothing naming its subject.
Hence the rule, every beat names its own subject.
docs/how-it-was-built.md is the protocol;
docs/card-craft.md is the pacing doctrine.
- Signal exports carry no call durations — only when a call started. Count, frequency and who dialled are solid; "hours on the phone" is not derivable.
- Attachments are pointers, not bytes. A card with images needs its own media export.
- iOS Safari saves the share card by long-press — where the browser refuses the download, the finale falls back to the full-size picture.
- The countdown's target is relative in the demo — today + 26 days, computed at module load — so it never goes stale.
- The deck is written from one person to another, with him/her pronouns in the data layer. Changing that is a copy edit, not a code change.
Code is MIT — see LICENSE. Music is by Scott Buckley under
CC BY 4.0; Anton and Fraunces under the SIL Open
Font License; the landmask from world.geo.json, derived from public-domain Natural Earth data.
The credit lines each asks for are in ATTRIBUTION.md.
Photos, music and any personal data you add are not covered by the code licence.
Not affiliated with Spotify. Wrapped's pacing was the reference; none of its assets, palette or shapes are used.
Run the gate before opening anything. One card per pull request; an src/engine/ change starts as
an issue, because that contract is what lets cards be written independently. New dependencies need
a reason.


