Skip to content
DD-UXPublic

About

Boutique hotels and unique stays — classic by day, neon by night.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Călător

Boutique stays, classic by day, neon by night.

A small but complete travel-booking flow — discover → details → reviews → checkout → confirmed booking — built as a Turborepo monorepo with a Next.js 16 App Router frontend and its own API. Around that spine sit the things a returning visitor expects: saved stays, and a My Reviews hub for what you have written, what is still waiting on you, and what hosts have written about you.

Călător — "traveler" in Romanian, a nod to Lateral's roots.

Live: calator-web.vercel.app — Next.js on Vercel, data on Turso, seeded from the same deterministic fixture you get locally. Nothing below requires it: everything also runs from a fresh clone with no env file and no external service, because packages/db picks its world from the environment and defaults to a file on disk. The runbook is written out below.

Classic Neon
Search, classic Search, neon
Stay, classic Stay, neon
Welcome, classic Welcome, neon

Mobile: classic · neon. The theme is read from a cookie in the root layout, so data-theme is correct in the first byte of HTML — there is no flash to suppress and the palette survives JavaScript being off.


Quick start

Local development needs no env file, no account and no external service. The database is a single file on disk, created on first run. Nothing here touches the network.

nvm use            # Node 24 (pinned in .nvmrc)
corepack enable    # pnpm 11.18.0, pinned in package.json#packageManager
pnpm install
pnpm showcase      # seed the DB if it has never been seeded, then run everything

That is the whole setup. showcase migrates, seeds only on a first run, and then starts the app on localhost:3000 and Storybook on localhost:6006 together.

Why not db:setup && dev? Because that pair is not safe to type twice. db:seed is idempotent by deletion — it clears the tables and writes the fixture again — so the second run silently destroys the booking you made during the first, and the failure is invisible: the app still works, it has just quietly forgotten you. showcase is the command that can be typed twice; pnpm showcase --reseed is how you ask for the wipe on purpose.

(And it is db:setup rather than setup because pnpm setup is a built-in pnpm command that edits your shell profile, and built-ins win over package scripts.)

The app opens on a welcome gate. There is no sign-in: pressing Continue as Maya Santos sets a calator_user cookie and that is the whole session model. The UI says so in as many words — a mock dressed up as auth would be the one dishonest thing in here.

To see the interesting parts quickly:

  • The server refusing to be lied to. Pick any stay, choose dates, book it — then try to book the same nights again. The server re-checks availability and recomputes the total from its own prices, so the second attempt gets a 409 and a page that explains it.
  • A payment that fails on purpose. At checkout, card 4242 4242 4242 4242 succeeds and 4000 0000 0000 0002 is declined; both are labelled in the form.
  • Moderation with its thumb on the scale. Open My Reviews from the account menu: the seed leaves Maya with finished trips waiting to be reviewed. Write a normal one and it publishes to the stay page; write one containing crypto, or two links, or in ALL CAPITALS, and it is held — visible to you, marked as held, and absent from the stay page.
  • Saved stays that agree with themselves. Tap a heart on the grid, and the details page, the header count and /favorites all follow; un-save from /favorites and go back — the heart stays off, which is not free and has a spec holding it down.

Optional: run it against Turso instead

Nothing above needs this — it is here because the same code runs both ways and it costs two variables to prove it. packages/db picks its world from the environment: with nothing set it opens the local file, and with CALATOR_DB_URL set it speaks to a hosted libSQL database through the same driver. No code changes, no build flag.

export CALATOR_DB_URL=libsql://calator-<org>.turso.io
export CALATOR_DB_AUTH_TOKEN=<token>

pnpm db:migrate    # both scripts follow the exported URL
pnpm db:seed       # warns first: "seeding a REMOTE database"
pnpm dev           # the app now reads and writes that database
Variable Effect
(none) file:db/calator.db at the repo root — the default
CALATOR_DB_URL + CALATOR_DB_AUTH_TOKEN that libSQL database instead
CALATOR_TURSO_DATABASE_URL + CALATOR_TURSO_AUTH_TOKEN the names Vercel's Marketplace injects, honoured as fallbacks

Two things to know before you do it. Presence, not truthiness decides: CALATOR_DB_URL="" counts as set, because a deploy that reads an empty string as "unset" writes to a throwaway file inside a serverless container and loses every booking at the end of the request. And pnpm showcase refuses to run when either URL variable is present — it exists to lay down demo data, and db:seed replaces every row it touches, so it will not aim that at something remote. Use pnpm dev for the hosted case, as above.

See Deploy for the same variables in a Vercel project.

Commands

pnpm showcase                # the one command for a fresh clone: seed once, then run it all
pnpm showcase --reseed       # throw the demo data away and lay it down again first
pnpm dev                     # Next dev server (Turbopack) + Storybook
pnpm build                   # production bundles
pnpm validate                # format check + typecheck + lint + unit tests
./scripts/validate.sh --scope packages/ui   # the same gate, one workspace

pnpm test                    # unit (Vitest)
pnpm test:e2e                # Playwright, desktop + mobile, freshly seeded local DB
pnpm test:a11y               # axe over every story × both themes
./scripts/smoke-api.sh       # every route handler over HTTP, against a running server

pnpm format                  # Prettier (sorted imports + sorted Tailwind classes)
pnpm lint                    # ESLint
pnpm typecheck               # tsc --noEmit

pnpm db:setup                # migrate + seed (destructive on a second run — see above)
pnpm db:generate             # drizzle-kit: diff schema → new migration
pnpm db:migrate / db:seed    # read NO env files; follow CALATOR_DB_URL if you export it
pnpm db:reset                # delete the local file, migrate, seed (refuses a remote URL)
pnpm db:studio               # inspect data
pnpm db:migrate:remote       # Turso — reads .env.turso, and only .env.turso
pnpm db:seed:remote          # ditto

pnpm release:dry             # preview the next version and its changelog section
pnpm release -- --title "…"  # cut the milestone: changelog, version bump, tag

Architecture

config ──→ schemas ──→ db  ──┐
   │           └────→ sdk ──┤→ apps/web
   └────→ ui ───────────────┘
Workspace Role
apps/web Next.js 16 App Router — pages, route handlers, features
apps/e2e Playwright suite; reaches the app over HTTP, never through the SDK
packages/schemas Zod schemas — the single source of truth for every shape
packages/db Drizzle over libSQL; the only code that talks to the database
packages/sdk The typed API client; the only place the frontend calls fetch
packages/ui Design system — tokens, primitives, motion presets, Storybook
packages/config Shared TypeScript, ESLint, Prettier and Tailwind configuration

Dependencies run one way. apps/e2e sits outside the graph looking in: it imports schemas (to parse responses with the same contracts the app uses) and db (to seed), and reaches the app over HTTP — deliberately not through the SDK, so a bug inside the SDK cannot make the specs and the app agree with each other and both be wrong.

Request flow

The app is client-rendered by design. React Server Components render the static shell and nothing else; every piece of domain data arrives over HTTP through @calator/sdk. The network tab is meant to be read.

  browser
     │
     │  ①  RSC renders the shell — no domain data crosses this line
     ▼
  app/(app)/stays/page.tsx  ──►  features/stays/…/StaysContent.tsx   "use client"
                                        │
                                        │  ②  useAsyncResource → load(), awaited and abortable
                                        ▼
                                  @calator/sdk · getStays(query, signal)
                                        │      safeParse the QUERY before it leaves
                                        │
                                        │  ③  the only fetch() in the frontend
                                        ▼
                                  GET /api/stays?q=…&checkIn=…&page=…
                                        │
                                        ▼
                                  withRoute('GET /api/stays')   → requestId · status · durationMs
                                        │
                                        │  ④  StaysQuerySchema.safeParse — the SAME schema
                                        │      the SDK used; a failure is 400 + flattened issues
                                        ▼
                                  @calator/db · Drizzle over libSQL
                                        │
                                        │  ⑤  NextResponse.json(… satisfies StaysResponseType)
                                        ▼
                                  @calator/sdk · safeParse the RESPONSE
                                        │      → StayModel[]  ·  or a typed ApiError
                                        ▼
                                  status · data · error · isFirstLoad · isRefreshing

Every boundary crossing is safeParsed and never cast, in both directions, against a schema that lives in packages/schemas and is imported by the client, the server and the form resolver alike. There is no second definition of "a valid search" to drift out of sync.

The server is the source of truth, and POST /api/bookings is where that is load bearing:

  1. CreateBookingInputSchema.safeParse(await req.json()) — no shape is trusted.
  2. getCurrentUserId() reads the calator_user cookie (server/identity.helpers.ts). Identity is attached server-side only — no request body carries a userId, ever, so no client can book as somebody else by editing a payload.
  3. Inside one transaction: re-read the stay, re-check availability against blackout dates and confirmed bookings, and recompute the total from database prices. The number the checkout page displayed is display-only. Two people booking the same nights cannot both win; the loser gets a 409 and a screen that explains it.

API surface

Fourteen route modules under apps/web/src/app/api. ./scripts/smoke-api.sh exercises all of them over HTTP and asserts on status codes and bodies.

Route Methods Purpose
/api/health GET Liveness — { ok: true }. What the e2e web server waits on
/api/session POST DELETE Open and close the demo session (sets/clears the cookie)
/api/me GET The current demo user
/api/stays GET Search: filters, sort, availability, pagination
/api/stays/[slug] GET One stay with its rating summary
/api/stays/[slug]/availability GET Blocked ranges, for the calendar
/api/stays/[slug]/reviews GET POST Published reviews; add one, subject to moderation
/api/favorites GET The current user's saved stays
/api/favorites/[stayId] PUT DELETE Save and unsave
/api/bookings POST Create — re-validates availability, recomputes the total
/api/bookings/[code] GET Look a confirmed booking up by its code
/api/users/me/reviews GET Reviews you wrote — flagged ones included, marked as such
/api/users/me/guest-reviews GET Reviews written about you as a guest
/api/users/me/reviewable-stays GET Stays you have finished and not yet reviewed

The three /api/users/me/* routes are the ones that make My Reviews work, and they are the reason identity is never a path parameter: me resolves from the cookie server-side, so there is no user id in a URL for anyone to change.


Key decisions & tradeoffs

The full log, including rejected alternatives, lives in docs/decisions.md. Headlines:

  • Next route handlers as the backend — one deployable, one type system, no CORS.
  • libSQL / Turso — the driver is pure JS, so there is no native module to compile and no postinstall script to trust; the same code runs against a local file and a hosted database, chosen by environment.
  • No auth, demo identity — a cookie-scoped user, attached server-side only. Real auth is scope, not insight, and a fake login screen would only be theatre.
  • Mocked payments, framed as mocks in the UI, with a decline card so the failure path is demonstrable rather than described.
  • URL-state search — applied filters live in the query string, so every result set is shareable and the back button behaves. Draft edits in the filter panel stay local until applied. Applied dates travel: a range picked in the filters narrows the results by availability and arrives at the stay's page already selected.
  • Money is integer cents everywhere — storage, transport and arithmetic. It becomes a string once, at the render edge.
  • Two themes, one token sheet. Components read --cal-* custom properties and never a literal colour; both palettes are held to WCAG AA by pnpm test:a11y rather than by a comment claiming they are.

Testing

Tier Tool Scope
Unit Vitest 113 colocated files — pricing, availability, date maths, schemas, hooks, components
E2E Playwright 7 specs × a desktop and a mobile project, against a production build
A11y axe Every story × both themes; non-zero exit on any violation

Unit tests are colocated (Foo.tsx beside Foo.test.tsx) and land in the same commit as the code they cover. The browser suite runs against next build output on its own port, with every CALATOR_* variable deleted from the environment first — deleted rather than blanked, because the database client tests for presence and an empty URL fails at connect time with a message that explains nothing.

The seven specs are the ones worth having: the booking a visitor came to make, the double-booking the server refuses, the review held for moderation next to the one that publishes, the review a visitor with no session is refused by the server rather than merely by a hidden form, the favourite that is let go of and stays let go through both the back button and a cold visit, the theme that survives a reload and arrives already applied in the server HTML, the search that finds nothing and says so, and the session that opens and closes.

They earned their keep on the first green run, by finding two shipped defects that no unit test could see — because the unit tests mock the very hooks that carried them. /stays never re-fetched when the URL changed, so filtering and paging rewrote the address bar while the grid sat frozen; and useAsyncResource reported "loaded, zero results" on its first render, so every list server-rendered its empty state before it had asked a question. Both are fixed, both have regression tests.


Observability

Structured JSON logging via pino. Every route handler is wrapped by withRoute (server/route.helpers.ts), which stamps a request id, times the handler, and emits one line per request whatever the outcome:

{
  "level": 30,
  "requestId": "801290e7-0b78-418d-b84d-bc194c49c6e6",
  "method": "GET",
  "route": "GET /api/stays",
  "status": 200,
  "durationMs": 4,
  "msg": "GET GET /api/stays 200 4ms"
}

The level follows the status — 5xx logs at error, 4xx at warn, everything else at info — so a log search for real failures does not have to know which status codes matter. Unhandled throws are logged with their message and stack, keyed to the same request id, before the 500 goes out.

There is no pino-pretty transport wired in. Transports spawn a worker thread that the bundler has to be taught about, and the payoff is colour; pnpm --filter web dev | npx pino-pretty gets the same result without the dependency.

GET /api/health is the liveness probe, and is what the Playwright web server waits on before the first spec runs.


Release & deploy

Commits are Conventional Commits. Versions mark milestones, not pushes — a phase lands, the gate is green, and pnpm release reads the commits since the last tag, writes the CHANGELOG.md section, bumps the version and cuts an annotated tag. scripts/release.mjs is ~200 lines and never pushes.

CI runs three independent jobs so one push reports everything that is wrong: verify (format → typecheck → lint → unit → build), e2e, and a11y. All three run against a freshly seeded local file database; no job needs a secret.

Deploy

Deployed at calator-web.vercel.app. The application code needs no changes to run against Turso — packages/db picks its world from the environment, and with nothing set it opens the local file.

# 1. Create the database (Turso CLI, or the Vercel Marketplace integration)
turso db create calator
turso db show calator --url          # → libsql://calator-<org>.turso.io
turso db tokens create calator       # → the auth token

# 2. Migrate and seed it — explicitly, from a gitignored env file you export yourself
cat > .env.turso <<'EOF'
CALATOR_DB_URL=libsql://calator-<org>.turso.io
CALATOR_DB_AUTH_TOKEN=<token>
EOF
set -a; source .env.turso; set +a   # nothing loads it for you — see the note below
pnpm db:migrate:remote
pnpm db:seed:remote

# 3. Deploy
vercel --prod

Set these in the Vercel project (or let the Marketplace integration inject its own names, which are honoured as fallbacks):

Variable Notes
CALATOR_DB_URL Falls back to CALATOR_TURSO_DATABASE_URL; then to the local file
CALATOR_DB_AUTH_TOKEN Falls back to CALATOR_TURSO_AUTH_TOKEN
NEXT_PUBLIC_APP_URL The deployed origin — metadataBase for link previews and OG images

Two guardrails worth knowing about. db:reset deletes the database file only when the URL starts with file:; against a remote it degrades to migrate + seed, so there is no sequence of arguments that unlinks production.

And no script reads an env file — not the local ones, not the :remote ones. A .env or .env.turso sitting in the repo is inert until you export it yourself, so a file left behind after a deploy cannot redirect tomorrow's seed. What the :remote variants add is a refusal: --remote exits non-zero when the resolved URL is still file:, which catches the source you forgot before it seeds a throwaway file and reports success.

An exported variable is a different matter and deliberately still works, because that is the escape hatch above; what it cannot do is happen quietly. db:seed prints WARNING: seeding a REMOTE database: <url> before it writes, and pnpm showcase refuses outright.

The design system, on the deploy

Storybook ships with the app at calator-web.vercel.app/design-system — every component, both themes, no local checkout required. apps/web's build runs scripts/embed-storybook.mjs before next build: it builds packages/ui's Storybook if no build is present, then copies the result into apps/web/public/storybook/. The copy is gitignored — it is 9.7MB of fingerprinted chunks derived from a source that is itself generated, and committing it would mean regenerating and re-committing it on every push.

The order matters and is the one thing that is easy to get wrong: Next reads public/ while it builds, so a directory that appears afterwards is not in the output. The first attempt copied after the build and every asset 404'd.

/design-system is a real route rather than the raw static path because Next serves public/ verbatim but does no directory-index resolution — /storybook/index.html is a 200 and bare /storybook is a 404. The route owns the clean URL, keeps the file layout an internal detail, and gets a title and noindex on the way. It is not linked from anywhere in the app, by choice: it is a reviewer's surface, not a user's one. Unlisted, not secured — nothing there reads data or accepts input.


What I'd do next

The full list — Product, UX/UI, and CI/release — lives in docs/next-steps.md: everything I'd build if this weren't a demo, not summarized here so the two copies can't drift apart.


LLM usage

Built with Claude Code (Opus). The prompts are committed, unedited, at docs/prompts/, and the standing rules the agent works under are in AGENTS.md — that file is the interesting artifact, and it is law rather than advice.

Workflow: spec-first prompt → tiered execution (must-ship before nice-to-have) → parallel subagents scoped one-per-workspace so they cannot collide → Playwright MCP visual verification at 375×812 and 1440×900 in both themes → human review of every diff.

Guardrails: typed contracts end to end (Zod schemas shared by the API, the SDK and the forms), a deterministic seed, tests as acceptance criteria rather than an afterthought, a validation gate that blocks the end of any turn that left the tree broken, permission ask-gates on anything expensive to undo, and no secrets in prompts or commits.

Where it needed a human. The model is good at breadth and consistency and bad at knowing when it is wrong. Every defect that mattered in this build was caught by something external to the model's own judgement — the a11y suite failing on muting done with opacity instead of colour, a visual sweep finding a welcome gate that rendered no avatar at all, and the browser suite finding two bugs the unit tests were structurally incapable of seeing. The lesson is not "review the diffs" but "make the feedback loops real", and then believe them over the model.

About

Boutique hotels and unique stays — classic by day, neon by night.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages