98 lines
5.3 KiB
Markdown
98 lines
5.3 KiB
Markdown
# Massage Studio Website CMS — Agent Guidelines
|
|
|
|
## Stack
|
|
|
|
- **SvelteKit 2** (SSR, Svelte 5 runes mode) — all `.svelte` files use `$state`, `$derived`, `$props()` etc.
|
|
- **PocketBase** — REST API via the `pocketbase` SDK (v0.26). Auth, DB, and image storage.
|
|
- **Tailwind CSS v4** + **DaisyUI 5** — utility-first CSS with DaisyUI components for admin; custom theme for the public site.
|
|
- **Docker Compose** — three services: `app` (SvelteKit), `pocketbase`, and `caddy` (reverse proxy).
|
|
|
|
## Project Structure
|
|
|
|
```
|
|
app/ # SvelteKit application
|
|
├── src/
|
|
│ ├── lib/
|
|
│ │ ├── admin/ # Admin UI components (BlockList, editors)
|
|
│ │ ├── blocks/ # Public block renderers (one per BlockType)
|
|
│ │ ├── components/ # Header.svelte, Footer.svelte
|
|
│ │ ├── pb.ts # PocketBase client factory + helpers
|
|
│ │ └── types.ts # ContentBlock, PageRecord, HeaderGlobal, FooterGlobal
|
|
│ ├── routes/
|
|
│ │ ├── +layout.svelte # Root layout (admin vs public shell)
|
|
│ │ ├── +page.svelte # Home page (slug=home)
|
|
│ │ ├── [slug]/ # Dynamic CMS pages
|
|
│ │ ├── admin/ # Admin area (login, pages, globals)
|
|
│ │ └── preview/ # Draft preview via sessionStorage
|
|
│ └── app.css # Tailwind + DaisyUI + custom theme
|
|
├── static/ # Static assets
|
|
├── build/ # Production build output
|
|
├── svelte.config.js # Adapter-node, runes mode forced
|
|
├── vite.config.ts # Tailwind v4 + SvelteKit plugins
|
|
└── package.json
|
|
pocketbase/pb_data/ # PocketBase data (mounted volume-mounted)
|
|
docker-compose.yml # app + pocketbase services
|
|
Dockerfile # Multi-stage Node 22 build
|
|
```
|
|
|
|
## Key Conventions
|
|
|
|
### Svelte 5 Runes Mode
|
|
All components use Svelte 5 runes syntax — **never** `export let`, `$:`, or `on:click`. Use:
|
|
- `$props()` for component props
|
|
- `$state()` for reactive local state
|
|
- `$derived()` for computed values
|
|
- `$effect()` / `onMount` for side effects
|
|
- `{@render children()}` for slots
|
|
- `onclick={handler}` (not `on:click`)
|
|
|
|
### Block System
|
|
Pages are composed of `ContentBlock[]`. Each block has `{ id, type, data }`. Block types are defined in `$lib/types.ts`:
|
|
`text | image | image_text | timeline | testimonials | services | cta | spacer | horizontal_cards`
|
|
|
|
- **Public renderers**: `$lib/blocks/<Type>Block.svelte` — one per type, receives `data` prop. Currently active: `TextBlock`, `ImageTextBlock`, `TimelineBlock`, `HeroBlock`.
|
|
- **Admin editors**: `$lib/admin/editors/BlockEditor.svelte` — switches editor UI by type
|
|
- **Defaults**: `$lib/admin/blockDefaults.ts` — `createBlock(type)` generates a new block with sensible defaults
|
|
- **Block list**: `$lib/admin/BlockList.svelte` — draggable reorder, select, delete
|
|
|
|
To add a new block type: add to `BlockType` union in `types.ts`, create renderer in `$lib/blocks/`, add editor case in `BlockEditor.svelte`, add default in `blockDefaults.ts`, add import in `BlockRenderer.svelte`.
|
|
|
|
### PocketBase Integration
|
|
- Client created in `hooks.server.ts` (`event.locals.pb`) — injected per-request with auth cookie
|
|
- `$lib/pb.ts` exports `createPocketBase()`, `getFileUrl()`, `uploadMedia()`
|
|
- Collections: `pages` (slug, title, blocks[], published), `globals` (key, data), `media` (file, alt)
|
|
- Server load functions use `locals.pb.collection('pages').getFirstListItem()`
|
|
|
|
### Styling
|
|
- **Public site**: Custom theme via `@theme` in `app.css` — colors: `warm`, `charcoal`, `sage`, `sage-dark`, `terracotta`. Fonts: `DM Sans` (body), `Playfair Display` (headings).
|
|
- **Admin area**: DaisyUI utility classes (`btn`, `card`, `input`, `select`, `rounded-box`, etc.)
|
|
- **Prose**: `.prose-wellness` class for rich text content styling
|
|
|
|
### Routing
|
|
- `+layout.server.ts` fetches header/footer globals for every public page
|
|
- `+page.server.ts` for home fetches `slug = "home" && published = true`
|
|
- `[slug]/+page.server.ts` fetches by dynamic slug
|
|
- Admin routes protected in `hooks.server.ts` — redirects to `/admin/login` if unauthenticated
|
|
|
|
## Build & Dev Commands
|
|
|
|
```sh
|
|
# Full stack (single entry point on port 8080) — the only supported way to run/develop
|
|
# Source changes require rebuilding; the container runs `node build`, not a dev server.
|
|
docker compose up --build
|
|
# App + PocketBase via Caddy: http://localhost:8080
|
|
# PocketBase admin: http://localhost:8080/_/
|
|
|
|
# Type checking (can run on the host with node_modules present, or inside the container)
|
|
cd app && npm run check
|
|
|
|
# Production build only (run by the Dockerfile)
|
|
cd app && npm run build
|
|
```
|
|
|
|
## Environment
|
|
|
|
- `PUBLIC_POCKETBASE_URL` — public-facing PocketBase URL, accessed through the Caddy reverse proxy (`http://localhost:8080`). Set directly in `docker-compose.yml`.
|
|
- `POCKETBASE_INTERNAL_URL` — internal Docker network URL (`http://pocketbase:80`). Set directly in `docker-compose.yml`.
|
|
- `ORIGIN` — SvelteKit origin for SSR (`http://localhost:8080`). Set directly in `docker-compose.yml`.
|
|
- Stripe + PocketBase admin secrets are read from a root-level `.env` next to `docker-compose.yml`; see `.env.example`.
|