Church member directory on Cloudflare Workers (Astro + Svelte + D1)
  • TypeScript 68.9%
  • Astro 20.5%
  • Svelte 9.1%
  • CSS 1.2%
  • JavaScript 0.2%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-11-23 14:46:06 -05:00
docs Store sibling and grandparent edges when the linking parent is absent 2026-11-23 14:20:12 -05:00
e2e Store sibling and grandparent edges when the linking parent is absent 2026-11-23 14:20:12 -05:00
migrations Store sibling and grandparent edges when the linking parent is absent 2026-11-23 14:20:12 -05:00
public Add default favicon and owner-uploadable site icon 2026-11-23 13:57:04 -05:00
scripts Replace scripts/integration-test.sh with e2e suites for authz, privacy, pages, relatives 2026-11-23 09:37:41 -05:00
seed Store sibling and grandparent edges when the linking parent is absent 2026-11-23 14:20:12 -05:00
src Store sibling and grandparent edges when the linking parent is absent 2026-11-23 14:20:12 -05:00
test Store sibling and grandparent edges when the linking parent is absent 2026-11-23 14:20:12 -05:00
.gitignore Add optional Turnstile to sign-in and sign-up forms 2026-11-22 20:39:19 -05:00
.nvmrc Scaffold Astro + Svelte app on cf with D1 schema 2026-11-22 19:02:48 -05:00
astro.config.mjs Add vitest e2e harness against the real app, with auth tests 2026-11-23 09:30:35 -05:00
cloudflare.config.ts Add optional Turnstile to sign-in and sign-up forms 2026-11-22 20:39:19 -05:00
components.json Add theme, shadcn-svelte components, branding settings, directory page 2026-11-22 19:39:05 -05:00
manifest.scm Scaffold Astro + Svelte app on cf with D1 schema 2026-11-22 19:02:48 -05:00
package-lock.json Add property-based tests for core invariants 2026-11-23 09:21:06 -05:00
package.json Add vitest e2e harness against the real app, with auth tests 2026-11-23 09:30:35 -05:00
README.md add script table headers 2026-11-23 14:46:06 -05:00
svelte.config.js Scaffold Astro + Svelte app on cf with D1 schema 2026-11-22 19:02:48 -05:00
tsconfig.json Add theme, shadcn-svelte components, branding settings, directory page 2026-11-22 19:39:05 -05:00
vitest.config.ts Add unit test harness and move pure policy code into src/lib/core 2026-11-22 21:03:58 -05:00
vitest.e2e.config.ts Add vitest e2e harness against the real app, with auth tests 2026-11-23 09:30:35 -05:00

Church Directory

A private, invite-only congregation directory on Cloudflare Workers (Astro + Svelte, D1, R2).

Prerequisites

  • Node.js ≥ 22.18 (.nvmrc pins 24). Bun is not supported.
  • Linux (glibc), macOS, or Windows/WSL. workerd comes from npm.

Setup

npm install
npm run db:migrate:local   # create/upgrade the local D1 database
npm run dev                # http://localhost:4321 (pass a port: npm run dev -- -- --port 8788)

Local state (D1, R2, ...) lives in .cloudflare/state/ and is gitignored.

Features

Sign-in and accounts

  • Email code / magic-link sign-in; only people in the directory can sign in.
  • Passkeys (fingerprint / face / device PIN) available after the first email sign-in.
  • Self-registration via admin-issued sign-up links, email verification, and admin approval.

Directory

  • Households and people with photos, phones, birthdays; archive (incl. memorial view).
  • Family connections across households: spouse, parent/child, and siblings/grandparents (derived through parents, or stored when the parent isn't in the directory).
  • Per-field privacy (self / household / leadership / members / everyone).
  • Upcoming birthdays and anniversaries.
  • Light and dark themes for every palette: follows the device by default, overridable per device on the Account page.

Editing

  • Editing for admins, household admins, and individuals (spec §5), with audit log.
  • Split / move-out / move / merge households; soft delete with undo and daily purge.
  • Email notifications when someone else edits your listing or household.

Administration

  • Roles, branding (name, logo, site icon, palette), retention, invitations.
  • CSV import; CSV export in the import format; full JSON backup for owners.
  • Printable directory (print or save as PDF from the browser).

DEMO_MODE (in cloudflare.config.ts) adds a "sign in as a sample person" picker. Never enable it with real data. In production, mail to reserved domains (example.com, *.test, …) is skipped, so demo data never sends real email.

Scripts

Script Action
npm run dev Local dev server (cf dev → astro dev on workerd)
npm run build Production build (cf build) to .cloudflare/output/
npm run deploy Build and deploy (cf deploy)
npm run types Regenerate binding types (.cloudflare/types) and Astro types
npm run check Types + astro check + unit tests
npm test Unit, property, and migration tests (test/; plain Node, no workerd, under a second)
npm run test:e2e End-to-end tests (e2e/) against the real app on cf dev with local D1/R2. Uses its own state in .cloudflare/e2e-state; your dev data is untouched. Needs network for the Turnstile test keys. Set E2E_PORT if 8799 is taken
npm run db:migrate:local / :remote Apply migrations/*.sql
npm run db:seed:local Load fictional demo data (seed/demo.sql)
npm run db:reset:local Wipe local state, migrate, and seed

In dev, POST /dev/maintenance (signed in) runs the daily cron job on demand; it 404s in production builds.

Tests

  • test/ (npm test): rules and pure logic. src/lib/core decisions (permissions, privacy, lifecycle plans), parsing and formatting, migrations and database triggers (on in-memory SQLite). Prefer properties (fast-check) over hand-picked examples where an invariant exists.
  • e2e/ (npm run test:e2e): user flows through the real app. Assert on what the database or the response actually did. Each file reseeds from seed/demo.sql. A refusal test needs a control showing the same request succeeds for someone allowed (see e2e/authz.test.ts); otherwise a malformed request passes as a refusal.
  • A good test fails when a behavior someone relies on breaks. Don't add tests that restate the implementation, check copy or styling, or exist for coverage numbers.

Tooling notes

  • This project uses the cf CLI with cloudflare.config.ts. Do not add a wrangler.jsonc. The Astro adapter refuses to build if one exists.
  • The few commands cf lacks run through npx wrangler with an explicit Worker name: npx wrangler tail church-directory.
  • @astrojs/cloudflare is on the 15.x beta. It is the first release that works with cf / Cloudflare Vite plugin 2.0. Versions are pinned exactly. Move to stable when it ships.
  • The D1 database ID lives in package.json → config.d1DatabaseId. It is read by cloudflare.config.ts and the migration scripts. The committed value is a placeholder that works locally. After cf d1 create, replace it with the real ID.
  • Deploy credentials: cf auth login, or CLOUDFLARE_API_TOKEN in .env (gitignored).

Guix

workerd is a prebuilt binary expecting /lib64/ld-linux-x86-64.so.2, so run everything inside an FHS container defined by manifest.scm:

scripts/guix-dev.sh                       # interactive shell
scripts/guix-dev.sh npm run dev           # or any single command

The container shares the project directory, ~/.npm, and the network (a dev server is reachable from the host). CLOUDFLARE_* environment variables are passed through.