Sign in Sign up
1 branch
README.md

Mamma's Advent Calendar

#

An audio advent calendar for a serialized story. One chapter per day through December: narration, the actual text, and an illustration. See SPEC.md for the design and the reasoning behind it.

Stack: SvelteKit (adapter-node) on Bun · SQLite · system ffmpeg · Docker. No runtime dependencies — build/ is the whole application.

Getting started

#
bun install
cp .env.example .env      # then fill in the passwords
bun run dev

With no .env the dev defaults are site password kerst, admin password admin. These exist only in dev: in production the app refuses to serve a single request unless SITE_PASSWORD, ADMIN_PASSWORD and a 32+ character SESSION_SECRET are all set — it starts, listens, and answers everything with a 500 naming what is missing. Nothing is baked in.

Most visitors never see a password — see Sharing below.

ffmpeg and ffprobe must be on PATH. The app warns at boot if they are not.

bun run build     # production build
bun run check     # typecheck

A demo calendar

#
bun run demo

Fills the instance with a twelve-part story to look at: illustrations in every gallery layout, a recording per chapter, and dates set so that most doors are already open and the last few are not — which is the state the calendar is in for most of December, and the only state worth judging.

It goes in through the same admin forms mom uses, rather than being written into SQLite behind the app's back, so it exercises uploading, the two-pass loudnorm transcode, date gating, share links and the podcast feed for real. Afterwards it checks the result from a visitor's point of view and prints the share link, the feed address and the admin page.

The pictures are drawn and the audio synthesised on the spot — no binary assets in the repository, and no ffmpeg filters standing in for content. Each chapter is deliberately recorded at a different level, from −3 to −24 dB, so the normalisation has something to do. It starts a dev server if none is running, writes about 70 MB into data/, and replaces its own calendar when re-run, leaving every other calendar alone.

What exists (phase 1)

#
  • As many calendars as she wants, created from the admin page and each with its own dates, doors, share link, podcast feed and cover. / forwards to whichever is running today
  • Configurable date range with presets (advent, through Christmas Day, twelve days, custom). Door 1 opens on the start date, one per day after, at 00:00 Europe/Amsterdam, staying open afterwards. Shrinking the range is refused if it would discard a chapter with content.
  • Doors that behave like doors: a coloured paper flap per day that peeks open on hover and stays folded back once you have read that chapter, so the grid shows at a glance what is left. Deterministic colours, staggered entrance, today's door badged
  • A locked door wobbles and tells you how long until it opens, instead of doing nothing
  • Snowfall, off by default under prefers-reduced-motion, with a corner toggle that sticks
  • Chapter pages: real selectable text, audio player with resume position, ±15s, speed control and lock-screen/car controls via the Media Session API
  • Any number of pictures per chapter, arranged as a grid, collage, swipeable row or stacked full width — or left on automatic, which picks from how many there are. Tap to enlarge
  • A private podcast feed: one episode appears by itself each morning, listenable in Apple Podcasts, Overcast or Pocket Casts alongside the web calendar
  • Admin editor: title, teaser, story text, audio and image upload, draft/ready status
  • Upload pipeline: any audio format in, mono 44.1k MP3 at −19 LUFS out, two-pass loudnorm, running in the background with progress shown in the editor
  • Date-gated media serving with HTTP Range support
  • Time travel: admins can set ?as_of=2026-12-07 to rehearse December in November

Listening in a podcast app

#

The admin page carries a feed address. Added in any podcast app under "add by URL", it delivers one episode per morning — same drip as the calendar, same unlock dates, no password.

The feed authenticates with the token in its path, since podcast apps cannot hold cookies, and declares itunes:block so it never appears in a public podcast directory. Give the calendar a cover and a read by name in the admin page: without artwork, podcast apps show a blank tile.

PODCAST_LANGUAGE sets the declared language (default nl).

Not built yet

#

The EPUB/PDF/MP3-zip keepsake export. See SPEC.md.

Sharing

#

Visitors get in by opening a link, not by typing a password. ?key=<token> on any URL admits the visitor, sets a one-year cookie, and redirects to the same page without the token.

  • Copy link on the calendar page gives the link to the whole calendar.
  • Copy link at the bottom of a chapter links straight to that chapter — so "chapter 7 is up" lands people on chapter 7 even if they have never opened the calendar.
  • The shared password still works for anyone whose messaging app mangles the URL.
  • Create a new link in the admin page revokes every link already sent. People who have already opened the calendar stay signed in, so a leaked link can be revoked without evicting the family mid-story.

Chapters still only open on their own date. The link controls who gets in, not what is open.

How mom uses it

#
  1. Go to /admin, log in with the admin password. This lists every calendar and is where new ones are started.
  2. Open a calendar. Under Dates, pick the kind of calendar (or set your own start and end dates). The number of doors follows from the range.
  3. Pick a day. Type the title and paste the story text. Choose an audio file — any format, any size; it is converted automatically.
  4. Leave it on Draft while working. Switch to Ready when the chapter is finished.
  5. A chapter that is Ready opens by itself on its date. Nothing to do on the day.

Everything can be prepared months ahead. Recording 24 chapters is the slow part, not the publishing.

Continuous integration

#

.neosource/workflows/ci.yml typechecks, builds and runs the whole smoke suite on every push. Deployment does not go through it — Dokploy builds the Dockerfile on the VPS itself — so a red run never blocks a release. It exists to say, within a few minutes, that the transcode pipeline or the date gating has broken.

The job declares tools with packages: rather than choosing a container image, which is how neosource CI works: bun, ffmpeg, nodejs_24 and sqlite on top of the baseline. The smoke suite runs twice, once per runtime — under Bun, which is what the container actually runs, and under Node, which is the documented fallback the cross-runtime SQLite layer exists for, and an escape hatch nobody tests is not one. Node has to be 24 (or 22.13+) for node:sqlite to exist unflagged.

Three neosource specifics, each of which has a way of being discovered the hard way:

  • Workflows are registered from the default branch only, and only from the top level of .neosource/workflows/. A workflow living on a feature branch does not exist as far as the server is concerned. .github/workflows/ is parsed and reported, and never run.

  • Parse warnings — an ignored key, a trigger that silently never fires — are not rendered in the web UI for registered workflows. The API is the only place they show up:

    curl -s -H "Authorization: Bearer $TOKEN" \
      https://neosource.dev/api/repos/structwafel/mamma-calendar/workflows \
      | jq '.workflows[] | {path, warnings}'
    
  • neo run --workflow .neosource/workflows/ci.yml runs the job on this machine. Today it fails at actions/checkout, which materialises the triggering commit from https://github.com/<owner>/<repo>.git — not where this repository lives. Running a copy of the file with the checkout step removed executes the rest of the job against the working tree, which is how it was verified before ever being pushed.

Deploying

#

Everything the app needs is inside the image: the adapter-node build, ffmpeg, tzdata, and no runtime dependencies at all. Exactly two things come from outside — the environment variables and a persistent volume — and those are also the only two ways this deployment goes wrong.

On Dokploy

#

Create an Application (not a Compose service; there is one container and Dokploy's own Traefik does the TLS).

  1. Provider — Docker, image neocr.io/structwafel/mamma-calendar:latest. Dokploy does not build anything: CI does (.neosource/workflows/ci.yml), and only after the smoke suite passes on main. Turn Autodeploy on and copy the deploy webhook URL from the Deployments tab.

  2. The webhook, on neosource — repo Settings → Webhooks, payload URL = that Dokploy URL, event Registry packages only. When CI pushes :latest, neosource sends a GitHub-shaped registry_package event and Dokploy redeploys. (Not Pushes: a push event would race the image build, and neosource does not deliver push events yet anyway.) To roll back, point the provider at :<commit sha> — CI pushes that tag too.

  3. Environment — without these the app deliberately serves nothing rather than running an open site on a dev secret. Note the shape of that failure: the container starts and Dokploy shows it healthy, but every request is a 500 and the log says Refusing to start: missing required environment variables: …. Read the logs, not the status dot.

    SITE_PASSWORD=...
    ADMIN_PASSWORD=...
    SESSION_SECRET=...            # 32+ chars: openssl rand -hex 32
    

    DATA_DIR, TIMEZONE, PORT and BODY_SIZE_LIMIT are already baked into the image. CALENDAR_YEAR is optional: it only names the first calendar on an empty database and defaults to the current year. There is no ORIGIN any more — see the next step.

  4. Domains — julekalender.structwafel.dev, container port 3000, HTTPS on, Let's Encrypt. The app works out its own address from each request's Host header and assumes HTTPS, which is exactly what Traefik hands it, so there is nothing to keep in sync. The one way to break it is serving the site over plain http://: pages load fine and every form submission is rejected by SvelteKit's CSRF check — which looks like "the save button does nothing". Keep HTTPS on.

  5. Advanced → Volumes — the setting that actually matters. Add a Volume Mount at mount path /var/lib/mamma-calendar. The SQLite database and every recording and picture she uploads live there. Without an explicit volume, a redeploy hands the new container a fresh anonymous volume and the whole calendar is gone — in November, silently, with no error anywhere. Use a named volume, mamma-calendar-data: it survives redeploys and the backup below can find it by name. (A bind mount to a host folder needs that folder owned by uid 1000, the image's bun user, or every upload fails.)

  6. Volume Backups — schedule mamma-calendar-data to a bucket, daily, with Turn Off Container During Backup on: the database is SQLite in WAL mode, and a copy taken while it is being written can be inconsistent. Her recordings are the irreplaceable part of this project and a copy that only exists on the VPS is not a backup.

Uploads are large by design — a 200 MB WAV master is normal. The site sits behind Cloudflare's proxy, which refuses any single request over 100 MB (413), so the chapter editor sends a recording in 16 MB pieces to /admin/c/<slug>/chapter/<day>/audio and the server joins them back into the original. Traefik does not cap request bodies by default. Pictures still go up with the ordinary form, so picking 100 MB of photos in one save would hit the same limit.

On a plain VPS

#
# on the VPS
echo "SITE_PASSWORD=..."    >> .env
echo "ADMIN_PASSWORD=..."   >> .env
echo "SESSION_SECRET=$(openssl rand -hex 32)" >> .env

docker compose up -d --build

Serve it over HTTPS: the app assumes it, and form submissions over plain http:// are rejected by SvelteKit's CSRF check. Caddy in front (it passes the Host header through):

kalender.example.nl {
	reverse_proxy 127.0.0.1:3000
	request_body {
		max_size 600MB
	}
}

The max_size matters: without it Caddy rejects real recordings before they reach the app.

Backups

#

Everything mutable is under /var/lib/mamma-calendar — calendar.sqlite plus media/. The recordings are the irreplaceable part, so sync them off the VPS:

docker compose exec calendar sh -c 'sqlite3 /var/lib/mamma-calendar/calendar.sqlite ".backup /var/lib/mamma-calendar/backup.sqlite"'
restic -r <repo> backup /var/lib/docker/volumes/mamma-calendar_calendar-data

Runtime note

#

The app runs on Bun, and the Dockerfile pins oven/bun:1.4.4-alpine, the Rust-based 1.4 line. The SvelteKit-breaking bug that kept it on 1.3.14 through the summer is fixed in the 1.4 releases; SPEC.md has the history and the five-second re-test. The SQLite layer selects bun:sqlite or node:sqlite at runtime, so if a future Bun release misbehaves, falling back to Node is a base-image change rather than a rewrite. CI proves both runtimes on every push.