docs: add /docs living documentation per AGENT.MD

- docs/README.md: navigation hub
- docs/architecture.md: system overview, tech stack, data flows, ports
- docs/backend/: supabase-core, schema, rpcs, rls, seed, docker
- docs/frontend/: app-structure, screens, api-client
- docs/next-steps.md: Phase 2/3/4 plan + open decisions
- Fix README demo-account emails to match the actual seed
This commit is contained in:
Lago committed 2026-08-22 17:10:50 +02:00
1 parent 37684ba116
commit 4abdc7691b
16 files changed
+1494 -7

No files matched your search

+152
View File
@@ -0,0 +1,152 @@
# Database Schema
All tables live in the `public` schema. Source of truth:
[`supabase/migrations/20260822000000_init.sql`](../../supabase/migrations/20260822000000_init.sql).
There are **9 tables**: people, schedule, and the event's activity.
```mermaid
erDiagram
profiles ||--o{ preferences : "picks"
profiles ||--o{ connections : "from/to"
profiles ||--o{ checkins : "checked in"
profiles ||--o{ feedback : "rates"
profiles ||--o{ leaderboard : "mirrored"
profiles ||--o{ points_log : "audited"
slots ||--o{ sessions : "contains"
sessions ||--o{ preferences : "picked"
sessions ||--o{ checkins : "checked into"
sessions ||--o{ feedback : "rated"
```
## `profiles` — people (source of truth)
One row per attendee. `id` **is** the Supabase Auth user id.
| Column | Type | Notes |
|---|---|---|
| `id` | `uuid` PK | = `auth.users(id)`; `on delete cascade` |
| `email` | `text` **unique** | The ticket-purchase email (login identifier) |
| `full_name` | `text` | |
| `company` | `text` | nullable |
| `role` | `text` | `attendee` \| `staff` \| `admin` (default `attendee`) |
| `qr_token` | `text` **unique** | The lanyard token; **doubles as the Auth password** |
| `points` | `integer` | `>= 0`, default 0 |
| `created_at` | `timestamptz` | |
## `slots` — schedule blocks
| Column | Type | Notes |
|---|---|---|
| `id` | `integer` PK | 1–6 |
| `name` | `text` | e.g. "Slot 1" |
| `slot_date` | `date` | `2026-10-23` |
| `start_time` | `time` | |
| `end_time` | `time` | |
## `sessions` — one per (slot, room)
| Column | Type | Notes |
|---|---|---|
| `id` | `uuid` PK | `gen_random_uuid()` |
| `title` | `text` | |
| `description` | `text` | nullable |
| `slot_id` | `integer` FK → `slots` | `on delete cascade` |
| `room` | `text` | "Main Stage" / "Room A" / "Room B" |
| `capacity` | `integer` | nullable (not enforced in v1) |
| `speakers` | `text` | |
| `created_at` | `timestamptz` | |
Index: `sessions_slot_id_idx (slot_id)`.
## `preferences` — one pick per slot
| Column | Type | Notes |
|---|---|---|
| `id` | `uuid` PK | |
| `profile_id` | `uuid` FK → `profiles` | |
| `session_id` | `uuid` FK → `sessions` | |
| `slot_id` | `integer` | denormalized for easy "one per slot" |
| `created_at` | `timestamptz` | |
**Constraint:** `unique (profile_id, slot_id)` — an attendee can pick at most one
session per slot. Enforced in the DB *and* by the `set_preference` RPC (which
deletes the old pick for the slot before inserting).
## `connections` — the networking relationship
| Column | Type | Notes |
|---|---|---|
| `id` | `uuid` PK | |
| `from_id` | `uuid` FK → `profiles` | the requester |
| `to_id` | `uuid` FK → `profiles` | the recipient |
| `status` | `text` | `pending` \| `accepted` \| `rejected` (default `pending`) |
| `created_at` | `timestamptz` | |
| `resolved_at` | `timestamptz` | set when accepted/rejected |
**Constraint:** unique per **unordered pair** via
`unique index connections_pair_uniq on (least(from_id, to_id), greatest(from_id, to_id))`.
So Ana→Bruno and Bruno→Ana are the *same* connection — a pair can only ever have
one.
## `checkins` — staff check-in of an attendee
| Column | Type | Notes |
|---|---|---|
| `id` | `uuid` PK | |
| `profile_id` | `uuid` FK → `profiles` | the attendee being checked in |
| `session_id` | `uuid` FK → `sessions` | |
| `staff_id` | `uuid` FK → `profiles` | the staff member who scanned |
| `created_at` | `timestamptz` | |
**Constraint:** `unique (profile_id, session_id)` — one check-in per attendee per
session (prevents double points).
## `feedback` — post-session rating
| Column | Type | Notes |
|---|---|---|
| `id` | `uuid` PK | |
| `profile_id` | `uuid` FK → `profiles` | |
| `session_id` | `uuid` FK → `sessions` | |
| `rating` | `integer` | `1–5` |
| `comment` | `text` | nullable (bonus points if present) |
| `created_at` | `timestamptz` | |
**Constraint:** `unique (profile_id, session_id)` — one feedback per attendee per
session.
## `leaderboard` — Realtime mirror
A public, Realtime-friendly mirror of points. **Not** the source of truth — it is
kept in sync transactionally by the RPCs (see [rpcs.md](./rpcs.md#_sync_leaderboard)).
| Column | Type | Notes |
|---|---|---|
| `profile_id` | `uuid` PK FK → `profiles` | |
| `full_name` | `text` | denormalized for display |
| `company` | `text` | denormalized |
| `points` | `integer` | |
| `updated_at` | `timestamptz` | |
The app subscribes to `postgres_changes` on this table to update the leaderboard
live. See [../frontend/screens.md#leaderboard](../frontend/screens.md#leaderboard).
## `points_log` — audit trail
Powers the per-category points breakdown on the Profile screen.
| Column | Type | Notes |
|---|---|---|
| `id` | `uuid` PK | |
| `profile_id` | `uuid` FK → `profiles` | |
| `delta` | `integer` | points added (can be negative for admin adjustments) |
| `category` | `text` | `checkin` \| `connection` \| `feedback` \| `admin` |
| `created_at` | `timestamptz` | |
Index: `points_log_profile_id_idx (profile_id)`.
## Other indexes
- `profiles_qr_token_idx (qr_token)` — fast lanyard lookups.
- `checkins_session_id_idx (session_id)`.