Repository Guidelines
Project Structure & Module Organization
src/routes/holds SvelteKit pages; nested folders map to routes, with shared data wired through+layout.*.src/lib/components/contains reusable UI, whilesrc/lib/server/hosts server-only helpers and database adapters.- Unit specs live beside code as
*.spec.ts; Playwright flows sit ine2e/; static assets land instatic/. - Drizzle migrations are versioned in
drizzle/, with tooling indrizzle.config.tsand bindings described bywrangler.jsonc.
Build, Test, and Development Commands
npm run devlaunches the Vite dev server; append-- --opento auto-open a browser tab.npm run checkperformssvelte-kit syncplussvelte-checkagainsttsconfig.jsonfor type safety.npm run buildcompiles the production bundle;npm run previewserves it viawrangler pages dev.npm run lintruns Prettier (check) and ESLint; usenpm run formatto fix style issues.npm run testruns Vitest headlessly and then Playwright;npm run test:unit -- --watchkeeps Vitest hot during development.- Database helpers:
npm run db:generatecreates snapshots,npm run db:pushsyncs schema, andnpm run db:migrate:localapplies migrations.
Coding Style & Naming Conventions
- TypeScript is mandatory; organize Svelte files as
<script lang="ts">, markup, then optional<style lang="scss">. - Prettier enforces tabs for HTML, JS/TS, CSS/Sass, and Svelte plus double quotes and 100-char width—run
npm run formatto stay aligned. - Name Svelte components in PascalCase, server utilities in camelCase, and route folders in kebab-case (
admin-dashboard). - Form fields do not need a background color.
Testing Guidelines
- Place unit specs beside the code (
*.spec.ts), mock remote calls, and label Vitestdescribeblocks after the module under test. - Maintain e2e journeys in
e2e/*.test.ts, favoring resilient selectors such asgetByRoleto prevent flakiness. - Refresh database state through Drizzle migrations or Cloudflare D1 resets before and after destructive tests.
Commit & Pull Request Guidelines
- Use short, present-tense commit messages (
Show countdown to events this season), mirroring the current history. - Group related changes per commit and confirm
npm run lintplusnpm run testpass locally before pushing. - Pull requests need a summary, linked issue when available, UI screenshots for visible changes, and callouts for database or Cloudflare impacts.
Cloudflare & Environment Notes
- Wrangler commands rely on the
bionic_portal_dbD1 binding; rerunnpm run cf-typegenafter binding updates to refreshsrc/worker-configuration.d.ts. - Mirror Wrangler secrets in your local
.env; never commit credentials—document the setup steps instead.