- TypeScript 68.9%
- Astro 20.5%
- Svelte 9.1%
- CSS 1.2%
- JavaScript 0.2%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| docs | ||
| e2e | ||
| migrations | ||
| public | ||
| scripts | ||
| seed | ||
| src | ||
| test | ||
| .gitignore | ||
| .nvmrc | ||
| astro.config.mjs | ||
| cloudflare.config.ts | ||
| components.json | ||
| manifest.scm | ||
| package-lock.json | ||
| package.json | ||
| README.md | ||
| svelte.config.js | ||
| tsconfig.json | ||
| vitest.config.ts | ||
| vitest.e2e.config.ts | ||
Church Directory
A private, invite-only congregation directory on Cloudflare Workers (Astro + Svelte, D1, R2).
Prerequisites
- Node.js ≥ 22.18 (
.nvmrcpins 24). Bun is not supported. - Linux (glibc), macOS, or Windows/WSL.
workerdcomes 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/coredecisions (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 fromseed/demo.sql. A refusal test needs a control showing the same request succeeds for someone allowed (seee2e/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
cfCLI withcloudflare.config.ts. Do not add awrangler.jsonc. The Astro adapter refuses to build if one exists. - The few commands
cflacks run throughnpx wranglerwith an explicit Worker name:npx wrangler tail church-directory. @astrojs/cloudflareis on the 15.x beta. It is the first release that works withcf/ 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 bycloudflare.config.tsand the migration scripts. The committed value is a placeholder that works locally. Aftercf d1 create, replace it with the real ID. - Deploy credentials:
cf auth login, orCLOUDFLARE_API_TOKENin.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.