Development
Developer documentation for Booking.
Getting started
pnpm install
echo 'SQL_ENABLED=true' > .env # gitignored; other env comes from .env.defaults
pnpm dev # watch mode, app on :8080, metrics/health on :9090
pnpm test # unit/route tests (vitest)
pnpm lint # eslint, check only (what CI runs)
pnpm lint:fix # eslint --fix
pnpm typecheck # tsc --build
# integration tests against real MariaDB
podman compose up -d # or: docker compose up -d
pnpm integration
# database migrations (umzug via fastify-sdk)
pnpm migrate # run all pending (K8s job entry point)
pnpm migrate:cli pending # CLI: up | down | pending | executed | create --name <name>
# frontends (Vue 3 + Vite)
pnpm ui:build # build both: ui-plugin (/booking/plugin/) and ui-poll (/booking/poll/)
pnpm ui:dev # ui-plugin dev server with App Suite proxy
pnpm poll:dev # ui-poll dev server (standalone voting page)
# component tests (Vue components in a real Chromium)
npx playwright install chromium
pnpm test:browser
# e2e (CodeceptJS + Playwright, needs an App Suite stack)
pnpm e2e
# docs (this site)
pnpm -C docs dev
pnpm -C docs buildA local dev environment end to end
- Start the local stack -
podman compose up -d(ordocker compose up -d) brings up MariaDB (:3306) and a mailpit mail sink (SMTP:1025, web UI at http://localhost:8025). - Enable the DB pool - create
.env(gitignored) with at leastSQL_ENABLED=true; the DB credentials come from.env.defaultsand already match the compose stack. PointAPP_SUITE_APIat a real App Suite (a preview, orappsuite-main) only if you need the session-authed owner API - the public booking/poll pages work without it. - Run
pnpm dev. The public pages are served by the backend at /booking/book/ and/booking/poll/, and any mail the service sends lands in mailpit.
Service config is layered flat YAML under $CONFIG_PATH (config/ locally): config/config.yaml is committed with working local defaults (mail → mailpit, localhost base URLs) so pnpm dev works out of the box, and config/config.local.yaml (gitignored, same shape) is merged on top for per-developer tweaks. Both hot-reload. config/ is kept out of the image, so these local defaults never ship: prod/preview mount the config from a ConfigMap, and an image run without one gets the code defaults (see operations).
Stack
- Runtime: Node.js ≥24, TypeScript via native type stripping (
node src/index.tsdirectly - no backend build step;tsc --buildis typecheck-only). - Framework: Fastify 5 via
@open-xchange/fastify-sdk(createApp()), which supplies config loading, logging, health/metrics, MariaDB pool lifecycle, and migration tooling. - Database: MariaDB, plain SQL with named placeholders (
src/db/), Umzug migrations (src/migrations/booking/). - Outbound HTTP: undici, wrapping calls into the App Suite middleware (
src/appsuite/). - Frontends: two Vue 3 + Vite 8 apps,
ui-pluginandui-poll, each their own pnpm workspace package. - Testing: vitest for unit and route tests (
test/) and integration tests against a real database (integration/); vitest browser mode on the Playwright provider for component tests (ui-plugin/*.browser.test.js); CodeceptJS +@open-xchange/appsuite-codeceptjson the Playwright driver for e2e (e2e/). - Package management: pnpm workspaces (root +
ui-plugin+ui-poll+e2e).
Project layout
src/
├── index.ts # loadEnv → requireEnv → createApp → start
├── config.ts # hot-reloaded service configuration (Joi-validated)
├── migrate.ts # K8s migration Job entry point
├── appsuite/ # HTTP clients to App Suite middleware (users, capabilities, folders, chronos)
├── db/ # repositories: pool.ts + users/polls/events/voters/votes
├── migrations/booking/ # Umzug migrations
├── plugins/ # session context, error mapping, rate limiting, static poll page
├── services/ # domain logic: polls-v1 (per-resource), calendar, cleanup, datetime, metrics
├── routes/
│ ├── root.ts # service status page
│ ├── booking/v1/ # /booking/v1 - the API surface (guidelines-conformant)
│ └── booking/mcp/ # /booking/mcp - public MCP endpoint (ADR-0012)
└── types/ # domain types, fastify request augmentationArchitecture decisions
- Record architecture decisions
- TypeScript with Node type stripping
- Adopt @open-xchange/fastify-sdk
- MariaDB, plain SQL, and Umzug migrations
- Serve /booking/api initially, target a /v1 surface (done:
/booking/apiis removed) - App Suite session auth first, OIDC later
- Hot-reloaded config replaces PATCH /config
- ArgoCD previews via the shared CI component
- Plain migration Job
- Calendar integration via iMIP, not middleware APIs
- Outbound mail: nodemailer + Liquid templates + DB outbox
Key patterns and gotchas
These are durable, non-obvious behaviors ported from the original Java service. Getting them wrong reintroduces subtle incompatibilities with existing clients and data.
- One error shape, one catalog.
/booking/v1responds with the guidelines shape{code, message}(validation failures:{code: 0x1, message, errors: [{field, message}]}), produced bysrc/plugins/errors.tsfrom the hex-code catalog insrc/appsuite/errors.ts. The Java-inherited{code, error}shape survives only outside/booking/v1(the MCP endpoint's transport errors); it went away for the API together with the legacy/booking/apisurface (ADR-0005). The/v1-only codes (0x1,0x804,0x1004,0x1005,0x1006,0x4005) have no Java counterpart. - Bind datetimes as UTC strings, never
Date. Themariadbdriver encodes JSDateobjects as local wall-clock time, which silently corrupts stored instants. Always go throughtoDbDateTime/isoLocalToDb(src/db/pool.ts,src/services/datetime.ts);TIMESTAMP/DATETIMEcolumns decode back as plain strings. - Route autoload uses
routeParams: truewith_pollId/subdirectories. Fastify's filesystem router only picks up sibling files next to anindex.tswhen the param is expressed as its own directory (polls/_pollId/index.ts,polls/_pollId/voters/index.ts, etc.) - a flatpolls/_pollId.tsfile will not pick up nested routes. Seesrc/routes/booking/v1/polls/. - Config is flat YAML that keeps the Java key names.
config.yaml(underCONFIG_PATH) has nocom.openexchange.booking.*prefix and is hot-reloaded via the SDK's config registry - but key names (pollBaseURL,maxPolls,autoDeletionIntervalMinutes, ...) are kept identical to the originalServiceConfig/RequestConfigJava fields. It loads in two layers, both optional and watched:config.yaml(base) thenconfig.local.yamlmerged on top (DEFAULTS → config.yaml → config.local.yaml, key-wise formail); locally the base carries working dev defaults and the override is gitignored, in prod the override can be a second ConfigMap. Keys removed from a file fall back to the layer beneath on the next reload; there is noPATCH /configendpoint anymore. - The cleanup job must stay idempotent across replicas.
cleanupPolls()(src/services/cleanup.ts) batch-deletes expired polls (5000 rows/batch) on a fixed interval with no cross-replica locking - the delete itself is the coordination (a poll already deleted by another replica is simply not matched again). Don't add stateful scheduling assumptions that break under 2+ replicas. - The plugin owns its "What's New" entries. App Suite's What's New dialog builds its feature list in core-ui (
pe/core/whatsnew/meta.js) and hands that list to every extension of thepe/core/whatsnew/dialog/featurelistpoint, rendering whatever they return.ui-plugin/src/booking-web/whatsnew.jsuses that seam, so the copy, the illustrations (ui-plugin/src/themes/illustrations/, imported with?no-inlineso they stay out of the boot chunk and resolve into the plugin's own static tree) and the translations ship with the release that ships the features, and no core-ui change is needed. The entries carry no capability gate because the plugin's manifest already requiresbooking && !guest && calendar, anddevice: '!smartphone'matches the desktop-onlyio.ox/calendar/actions/bookingaction they link to. Theirversionmust name a release core-ui knows in itsdatesmap, otherwise the dialog files the entry under 8.0 (March 2022). - Health/metrics live on a separate port.
:9090serves/live,/ready,/metricsvia the SDK; the app itself listens on:8080(PORT). Domain counters (booking_polls_total,booking_voters_total,booking_votes_total) are defined insrc/services/metrics.ts.
Commit style
Keep-a-changelog prefixes: Add:, Update:, Fix:, Remove:, Change:. Subject ≤ 72 chars. Focus on why. No AI-generation footers. CHANGELOG.md is maintained by hand (not auto-generated) - add an entry under [Unreleased] for user-facing changes. See the project CLAUDE.md at the repo root for the full contribution guidelines.

