Skip to content

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 build

A local dev environment end to end

  1. Start the local stack - podman compose up -d (or docker compose up -d) brings up MariaDB (:3306) and a mailpit mail sink (SMTP :1025, web UI at http://localhost:8025).
  2. Enable the DB pool - create .env (gitignored) with at least SQL_ENABLED=true; the DB credentials come from .env.defaults and already match the compose stack. Point APP_SUITE_API at a real App Suite (a preview, or appsuite-main) only if you need the session-authed owner API - the public booking/poll pages work without it.
  3. 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.ts directly - no backend build step; tsc --build is 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-plugin and ui-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-codeceptjs on 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 augmentation

Architecture decisions

  1. Record architecture decisions
  2. TypeScript with Node type stripping
  3. Adopt @open-xchange/fastify-sdk
  4. MariaDB, plain SQL, and Umzug migrations
  5. Serve /booking/api initially, target a /v1 surface (done: /booking/api is removed)
  6. App Suite session auth first, OIDC later
  7. Hot-reloaded config replaces PATCH /config
  8. ArgoCD previews via the shared CI component
  9. Plain migration Job
  10. Calendar integration via iMIP, not middleware APIs
  11. 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/v1 responds with the guidelines shape {code, message} (validation failures: {code: 0x1, message, errors: [{field, message}]}), produced by src/plugins/errors.ts from the hex-code catalog in src/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/api surface (ADR-0005). The /v1-only codes (0x1, 0x804, 0x1004, 0x1005, 0x1006, 0x4005) have no Java counterpart.
  • Bind datetimes as UTC strings, never Date. The mariadb driver encodes JS Date objects as local wall-clock time, which silently corrupts stored instants. Always go through toDbDateTime/isoLocalToDb (src/db/pool.ts, src/services/datetime.ts); TIMESTAMP/DATETIME columns decode back as plain strings.
  • Route autoload uses routeParams: true with _pollId/ subdirectories. Fastify's filesystem router only picks up sibling files next to an index.ts when the param is expressed as its own directory (polls/_pollId/index.ts, polls/_pollId/voters/index.ts, etc.) - a flat polls/_pollId.ts file will not pick up nested routes. See src/routes/booking/v1/polls/.
  • Config is flat YAML that keeps the Java key names. config.yaml (under CONFIG_PATH) has no com.openexchange.booking.* prefix and is hot-reloaded via the SDK's config registry - but key names (pollBaseURL, maxPolls, autoDeletionIntervalMinutes, ...) are kept identical to the original ServiceConfig/RequestConfig Java fields. It loads in two layers, both optional and watched: config.yaml (base) then config.local.yaml merged on top (DEFAULTS → config.yaml → config.local.yaml, key-wise for mail); 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 no PATCH /config endpoint 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 the pe/core/whatsnew/dialog/featurelist point, rendering whatever they return. ui-plugin/src/booking-web/whatsnew.js uses that seam, so the copy, the illustrations (ui-plugin/src/themes/illustrations/, imported with ?no-inline so 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 requires booking && !guest && calendar, and device: '!smartphone' matches the desktop-only io.ox/calendar/actions/booking action they link to. Their version must name a release core-ui knows in its dates map, otherwise the dialog files the entry under 8.0 (March 2022).
  • Health/metrics live on a separate port. :9090 serves /live, /ready, /metrics via the SDK; the app itself listens on :8080 (PORT). Domain counters (booking_polls_total, booking_voters_total, booking_votes_total) are defined in src/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.