- Migrate all DaisyUI 4 form markup (form-control, label-text, *-bordered — removed in v5) to v5 fieldset/legend; labels sat inline beside inputs and inputs fell back to a fixed 20rem width. - One Modal component (native <dialog>: Escape, focus trap) for page, event, item and slot editors; destructive actions confirmed everywhere. The page Delete confirm was ignored — returning false from onsubmit doesn't cancel — so Cancel still deleted the page. - Block editor follows the background-picker style throughout: SegmentedControl rows (title-cased options, clearer selected state) and a new ColorField row with reset; image position is Left/Right like the alignment controls. - Globals keep their layout; readable field labels, save feedback without reload, hints wrap. - Pages list: fixed broken Preview link (VITE_PUBLIC_SITE_URL was undefined → "undefined/slug"), shown for published pages only; action column no longer breaks row alignment; empty states on all tables. - Items: image picker instead of a raw media-id field, upload errors shown (were swallowed), prices in the shop currency instead of hard-coded EUR. - Slots/orders/calendar: times shown in the site timezone with a fixed locale (server and browser render the same text). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KgF3Kf47LjPGHKQHszpUAv |
||
|---|---|---|
| app-admin | ||
| app-public | ||
| backups | ||
| packages/shared | ||
| .dockerignore | ||
| .env.example | ||
| .gitignore | ||
| AGENTS.md | ||
| bun.lock | ||
| Caddyfile | ||
| CONTRACT.md | ||
| docker-compose.yml | ||
| pb_schema.json | ||
| README.md | ||
Massage Studio Website CMS
A full-stack SvelteKit CMS for a single-operator massage studio. PocketBase provides auth, database records, and image storage. The public site is warm and minimal; the admin UI uses DaisyUI components.
Stack
- SvelteKit + SSR (two apps: admin and public)
- PocketBase REST API via the
pocketbaseSDK - Tailwind CSS v4 + DaisyUI
- Docker Compose with four services:
app-admin,app-public,pocketbase, andcaddy(reverse proxy)
Architecture
The project is split into two independent SvelteKit apps, each serving its own subdomain:
app-admin— servesadmin.<domain>(admin UI, page editor, CRUD)app-public— serves*.<domain>(public CMS pages, shop, checkout)- PocketBase — serves
db.<domain>(auth, DB, image storage)
Shared types and calendar utilities live in packages/shared/ and are imported via the $shared alias declared in each app's svelte.config.js.
Development
The project runs exclusively through Docker Compose. There is no bare host dev mode.
- Copy the env file and fill in the secrets:
cp .env.example .env - Build and start the full stack:
DOMAIN=localhost docker compose up --build - Visit:
- Admin app:
http://admin.localhost:8080 - Public app:
http://www.localhost:8080 - PocketBase admin:
http://db.localhost:8080/_/
- Admin app:
Caddy's .localhost handling works without DNS or hosts-file changes. Source changes require rebuilding (docker compose up --build); the containers run the production build (node build), not a dev server.
Docker Compose
Run the full stack:
DOMAIN=localhost docker compose up --build
If dependency installation is slow on the first build, enable BuildKit explicitly:
DOCKER_BUILDKIT=1 docker compose build --progress=plain app-admin app-public
docker compose up
Subsequent builds reuse the npm cache declared in each app's Dockerfile.
- Admin app:
http://admin.localhost:8080→app-admin:3001 - Public app:
http://www.localhost:8080→app-public:3000 - PocketBase admin UI:
http://db.localhost:8080/_/(redirects/to/_/) - PocketBase REST API:
http://db.localhost:8080/api/
The app containers use two PocketBase URLs:
POCKETBASE_INTERNAL_URL=http://pocketbase:80for server-side SvelteKit calls from the app containers when using the includedspectado/pocketbaseimage.PUBLIC_POCKETBASE_URL=http://db.${DOMAIN}:8080for browser-side admin uploads and public file URLs. Points to the Caddy reverse proxy so browsers reach PocketBase via thedbsubdomain.
PocketBase setup
- Open
http://db.localhost:8080/_/. - Create the first PocketBase admin user when prompted.
- Import
pb_schema.jsonfrom the PocketBase admin UI collection settings/import flow. This file uses the newer PocketBasefieldsschema format; if PocketBase still reportsInvalid collections configuration, create the three collections manually using the fields below. - Create starter records:
pages: slughome, titleHome,published: true, and a blocks JSON array.globals: keyheader, data matching the header JSON in the project prompt.globals: keyfooter, data matching the footer JSON in the project prompt.
If the globals records do not exist, the app falls back to safe defaults and the admin globals page will create them.
Manual collection fields fallback
If schema import fails because of a PocketBase version mismatch, create these collections manually:
pagesslug: text, required, uniquetitle: text, requiredblocks: jsonpublished: bool
globalskey: text, required, uniquedata: json
mediafile: file, required, max select1, image mime typesalt: text
Commerce collections (see the Stripe section above for context):
items—nametext,descriptiontext,pricenumber,imagerelation→media,typeselectitem|item_with_time,stocknumber (nullable),durationnumber (nullable, minutes),activeboolslots—itemrelation→items,startdate,enddate,statusselectavailable|held|booked,heldUntildate (nullable),orderrelation→orders (nullable),notestextbaskets—statusselectactive|completed|abandoned,expiresAtdate,emailtext,customerDetailsjson,stripePaymentIntentIdtextbasket_lines—basketrelation→baskets,itemrelation→items,slotrelation→slots (nullable),quantitynumber,lineTypeselectitem|slotorders—basketrelation→baskets,emailtext,customerDetailsjson,totalnumber,statusselectpending|paid|refunded,stripePaymentIntentIdtext,customerEmailSentAtdate,clientEmailSentAtdate,emailErrortextorder_lines—orderrelation→orders,itemrelation→items,slotrelation→slots (nullable),quantitynumber,lineTypeselectitem|slot,nametext (snapshot),pricenumber (snapshot),startdate (nullable, snapshot)email_templates—keytext (unique:customer_confirmation|client_alert),subjecttext,blocksjson,recipientstext,enabledbool
Schema format note:
pb_schema.jsontargets PocketBase 0.23+ using thefieldsarray (not the legacyschemaarray). Relation and select fields carry their config (collectionId,cascadeDelete,maxSelect,values) at the field top level, not nested underoptions. Importing the whole file via the PocketBase admin UI orPUT /api/collections/importcreates or updates all collections in one pass.
Authentication
Admin routes live in the app-admin app. Login accepts either:
- a PocketBase admin account, or
- a record from a
usersauth collection if you create one.
All routes in app-admin except /login are guarded in src/hooks.server.ts.
CMS routes (admin app)
/login— sign in/pages— list/create pages/pages/[slug]— block editor with draft preview/calendar— events shown by Upcoming Calendar blocks/items— services and products shown in Shop blocks/slots— manually created bookable time slots for services/orders— confirmed bookings and purchases, with booking-email status and resend buttons/emails— block-based editor for the booking confirmation and new-booking alert emails (live preview, test send)/globals— header/footer/colors editor
Reservations & payments (Stripe)
The shop/checkout blocks implement a basket-based booking flow: visitors add services (with time slots) or products to a server-side basket, then pay with an embedded Stripe Payment Element. Order creation is confirmed by the Stripe webhook (never the client).
Setup:
- Add the Stripe + PocketBase-admin vars from
.env.exampleto.envat the project root. POCKETBASE_ADMIN_EMAIL/POCKETBASE_ADMIN_PASSWORDare the credentials of the PocketBase superuser you created — the basket/checkout/webhook APIs use a server-side admin client so collection rules can stay admin-only.- For local webhook testing, forward Stripe events with the CLI:
Copy the printedstripe listen --forward-to www.localhost:8080/api/webhooks/stripewhsec_…signing secret intoSTRIPE_WEBHOOK_SECRET. - Import the updated
pb_schema.json(addsitems,slots,baskets,basket_lines,orders,order_lines). Thebasket_lines.slotpartial unique index guarantees two visitors can't hold the same slot. - Create a published page (e.g. slug
book) with ashopblock and acheckoutblock, and point the header CTA at it.
Booking emails (Brevo)
After the Stripe webhook creates an order it sends two emails through an SMTP relay (Brevo) with nodemailer:
- Booking confirmation to the customer, with a
booking.icscalendar attachment for booked time slots. Reply-To is the footer email. - New booking alert to the studio (the template's recipients, or the footer email). Reply-To is the customer.
Both are edited in the admin under Emails using email blocks (text, image, button, spacer, divider, and auto-filled booking details / customer details / contact info). Text and subjects support placeholders like {{customer_first_name}} and {{booking_date}}. Until a template is saved, a built-in default is used. Rendering lives in packages/shared/src/email/ (pure, used by both the admin live preview and sending); sending lives in packages/shared/src/server/email/.
The result is recorded on the order (customerEmailSentAt, clientEmailSentAt, emailError); a failed email never fails the webhook and can be resent from /orders.
Setup:
- Import the updated
pb_schema.json(addsemail_templatesand the email fields onorders). - In Brevo: Settings → Senders, Domains & Dedicated IPs → Domains → Add a domain, then add the DNS records it shows (Brevo code TXT, the DKIM CNAMEs, DMARC TXT on
_dmarc) and click Authenticate. Add a sender such asbookings@yourdomain.com. - SMTP & API → SMTP → Generate a new SMTP key. Put the values in
.env:SMTP_HOST=smtp-relay.brevo.com,SMTP_PORT=587,SMTP_USER= the SMTP login shown there (…@smtp-brevo.com, not your account email),SMTP_PASS= the key,EMAIL_FROM/EMAIL_FROM_NAME= the sender. - Set
SITE_TIMEZONE(IANA name, defaultEurope/Oslo) — booking times in emails are shown in this zone. - Rebuild, open Emails in the admin, and use Send test email.
With SMTP_HOST empty (local dev) emails are written to the app container logs instead of being sent.
Public routes (public app)
/renderspages.slug = "home"/[slug]renders any other published page- Unpublished pages return
404
Notes
- Admin image uploads create records in the
mediacollection and store PocketBase file URLs in block JSON. - Draft preview writes current blocks to
sessionStorageand opens/previewin an iframe (same-origin on the admin subdomain). - The page editor includes draggable reordering using native HTML drag events for compatibility; the requested DnD packages are installed and can be swapped in later if desired.