le-hoetel

Engineering guide

The stack, the packages, the commands and the rules every change follows.

Stack

  • pnpm workspace and turborepo, TypeScript everywhere, biome for format and lint plus oxlint
  • Next.js app router for apps/web (landing and public guest pages) and apps/dashboard (login and the hotel and admin app)
  • apps/api: oRPC on bun. The only app that touches the database, auth, storage and providers
  • Postgres with drizzle, better-auth, zod-validated env, shadcn components

Apps

AppWhat it is
apps/webLanding page and the public guest pages. Calls the api only
apps/dashboardLogin, hotel dashboard and admin panel. Calls the api only
apps/apioRPC api and the worker. Database, auth, storage and providers live here
apps/docsThis site
apps/emailreact-email preview app
apps/e2ePlaywright tests

Packages

PackageWhat it holds
@le-hoetel/uishadcn components and the theme tokens
@le-hoetel/commonzod schemas, constants and utils shared by api, web and dashboard
@le-hoetel/orpcprocedures and typed clients
@le-hoetel/dbdrizzle schema, migrations, seed scenario
@le-hoetel/authbetter-auth setup, organizations
@le-hoetel/envzod-validated env, one root .env
@le-hoetel/jobsbackground jobs on the same Postgres
@le-hoetel/notificationchannels, rendering and brand config for messages
@le-hoetel/storageS3 compatible storage
@le-hoetel/loggerstructured logger with redaction
@le-hoetel/i18nEnglish, French and Arabic messages and locale switching
@le-hoetel/complianceconsent helpers and banner
@le-hoetel/webhooksinbound webhooks
@le-hoetel/aiAI helpers
@le-hoetel/configshared tsconfig

More on the layout in structure.

The rule: the api only touches the database

apps/api is the only app that touches the database, auth, storage and providers. web and dashboard call it through @le-hoetel/orpc, so secrets and data access live in one place. Never import @le-hoetel/db from web or dashboard.

Commands

CommandWhat it does
pnpm devRun every app
pnpm buildBuild everything with turbo
pnpm checkFormat and fix
pnpm lintThe CI check
pnpm check-typesTypeScript across the repo
pnpm testTests in every package, against Postgres (pnpm db:up first)
pnpm test:e2ePlaywright tests on the demo seed
pnpm db:generate / db:migrate / db:seedDrizzle
pnpm ui:add <component>Add a shadcn component

Run only what you touched while iterating, the whole suite before handing off. The full list is in scripts and the first run in setup.

Conventions

  • oRPC: procedures live in packages/orpc/src/routers, built from publicProcedure or protectedProcedure. Validate input and output with zod. Throw ORPCError, never raw errors.
  • drizzle: the schema is in packages/db/src/schema. Change the schema, then run pnpm db:generate. Never hand-write a migration.
  • better-auth: configured once in packages/auth. Sessions are cookies, signed-in calls send x-csrf-token: orpc.
  • env: every variable goes through packages/env and .env.example. App code reads env through packages/env, not process.env. No secrets in diffs.
  • UI: reuse shadcn components from @le-hoetel/ui and the theme tokens. No hard-coded colors.
  • RTL: English, French and Arabic everywhere. Use logical CSS properties (ms-, me-, ps-, pe-, start, end), never left or right.
  • Files: kebab-case. React components have a kebab-case file and a PascalCase export. Functions and variables are camelCase, module constants are UPPER_SNAKE_CASE.
  • Code: explicit types, no any, short functions, no duplicate types or helpers, no comments that restate the code, smallest diff that does the job.

Product rules the code must keep

  • Every guest row and every query is scoped by hotel id.
  • Guests are not auth users.
  • Consent is logged per channel in an append-only log.
  • Never log a phone, email or name in plain text.
  • Previews, tests, local and staging never send real messages.

See data and consent rules and decisions.

Tests

  • One focused test per behavior or bug: it fails before the fix and passes after.
  • No happy-path padding, snapshot dumps, or tests of types or the framework.
  • Test through the public function or endpoint. Mock only external boundaries, never our own modules.
  • Tests run against a real Postgres. createTestDb() from @le-hoetel/db/testing gives a fresh migrated database and createTestApp() from @le-hoetel/orpc/testing the real services plus signUp() for signed-in clients.

Accessibility and speed budgets

  • apps/e2e/tests/a11y.spec.ts runs axe on the landing page, the QR capture page and the sign-in page in English and Arabic. Any serious or critical violation fails the e2e job.
  • The lighthouse workflow runs Lighthouse CI (apps/e2e/lighthouserc.json) on the QR capture page with the mobile throttling defaults, only when a pull request touches apps/web, packages/ui or packages/i18n. Accessibility must be at least 0.95 and blocks. Performance at least 0.8, LCP at most 3000 ms and script transfer at most 300 kB only warn until the runs are stable, then they become errors.

Adding an endpoint

See structure.

Docs for agents

This site serves /llms.txt (index), /llms-full.txt (every page) and each page as markdown at <page-url>.md, or send Accept: text/markdown.

On this page