# Step 1 · Set up the patient register

Canonical page: https://docs.ovok.com/guides/staffed-kiosk/set-up-the-patient-register

A `patients` table in your own Supabase, which only the kiosk's Edge Function can read. Supabase is open source, so you run the same stack on your laptop now and on your own servers later.

## Before you begin [#before-you-begin]

- Docker running on your machine.
- Node.js 24 or newer.

## Start Supabase [Terminal] [#start-supabase-terminal]

Clone the example and start Supabase from it. The Supabase CLI is a dev dependency, so `npm ci` installs it.

~~~bash
git clone https://github.com/Ovok-Dev/staffed-kiosk-example.git
cd staffed-kiosk-example
npm ci
npm run supabase -- start
~~~

`supabase start` runs Postgres, the API gateway and the Edge Functions runtime in Docker, then applies the migrations in `supabase/migrations`. It prints the API URL, `http://127.0.0.1:54321` by default. The example's `supabase/config.toml` turns off Realtime, Storage and Analytics, which the kiosk doesn't use.

## Create the patients table [Server-side] [#create-the-patients-table-server-side]

The migration creates the register:

~~~sql title="supabase/migrations/20261112120000_patients.sql"
create table public.patients (
  id uuid primary key default gen_random_uuid(),
  card_code text not null unique,
  given_name text not null,
  family_name text not null,
  birth_date date not null,
  ovok_patient_id text unique,
  created_at timestamptz not null default now(),
  constraint card_code_format check (card_code ~ '^[A-Za-z0-9-]{4,64}$'),
  constraint given_name_length check (char_length(given_name) between 1 and 100),
  constraint family_name_length check (char_length(family_name) between 1 and 100)
);

alter table public.patients enable row level security;
revoke all on public.patients from anon, authenticated;
~~~

- `id` is the pseudonym. It is the only value from this table that reaches Ovok.
- `card_code` is unique, so one card always means one patient.
- Row level security is on with no policies, and the `anon` and `authenticated` roles have no grants. Only the service role, which the Edge Function uses, can read or write.

## Verify your integration [#verify-your-integration]

Read the table with the anon key that `supabase start` printed. The register must refuse it:

~~~bash
curl "http://127.0.0.1:54321/rest/v1/patients?select=*" \
  -H "apikey: {{SUPABASE_ANON_KEY}}"
~~~

You should get an error that permission is denied for table `patients`, never a list.

## Troubleshooting [#troubleshooting]

- **`supabase start` fails:** check that Docker is running and that ports 54321 and 54322 are free.
- **The request returns `[]` instead of an error:** the grants were not revoked. Run `npm run supabase -- db reset` to apply the migration again.

## Next step [#next-step]

Continue to [step 2: configure the Ovok project](/guides/staffed-kiosk/configure-the-ovok-project).
