---
title: "Setup"
description: "From a fresh clone to every app running locally."
url: https://pr-405-docs.preview-ritorno.findmalek.engineer/docs/setup
markdown: https://pr-405-docs.preview-ritorno.findmalek.engineer/docs/setup.md
---

# Setup

You need node 24, pnpm, bun, docker, the [Infisical cli](https://infisical.com/docs/cli/overview) and access to the tailnet.

```bash
pnpm install
infisical login   # once per machine, from the repo root
pnpm db:up
pnpm dev
```

No `.env` is needed: `pnpm dev` reads the Infisical `dev` environment, see [secrets](https://pr-405-docs.preview-ritorno.findmalek.engineer/docs/secrets.md#locally). Without Infisical it warns and reads the root `.env` instead (copy `.env.example`, set `BETTER_AUTH_SECRET`).

`pnpm db:up` starts a local postgres from `docker/docker-compose.yml`. The api applies migrations on start and, when `SEED=demo`, fills an empty database with sample data.

## Demo data

`pnpm db:seed`, the api with `SEED=demo` and the Playwright run all use the same deterministic seed (`packages/db/src/seed`, fixed random seeds, only dates move with today). It runs on an empty database only (no hotel and no note), so running it twice changes nothing. It is all fake and covers six months:

- four hotels with their own colors and logo: Dar Zitouna (Monastir guesthouse), Sunset Bay Resort (Hammamet), Villa Mimosa Spa (Djerba), Riad Dattier (Tozeur, pilot ending soon and low WhatsApp credit). Two more only the platform admin sees: one waiting for its owner, one suspended
- about 1400 guests in fr, ar and en with consents, an append-only `consent_events` log, visits (some returning), birthdays (a few today and this week) and QR spots (rooms, tables)
- offers (open, expired, paused, used up) with codes and redemptions, post-stay surveys with comments and feedback cases with notes
- campaigns (sent, scheduled, draft, cancelled), holiday choices, the message log in every status with previews of the last week's unsent messages, the prepaid balance ledger, notifications and the audit log
- a team per hotel (owner, manager, two staff) and a pending invitation

Logos are uploaded only when the `S3_*` keys are set, otherwise a hotel shows its initial.

Accounts are on `@demo.ritorno.test`: a super admin `admin@`, and per hotel `owner.<slug>@`, `manager.<slug>@`, `reception.<slug>@` and `service.<slug>@`, for example `owner.sunset-bay@demo.ritorno.test`. They share the password `DEMO_PASSWORD` (default `demo-ritorno-2026`), except the sales viewer below.

### Sales viewer

`sales@demo.ritorno.test` is the account to open [in a sales meeting](https://pr-405-docs.preview-ritorno.findmalek.engineer/docs/pitch.md#opening-the-demo-hotel). It sees Sunset Bay Resort like a manager and can change nothing, so a prospect holding the phone cannot break the demo:

- it has its own password, `DEMO_VIEWER_PASSWORD`. A deployed env without it has no sales viewer; locally it defaults to `demo-ritorno-2026`
- the api refuses it every signed-in procedure that is not declared `GET`, except the `POST`s that only read (QR codes, campaign reach, email preview, offer code lookup). A new read only `POST` goes in `DEMO_VIEWER_READS` (`packages/orpc/src/procedures.ts`)
- exports (guests and account data) are refused, so no copy of the list lands on that phone. A new export procedure is covered as long as its name starts with `export`
- auth refuses it every write except sign in, sign out and picking its hotel, so nobody can change the password or invite someone
- the dashboard shows a view only banner

Public guest pages (capture, survey, unsubscribe) need no account and still save what is typed. Nobody can sign up with a demo address, even one with a pending seeded invitation.

### Nothing can reach a person

Emails are on `demo.ritorno.test` (`.test` never resolves). Phone numbers come from `DEMO_PHONE_RANGES` in `packages/common/src/demo.ts`:

| Range | Used for | Why it is safe |
| --- | --- | --- |
| `+33 6 39 98 XX XX` | French, British and Italian guests | reserved by ARCEP for fiction |
| `+216 49 XXX XXX` | Tunisian guests and managers | no operator block in libphonenumber's allocation data |
| `+213 500 XXX XXX` | Algerian guests | same |
| `+49 1530 XXXXXXX` | German guests | same |

Only the first is an official reservation, check the other three again if an operator opens those blocks. On top of that the notifier never hands a demo address or number to a provider, even with `MESSAGING_LIVE=true`.

The seed refuses to run with `DEPLOY_ENV=production`, and with `DEPLOY_ENV` unset or `local` it refuses a database that is not on this machine (`localhost`, `127.0.0.1`, `::1` or the compose service `postgres`). `pnpm db:seed` fails there, the api logs a warning, skips the seed and starts. Staging (`DEPLOY_ENV=staging`) and previews (`pr-<N>`) seed their own databases.

Self-hosting with `docker-compose.yml` defaults to `DEPLOY_ENV=production`, so `SEED=demo` alone does nothing there. For a throwaway demo stack set `DEPLOY_ENV` to another name, such as `demo`, as well. That compose file does not pass `DEMO_PASSWORD` through, so the accounts get the public default: never expose such a stack with real data. To reseed staging see the [deploy runbook](https://pr-405-docs.preview-ritorno.findmalek.engineer/docs/deploy-runbook.md#reseed-staging).

A feature that adds tables adds its rows to a scenario file in `packages/db/src/seed`, its insert to `seedDemo` and a test.

## End-to-end tests

`pnpm test:e2e` (needs `pnpm db:up`) builds web and dashboard, starts the api on a fresh database with `SEED=demo` and runs Playwright from `apps/e2e`. Three projects: `desktop`, `iphone` (iPhone 14) and `android` (Pixel 7). Phone profiles run in chromium and only the `web` and `dashboard` specs, which check each language (en, fr, ar) for `lang`, `dir` (RTL in Arabic) and no sideways scroll. `fixtures.ts` has the shared helpers. `flows.spec.ts` (desktop) creates a hotel through the admin UI and runs it through invitation, branding, offers and capture, unsubscribe, survey alert, CSV import, export and delete; isolation, login and the QR page have their own specs. Specs never sleep: wait on what the page or the database shows. Set `E2E_DATABASE_URL` when Postgres is not on port 5432. Sign in as a demo account with the credentials above. The api allows 10 sign-in posts a minute per ip, so keep UI sign-ins few.

| App | Url |
| --- | --- |
| web | http://localhost:3000 |
| api | http://localhost:3001 |
| dashboard | http://localhost:3002 |
| docs | http://localhost:3003 |

Sign in to the dashboard with `ADMIN_EMAIL` and `ADMIN_PASSWORD` of the Infisical `dev` environment (or your `.env`). The admin is created or reset on every api start.

## Working on one app

```bash
pnpm dev:web        # web and api
pnpm dev:dashboard  # dashboard and api
```

## Before you push

```bash
pnpm lint
pnpm check-types
pnpm test
pnpm build
```
