7.4 KiB
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
- PocketBase REST API via the
pocketbaseSDK - Tailwind CSS v4 + DaisyUI
- Docker Compose with three services:
app,pocketbase, andcaddy(reverse proxy)
Local development
- Install Node.js
22.xor another version accepted by SvelteKit's Vite plugin. - Copy the app env file:
cp app/.env.example app/.env - Start PocketBase on port
8090. With Docker:docker compose up pocketbase - In another terminal:
cd app npm install npm run dev - Visit
http://localhost:5173.
Note: During local development (outside Docker), PocketBase is accessed directly at
http://localhost:8090. When running the full Docker stack, everything goes through the Caddy reverse proxy on port8080.
Docker Compose
Run the full stack:
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
docker compose up
Subsequent builds reuse the npm cache declared in the Dockerfile.
- Single entry point (Caddy reverse proxy):
http://localhost:8080- SvelteKit app:
http://localhost:8080/(or any non-API path) - PocketBase admin UI:
http://localhost:8080/_/ - PocketBase REST API:
http://localhost:8080/api/
- SvelteKit app:
- PocketBase direct access (internal only, not exposed):
http://localhost:8090
The app container uses two PocketBase URLs:
POCKETBASE_INTERNAL_URL=http://pocketbase:80for server-side SvelteKit calls from the app container when using the includedspectado/pocketbaseimage.PUBLIC_POCKETBASE_URL=http://localhost:8080for browser-side admin uploads and public file URLs. Since the Caddy reverse proxy routes/api/*to PocketBase, the public URL points to the proxy.
PocketBase setup
- Open
http://localhost:8080/_/(orhttp://localhost:8090/_/for direct access). - 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,stripePaymentIntentIdtextorder_lines—orderrelation→orders,itemrelation→items,slotrelation→slots (nullable),quantitynumber,lineTypeselectitem|slot,nametext (snapshot),pricenumber (snapshot),startdate (nullable, snapshot)
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 under /admin. Login accepts either:
- a PocketBase admin account, or
- a record from a
usersauth collection if you create one.
All /admin routes except /admin/login are guarded in src/hooks.server.ts.
CMS routes
/admin/login— sign in/admin/pages— list/create pages/admin/pages/[slug]— block editor with draft preview/admin/calendar— events shown by Upcoming Calendar blocks/admin/items— services and products shown in Shop blocks/admin/slots— manually created bookable time slots for services/admin/orders— read-only list of confirmed bookings and purchases/admin/globals— header/footer 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
app/.env.exampletoapp/.env(local dev) or a root-level.envnext todocker-compose.yml(Docker). 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 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.
Public routes
/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. - 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.