Redesign Phases 3-6: multi-event model, APPE Admin, Convivo App behaviors, APPE branding

- Phase 3: new migration 20260824000000_redesign.sql (contacts/events/registrations/sponsors, slot types, session speakers + feedback/material), seed rewrite
- Phase 4: APPE Admin rebrand + Contacts/Registrations/Sponsors/Schedule/Activity/Events views
- Phase 5: Convivo App (24h login, 5s polling, QR type badge, red dot, speaker material)
- Phase 6: APPE favicon + PWA icons for both apps
- Docs: schema/rpcs/rls/seed/screens/api-client/admin-app/architecture/next-steps/README/roadmap updated

Co-authored-by: Stephan Charles <[email protected]>
Co-authored-by: Amelia Hernandez <[email protected]>
Co-authored-by: Markus Franz <[email protected]>
Co-authored-by: Sabrina Hota <[email protected]>
Co-authored-by: Nilüfer Doğan <[email protected]>
This commit is contained in:
committed 2026-08-23 02:53:16 +02:00
1 parent 2f53d47578
commit 7605c9bbf4
64 files changed
+4593 -1371

No files matched your search

+7 -5
View File
@@ -4,9 +4,11 @@ Living documentation for **Convivo** — a conference networking app that turns
conference into a game. This folder is the single source of truth for *how the
system works*; the root [`README.md`](../README.md) is the quick-start.
> **Status:** Phases 0–2 are complete and verified. The project is now in the
> **Redesign** (Phases 3–6) — a new multi-event data model + APPE Admin rebrand.
> See the root [`roadmap.md`](../roadmap.md) and [next-steps.md](./next-steps.md).
> **Status:** Phases 0–6 are complete and verified. The **Redesign** (Phases
> 3–6) is done: the new multi-event data model is live, the admin app is
> rebranded to **APPE Admin**, the Convivo App has all the new behaviors, and both
> apps carry the APPE branding. See the root
> [`roadmap.md`](../roadmap.md) and [next-steps.md](./next-steps.md).
## Where things live
@@ -46,8 +48,8 @@ system works*; the root [`README.md`](../README.md) is the quick-start.
RPC reference instead of re-describing the RPCs.)
- **Code is the source of truth.** If a doc and the code disagree, the code wins —
fix the doc. Key files:
- Schema + RPCs + RLS: [`supabase/migrations/20260822000000_init.sql`](../supabase/migrations/20260822000000_init.sql)
- Admin app migration (admin read RLS + `reset_qr_token`): [`supabase/migrations/20260823000000_admin_app.sql`](../supabase/migrations/20260823000000_admin_app.sql)
- Schema + RPCs + RLS (the Redesign, **current**): [`supabase/migrations/20260824000000_redesign.sql`](../supabase/migrations/20260824000000_redesign.sql)
- Earlier migrations (applied, then replaced by the Redesign): [`20260822000000_init.sql`](../supabase/migrations/20260822000000_init.sql), [`20260823000000_admin_app.sql`](../supabase/migrations/20260823000000_admin_app.sql)
- Seed: [`supabase/seed.sql`](../supabase/seed.sql)
- Attendee app source: [`apps/convivo/src/`](../apps/convivo/src/)
- Admin app source: [`apps/admin/src/`](../apps/admin/src/)
+23 -17
View File
@@ -18,7 +18,7 @@ make connections, get checked in by staff, and rate sessions. Every action earns
flowchart LR
subgraph Browser["Browser"]
A["Convivo PWA<br/>React 18 + Vite 5 + TS<br/>mobile-first, installable"]
AD["Convivo Admin<br/>React 18 + Vite 5 + TS<br/>desktop-first console"]
AD["APPE Admin<br/>React 18 + Vite 5 + TS<br/>desktop-first console"]
end
subgraph Docker["Docker (local)"]
@@ -64,12 +64,14 @@ talks to Supabase through **same-origin paths**, so there is no CORS to manage.
### Backend — the Supabase core
Everything server-side lives in Postgres. See [backend/README.md](./backend/README.md):
- **Schema** — 9 tables (people, schedule, and the event's activity). → [backend/schema.md](./backend/schema.md)
- **Schema** — 13 tables (people, the event, participation, schedule, and the
event's activity). → [backend/schema.md](./backend/schema.md)
- **Business logic** — transactional `security definer` RPCs that award points and
keep the leaderboard consistent. → [backend/rpcs.md](./backend/rpcs.md)
- **Security** — Row Level Security on every table; the app only ever uses the
**anon key + the user's session JWT**. → [backend/rls.md](./backend/rls.md)
- **Data** — seed with 6 slots, 18 sessions, 13 demo users. → [backend/seed.md](./backend/seed.md)
- **Data** — seed with 1 event, 6 slots, 18 sessions, 14 contacts, 13
registrations, 3 sponsors. → [backend/seed.md](./backend/seed.md)
### Frontend — the attendee PWA
A single-page React app with a tab shell and a few full-screen takeovers. See
@@ -78,15 +80,17 @@ A single-page React app with a tab shell and a few full-screen takeovers. See
- **Screens** — Login, Home, Agenda, Scan/Check-in, Connections, Feedback, Leaderboard, Profile. → [frontend/screens.md](./frontend/screens.md)
- **API client** — a thin typed wrapper over `supabase.rpc` / `supabase.from`. → [frontend/api-client.md](./frontend/api-client.md)
### Frontend — the admin console
A separate desktop-first React app for organizers, guarded to the **admin** role.
See [frontend/admin-app.md](./frontend/admin-app.md):
- **Views** — Dashboard (live stats), Attendees (edit / reset QR / adjust
points), Schedule (manage slots + sessions), Activity (check-ins /
connections / feedback).
### Frontend — the admin console (APPE Admin)
A separate desktop-first React app for organizers, guarded to the **`is_admin`**
flag. See [frontend/admin-app.md](./frontend/admin-app.md):
- **Views** — Dashboard (active event + aggregates), Contacts, Registrations,
Sponsors, Schedule (slots/sessions/speakers/material/AI-evaluate), Activity,
Events.
- **Auth guard** — same QR + email login, but non-admin sessions are rejected.
- **New RPC** — `reset_qr_token` regenerates an attendee's lanyard token and
syncs the Auth password (see [backend/rpcs.md](./backend/rpcs.md)).
- **Key RPCs** — `reset_qr_token` (regenerate a lanyard token + sync the Auth
password), `adjust_points`, `upsert_contact`, `create_registration`,
`set_registration_type`, `evaluate_session_feedback` (AI stub), and
`set_session_material` (see [backend/rpcs.md](./backend/rpcs.md)).
## 5. How a request flows (example: staff check-in)
@@ -102,7 +106,7 @@ sequenceDiagram
N->>K: proxy (same-origin)
K->>R: route /rest
R->>DB: execute checkin_attendee() as `authenticated`
Note over DB: security definer → bypasses RLS<br/>1. insert checkin (ON CONFLICT do nothing)<br/>2. _award_points(+10) → profiles.points + points_log<br/>3. _sync_leaderboard()
Note over DB: security definer → bypasses RLS<br/>1. insert checkin (ON CONFLICT do nothing)<br/>2. _award_points(+10) → registrations.points + points_log<br/>3. _sync_leaderboard()
DB-->>R: {checkin_id, attendee_name, points, already}
R-->>K: JSON
K-->>N: JSON
@@ -119,8 +123,9 @@ the work atomically, and the `leaderboard` table change fans out over Realtime.
Login is a standard `signInWithPassword({ email, password: qrToken })`.
- `enable_confirmations = false`, so **no email is sent** — the email is only a
"confirm it's you" check against the ticket purchase.
- After login, the app holds a short-lived **session JWT** (in `localStorage`).
Every request sends the **anon key** (public) + the **session JWT** (identity).
- After login, the app holds a **session JWT** (in `localStorage`) that lasts
**24 hours** (`jwt_expiry = 86400`). Every request sends the **anon key**
(public) + the **session JWT** (identity).
- The **service-role key is never in the app** — it bypasses RLS and stays
server-side. See [backend/rls.md](./backend/rls.md) for what each role can do.
@@ -167,9 +172,10 @@ Convivo/
├─ supabase/
│ ├─ config.toml # Local stack config (ports, auth, RLS defaults)
│ ├─ migrations/
│ │ ├─ 20260822000000_init.sql # schema, RLS, points RPCs
│ │ └─ 20260823000000_admin_app.sql # admin read RLS + reset_qr_token RPC
│ └─ seed.sql # Slots, sessions, 13 demo users, Ana's demo state
│ │ ├─ 20260822000000_init.sql # original schema (replaced by the Redesign)
│ │ ├─ 20260823000000_admin_app.sql # admin read RLS + reset_qr_token (superseded)
│ │ └─ 20260824000000_redesign.sql # ← current: multi-event model, RPCs, RLS, materials
│ └─ seed.sql # 1 event, 6 slots, 18 sessions, 14 contacts, demo state
├─ docker-compose.yml # Runs both app sidecars on the Supabase network
├─ docs/ # ← this documentation
└─ mockup/index.html # Original interactive mockup (design reference)
+9 -6
View File
@@ -7,23 +7,24 @@ Postgres. This folder documents that core.
| File | What it covers |
|---|---|
| [supabase-core.md](./supabase-core.md) | The local stack: containers, ports, how to start/reset, config |
| [schema.md](./schema.md) | All 9 tables, columns, constraints, indexes |
| [schema.md](./schema.md) | All 13 tables, columns, constraints, indexes |
| [rpcs.md](./rpcs.md) | The transactional points RPCs (the business logic) |
| [rls.md](./rls.md) | Row Level Security policies + which key the app uses |
| [seed.md](./seed.md) | Seed data + the 13 demo accounts |
| [seed.md](./seed.md) | Seed data + the demo accounts |
| [docker.md](./docker.md) | Docker: the app image + root compose (how the core + app run together) |
## The big picture
```
Postgres 17 ── schema (9 tables)
Postgres 17 ── schema (13 tables, multi-event model)
── RLS (who can read/write what)
── RPCs (security definer, transactional points logic)
── seed (demo data)
```
- **Data + logic live in the database.** The app never computes points or writes
to `profiles.points` directly — it calls RPCs, and Postgres enforces the rules.
to `registrations.points` directly — it calls RPCs, and Postgres enforces the
rules.
- **RLS is the security boundary.** The app uses the **anon key + the user's
session JWT**; RLS decides what that user may see and do. The service-role key
is never shipped to the app. See [rls.md](./rls.md).
@@ -33,7 +34,9 @@ Postgres 17 ── schema (9 tables)
## Source of truth
- Schema + RPCs + RLS: [`supabase/migrations/20260822000000_init.sql`](../../supabase/migrations/20260822000000_init.sql)
- Admin app (Phase 2): admin read RLS + `reset_qr_token` RPC — [`supabase/migrations/20260823000000_admin_app.sql`](../../supabase/migrations/20260823000000_admin_app.sql)
- Schema + RPCs + RLS (the Redesign, **current**): [`supabase/migrations/20260824000000_redesign.sql`](../../supabase/migrations/20260824000000_redesign.sql)
- Earlier migrations (still applied, then replaced by the Redesign):
[`20260822000000_init.sql`](../../supabase/migrations/20260822000000_init.sql) and
[`20260823000000_admin_app.sql`](../../supabase/migrations/20260823000000_admin_app.sql)
- Seed: [`supabase/seed.sql`](../../supabase/seed.sql)
- Stack config: [`supabase/config.toml`](../../supabase/config.toml)
+1 -1
View File
@@ -56,7 +56,7 @@ same-origin paths to the core:
| `/auth/` | `__SUPABASE_PROXY_TARGET__` | GoTrue |
| `/rest/` | `__SUPABASE_PROXY_TARGET__` | PostgREST (tables + RPCs) |
| `/realtime/` | `__SUPABASE_PROXY_TARGET__` | WebSocket — `Upgrade`/`Connection` headers + long timeouts |
| `/storage/` | `__SUPABASE_PROXY_TARGET__` | Storage (unused in v1) |
| `/storage/` | `__SUPABASE_PROXY_TARGET__` | Storage — the `materials` bucket (session material) |
`__SUPABASE_PROXY_TARGET__` is replaced at start with the value of the
`SUPABASE_PROXY_TARGET` env var (default `supabase_kong_Convivo:8000`).
+103 -61
View File
@@ -1,12 +1,12 @@
# Row Level Security (RLS)
RLS is the security boundary. It is **enabled on all 9 tables**, and every policy
is scoped to the `authenticated` role. The `anon` role has `GRANT select` at the
Postgres level, but RLS blocks it from reading anything — so an unauthenticated
request sees no rows.
RLS is the security boundary. It is **enabled on all 13 tables**, and every
policy is scoped to the `authenticated` role. The `anon` role has `GRANT select`
at the Postgres level, but RLS blocks it from reading anything — so an
unauthenticated request sees no rows.
Source of truth:
[`supabase/migrations/20260822000000_init.sql`](../../supabase/migrations/20260822000000_init.sql)
[`supabase/migrations/20260824000000_redesign.sql`](../../supabase/migrations/20260824000000_redesign.sql)
(RLS section).
## Which key does the app use?
@@ -26,91 +26,132 @@ Source of truth:
## Role helpers
Two `security definer` functions drive role checks (see [rpcs.md](./rpcs.md#role-helper-functions)):
- `is_admin()` — current user's profile has `role = 'admin'`
- `is_staff_or_admin()` — current user's profile has `role in ('staff','admin')`
`security definer` functions drive role checks (see
[rpcs.md](./rpcs.md#role-helper-functions)):
- `current_email()` — `auth.jwt() ->> 'email'` (the identity; `contacts` is keyed
by email)
- `is_admin()` — current contact has `is_admin = true`
- `is_staff_or_admin()` — = `is_admin()` (staff is merged into admin)
- `is_speaker_or_admin()` — admin, or a speaker of an active-event session, or a
`speaker`-type registration
## Policies by table
| Table | SELECT | INSERT | UPDATE | DELETE |
|---|---|---|---|---|
| `profiles` | own **or** admin | — | admin only | admin only |
| `contacts` | own **or** admin | — | admin only | admin only |
| `events` | all authenticated | admin only | admin only | admin only |
| `registrations` | own **or** admin | admin only | admin only | admin only |
| `sponsors` | admin **or** `paid` | admin only | admin only | admin only |
| `slots` | all authenticated | admin only | admin only | admin only |
| `sessions` | all authenticated | admin only | admin only | admin only |
| `preferences` | own **or** admin | — | — | — |
| `session_speakers` | all authenticated | admin only | admin only | admin only |
| `preferences` | own | — | — | — |
| `connections` | rows you're in **or** admin | — | — | — |
| `checkins` | own **or** staff/admin | — | — | — |
| `checkins` | own **or** admin | — | — | — |
| `feedback` | own **or** admin | — | — | — |
| `leaderboard` | all authenticated | — | — | — |
| `points_log` | own **or** admin | — | — | — |
> **Phase 2 addition** ([`20260823000000_admin_app.sql`](../../supabase/migrations/20260823000000_admin_app.sql)):
> admin-only `select` policies were added to `preferences`, `connections`, and
> `feedback` so the Admin console can read the full activity. The per-user
> policies above are unchanged — these are additive `OR is_admin()` reads.
**"—" (no policy)** means normal users have **no direct write access** — those
tables are written only by the `security definer` RPCs, which bypass RLS. This is
deliberate: a client cannot `UPDATE profiles SET points = 9999` or insert its own
check-in. See [rpcs.md](./rpcs.md).
deliberate: a client cannot `UPDATE registrations SET points = 9999` or insert its
own check-in. See [rpcs.md](./rpcs.md).
> **Admin reads the full activity.** The `connections`, `checkins`, and `feedback`
> select policies include `or public.is_admin()`, so the APPE Admin console's
> Activity view sees every row (an admin is "involved" in none of them, so a
> pure "involved/own" policy would show 0).
### The exact policies
```sql
-- profiles: read own or admin; write admin only
create policy "profiles_select_own_or_admin" on public.profiles for select to authenticated
using (id = auth.uid() or public.is_admin());
create policy "profiles_update_admin" on public.profiles for update to authenticated
-- contacts: read own or admin; write admin only
create policy "contacts_select_own_or_admin" on public.contacts for select to authenticated
using (email = public.current_email() or public.is_admin());
create policy "contacts_admin_update" on public.contacts for update to authenticated
using (public.is_admin()) with check (public.is_admin());
create policy "profiles_delete_admin" on public.profiles for delete to authenticated
create policy "contacts_admin_delete" on public.contacts for delete to authenticated
using (public.is_admin());
-- slots / sessions: readable by any authenticated user (public agenda); admin writes
-- events: readable by all authenticated; writable by admin
create policy "events_select_all" on public.events for select to authenticated using (true);
create policy "events_admin_insert" on public.events for insert to authenticated with check (public.is_admin());
create policy "events_admin_update" on public.events for update to authenticated
using (public.is_admin()) with check (public.is_admin());
create policy "events_admin_delete" on public.events for delete to authenticated using (public.is_admin());
-- registrations: own or admin
create policy "registrations_select_own_or_admin" on public.registrations for select to authenticated
using (contact_email = public.current_email() or public.is_admin());
-- (admin-only insert/update/delete)
-- sponsors: admin sees all; non-admin sees only paid sponsors
create policy "sponsors_select" on public.sponsors for select to authenticated
using (public.is_admin() or paid);
-- (admin-only insert/update/delete)
-- slots / sessions / session_speakers: readable by any authenticated user; admin writes
create policy "slots_select_all" on public.slots for select to authenticated using (true);
create policy "slots_admin_insert" on public.slots for insert to authenticated with check (public.is_admin());
create policy "slots_admin_update" on public.slots for update to authenticated using (public.is_admin()) with check (public.is_admin());
create policy "slots_admin_delete" on public.slots for delete to authenticated using (public.is_admin());
-- (sessions: identical four policies)
create policy "sessions_select_all" on public.sessions for select to authenticated using (true);
create policy "session_speakers_select_all" on public.session_speakers for select to authenticated using (true);
-- (each has admin-only insert/update/delete)
-- preferences: read own
create policy "prefs_select_own" on public.preferences for select to authenticated
using (profile_id = auth.uid());
using (contact_email = public.current_email());
-- connections: read rows you're involved in
create policy "conn_select_involved" on public.connections for select to authenticated
using (from_id = auth.uid() or to_id = auth.uid());
-- connections: read rows you're part of (or all if admin)
create policy "conn_select_involved_or_admin" on public.connections for select to authenticated
using (from_email = public.current_email() or to_email = public.current_email() or public.is_admin());
-- checkins: read own or staff/admin
create policy "checkins_select_own_or_staff" on public.checkins for select to authenticated
using (profile_id = auth.uid() or public.is_staff_or_admin());
-- checkins: read own, or all if admin
create policy "checkins_select_own_or_admin" on public.checkins for select to authenticated
using (contact_email = public.current_email() or public.is_admin());
-- feedback: read own
create policy "feedback_select_own" on public.feedback for select to authenticated
using (profile_id = auth.uid());
-- feedback: read own, or all if admin
create policy "feedback_select_own_or_admin" on public.feedback for select to authenticated
using (contact_email = public.current_email() or public.is_admin());
-- leaderboard: readable by any authenticated user
-- leaderboard: public to all authenticated (Realtime source)
create policy "leaderboard_select_all" on public.leaderboard for select to authenticated using (true);
-- points_log: read own or admin
create policy "points_log_select_own_or_admin" on public.points_log for select to authenticated
using (profile_id = auth.uid() or public.is_admin());
-- Phase 2 (20260823000000_admin_app.sql): additive admin-only reads for the
-- Admin console. These OR with the per-user policies above.
create policy "prefs_select_admin" on public.preferences for select to authenticated using (public.is_admin());
create policy "conn_select_admin" on public.connections for select to authenticated using (public.is_admin());
create policy "feedback_select_admin" on public.feedback for select to authenticated using (public.is_admin());
using (contact_email = public.current_email() or public.is_admin());
```
## Storage — `materials` bucket
The `materials` bucket (public read) stores session material. Policies on
`storage.objects`:
```sql
create policy "materials_read" on storage.objects for select to authenticated
using (bucket_id = 'materials');
create policy "materials_write" on storage.objects for insert to authenticated
with check (bucket_id = 'materials' and public.is_speaker_or_admin());
create policy "materials_update" on storage.objects for update to authenticated
using (bucket_id = 'materials' and public.is_speaker_or_admin());
create policy "materials_delete" on storage.objects for delete to authenticated
using (bucket_id = 'materials' and public.is_speaker_or_admin());
```
Speakers + admins can write; any authenticated attendee can read (download).
Because the `sessions` table is admin-write only, a speaker attaches their
uploaded file via the `set_session_material` RPC (see
[rpcs.md](./rpcs.md#set_session_materialp_session_id-p_material_path--sessions)).
## GRANTs
The new Supabase CLI does **not** auto-expose new tables to the Data API roles, so
the migration grants explicitly (RLS still governs what each role can actually see):
the migration grants explicitly (RLS still governs what each role can actually
see):
```sql
grant usage on schema public to anon, authenticated, service_role;
grant select on <all 9 tables> to anon, authenticated, service_role;
grant insert, update, delete on <all 9 tables> to authenticated, service_role;
grant select on <all 13 tables> to anon, authenticated, service_role;
grant insert, update, delete on <all 13 tables> to authenticated, service_role;
grant execute on function <all public RPCs + helpers> to authenticated;
```
@@ -119,20 +160,21 @@ full DML at the Postgres level, but **RLS narrows it** to the policies above.
## Net effect by role
- **Attendee** — sees their own profile/prefs/connections/feedback, the full
agenda, and the leaderboard; can only act through the RPCs (which re-check role
internally, e.g. only staff can call `checkin_attendee`).
- **Staff** — everything an attendee can do, plus can read all `checkins` and call
the check-in RPC.
- **Admin** — full read on everything (including all `preferences`,
`connections`, and `feedback`), and the only role with **direct** write access
to `profiles` / `slots` / `sessions`. This is exactly what the Admin console
(Phase 2, [`../frontend/admin-app.md`](../frontend/admin-app.md)) uses.
- **Attendee** — sees their own contact/registration/prefs/connections/feedback,
the full agenda, the public contact directory, and the leaderboard; can only act
through the RPCs (which re-check role internally, e.g. only staff can call
`checkin_attendee`).
- **Staff (= admin)** — everything an attendee can do, plus can read all
`checkins` / `connections` / `feedback` and call the check-in RPC.
- **Admin** — full read on everything, and the only role with **direct** write
access to `contacts` / `events` / `registrations` / `sponsors` / `slots` /
`sessions` / `session_speakers`. This is exactly what the APPE Admin console
([../frontend/admin-app.md](../frontend/admin-app.md)) uses.
## Things to revisit later
- `slots` / `sessions` are readable by *any* authenticated user (fine — it's a
public agenda). If you ever want the agenda hidden until the event, that's a
one-line policy change.
- `slots` / `sessions` / `session_speakers` are readable by *any* authenticated
user (fine — it's a public agenda). If you ever want the agenda hidden until the
event, that's a one-line policy change.
- `leaderboard` exposes every attendee's name + points to any authenticated user.
That's the intended product behavior (a public leaderboard).
+82 -44
View File
@@ -1,12 +1,13 @@
# Points RPCs (Business Logic)
All mutations go through **Postgres RPCs** (`security definer`, transactional).
The app never writes to `profiles.points`, `connections`, `checkins`, `feedback`,
or `leaderboard` directly — it calls these functions. This is what makes the
points system race-free and prevents a client from, e.g., setting its own points.
The app never writes to `registrations.points`, `connections`, `checkins`,
`feedback`, or `leaderboard` directly — it calls these functions. This is what
makes the points system race-free and prevents a client from, e.g., setting its
own points.
Source of truth:
[`supabase/migrations/20260822000000_init.sql`](../../supabase/migrations/20260822000000_init.sql).
[`supabase/migrations/20260824000000_redesign.sql`](../../supabase/migrations/20260824000000_redesign.sql).
## Why RPCs?
@@ -17,6 +18,8 @@ Source of truth:
re-sync the leaderboard* in **one transaction**. Either all happen or none do.
- **Idempotent where it matters** → re-check-in and re-feedback are detected and
never double-award.
- **Event-scoped** → every RPC resolves the **active event** first and scopes all
reads/writes to it.
## Points rules
@@ -30,27 +33,37 @@ Source of truth:
## Internal helpers
### `_award_points(p_profile_id, p_delta, p_category)`
### `_award_points(p_event_id, p_contact_email, p_delta, p_category)`
The single place points change. In one transaction it:
1. `update profiles set points = greatest(0, points + p_delta)` (floored at 0),
2. `insert into points_log (profile_id, delta, category)`,
3. calls `_sync_leaderboard(p_profile_id)`.
1. `update registrations set points = greatest(0, points + p_delta)` (floored at
0) for the (event, contact),
2. `insert into points_log (event_id, contact_email, delta, category)`,
3. calls `_sync_leaderboard(p_event_id, p_contact_email)`.
### `_sync_leaderboard(p_profile_id)`
Upserts the `leaderboard` row for that profile from `profiles`
(`on conflict (profile_id) do update ...`). This is what makes the leaderboard a
consistent, Realtime-friendly mirror.
### `_sync_leaderboard(p_event_id, p_contact_email)`
Upserts the `leaderboard` row for that (event, contact) from `registrations` +
`contacts` (`on conflict (event_id, contact_email) do update ...`). This is what
makes the leaderboard a consistent, Realtime-friendly mirror.
### `_recalc_event_aggregates(p_event_id)`
Recomputes the `events` aggregate columns (`num_sessions`, `num_speakers`,
`num_registrations`, `num_checked_in_registrations`, `avg_feedback`). Called by
triggers and the feedback RPC.
## Public read functions
| Function | Returns | Used for |
|---|---|---|
| `get_public_profiles()` | `id, full_name, company, role, points` (ordered by points) | Leaderboard initial load, id→name lookups |
| `lanyard_lookup(p_qr_token)` | `id, full_name, company, role` | Resolve a scanned QR (pre-login + connect) |
| `get_agenda()` | slots with their sessions (flat rows) | Agenda + Home |
| `get_leaderboard()` | `event_id, contact_email, full_name, points` (active event, ordered by points) | Leaderboard initial load + realtime re-fetch |
| `lanyard_lookup(p_qr_token)` | `email, full_name, linkedin_url` (null unless `show_linkedin`), `show_email`, `registration_type` | Resolve a scanned QR (pre-login + connect) |
| `get_public_contacts()` | `email, full_name, linkedin_url`, `show_email`, `registration_type` (active-event registrants) | Connections name/type lookups |
| `get_agenda()` | flat rows: slot fields + session fields + `speakers` (string_agg) | Agenda + Home |
| `get_active_event()` | the active `events` row (or none) | event name/dates/location |
All three are `security definer` and expose **only public columns** (no email, no
`qr_token`).
All are `security definer` and expose **only public columns** (email is included
because `contacts` is keyed by email and is the identity; `qr_token` is never
exposed). `lanyard_lookup` / `get_public_contacts` respect the contact's
`show_email` / `show_linkedin` visibility toggles.
## Mutation RPCs
@@ -63,28 +76,29 @@ Enforces "one pick per slot".
Removes the caller's pick for a slot.
### `create_connection_request(p_target_qr)` → `connections`
Creates a **pending** connection to the attendee whose QR was scanned.
Creates a **pending** connection to the contact whose QR was scanned.
- Resolves the target by `qr_token`; errors if not found or if it's yourself.
- **Idempotent:** if the pair already has a connection (either direction), returns
the existing one instead of creating a duplicate.
- **Idempotent:** if the pair already has a connection (either direction) for the
active event, returns the existing one instead of creating a duplicate.
### `accept_connection(p_connection_id)` → `connections`
Accepts an **incoming** request.
- Locks the row (`for update`), verifies the caller is the recipient
(`to_id = auth.uid()`) and the status is still `pending`.
(`to_email = current_email()`) and the status is still `pending`.
- Sets `status = 'accepted'`, `resolved_at = now()`.
- **Awards +5 to both** `from_id` and `to_id` (category `connection`).
- **Awards +5 to both** `from_email` and `to_email` (category `connection`).
### `reject_connection(p_connection_id)` → `connections`
Same guards as accept, but sets `status = 'rejected'`. No points.
### `checkin_attendee(p_session_id, p_attendee_qr)` → `(checkin_id, attendee_id, attendee_name, points, already)`
### `checkin_attendee(p_session_id, p_attendee_qr)` → `(checkin_id, attendee_email, attendee_name, points, already)`
Staff checks an attendee into a session.
- **Role check:** `is_staff_or_admin()` or it raises `staff or admin only`.
- **Role check:** `is_staff_or_admin()` (i.e. `is_admin()`) or it raises
`staff or admin only`.
- Resolves the attendee by `qr_token`.
- `insert into checkins ... on conflict (profile_id, session_id) do nothing
returning id` — if no row was inserted, the attendee was **already checked in**:
sets `already = true` and awards **no points**.
- `insert into checkins ... on conflict (event_id, contact_email, session_id) do
nothing returning id` — if no row was inserted, the attendee was **already
checked in**: sets `already = true` and awards **no points**.
- Otherwise awards **+10** to the attendee (category `checkin`).
- Returns the attendee's current total points.
@@ -102,20 +116,22 @@ Post-session feedback.
- **Idempotent:** if feedback already exists for (caller, session), it **updates**
the rating/comment and awards **0** (already rewarded on first submission).
- Otherwise inserts and awards `earned` (category `feedback`).
- Recalculates `sessions.average_feedback`, updates the `ai_generated_feedback`
state machine, and recalcs the event aggregates.
### `adjust_points(p_profile_id, p_delta, p_reason)` → `void`
**Admin-only** manual points adjustment (category `admin`). Used by the Admin
console (Phase 2) to award prizes or correct mistakes. Goes through
### `adjust_points(p_contact_email, p_delta, p_reason)` → `void`
**Admin-only** manual points adjustment (category `admin`) for the active event.
Used by the APPE Admin console to award prizes or correct mistakes. Goes through
`_award_points`, so it floors at 0, writes `points_log`, and re-syncs the
leaderboard.
### `reset_qr_token(p_profile_id)` → `(profile_id, qr_token)`
**Admin-only.** Regenerates an attendee's lanyard QR token.
- Generates a fresh `CVV-XXX-NNNN` token and writes it to `profiles.qr_token`.
- **Re-hashes it as the Auth password** (`extensions.crypt(token, extensions.gen_salt('bf'))`
on `auth.users.encrypted_password`), so the **old token stops working** and the
attendee must re-scan with the new one.
- **Deletes the attendee's existing `auth.sessions`**, forcing a re-login.
### `reset_qr_token(p_contact_email)` → `(email, qr_token)`
**Admin-only.** Regenerates a contact's lanyard QR token.
- Generates a fresh `CVV-XXX-NNNN` token and writes it to `contacts.qr_token`.
- **Re-hashes it as the Auth password** (`extensions.crypt(token,
extensions.gen_salt('bf'))` on `auth.users.encrypted_password`), so the **old
token stops working** and the contact must re-scan with the new one.
- **Deletes the contact's existing `auth.sessions`**, forcing a re-login.
- Returns the new token so the admin can print/show it as a QR code.
> **Implementation note:** pgcrypto's `gen_salt` / `crypt` live in the
@@ -124,22 +140,44 @@ leaderboard.
> `extensions.crypt(...)`. The function owner (`postgres`) can write
> `auth.users` and `auth.sessions`, which is what makes this possible.
Source of truth for this RPC:
[`supabase/migrations/20260823000000_admin_app.sql`](../../supabase/migrations/20260823000000_admin_app.sql).
### `upsert_contact(p_email, p_full_name, p_linkedin_url, p_is_admin, p_qr_token)` → `contacts`
**Admin-only.** Creates a contact if it doesn't exist (generating a QR token when
none is given) or updates the existing one. Returns the contact row.
### `create_registration(p_contact_email, p_type)` → `registrations`
**Admin-only.** Creates a registration for the active event (enforces the
sponsor-type rule).
### `set_registration_type(p_contact_email, p_type)` → `registrations`
**Admin-only.** Changes a contact's registration type for the active event.
### `evaluate_session_feedback(p_session_id)` → `sessions`
**Admin-only.** The **AI-feedback stub**: sets `ai_generated_feedback` to a
placeholder string ("AI evaluation stub: N comment(s) received. (LLM integration
pending.)"). Real LLM integration is a later phase.
### `set_session_material(p_session_id, p_material_path)` → `sessions`
Sets a session's `material_path`. Allowed for **admins and for any speaker of the
session** (the `sessions` table is admin-write only, so speakers need this
security-definer RPC to attach their uploaded material). The attendee app calls
this after uploading a file to the `materials` bucket.
## Role helper functions
| Function | Returns | Meaning |
|---|---|---|
| `is_admin()` | `boolean` | current user's profile has `role = 'admin'` |
| `is_staff_or_admin()` | `boolean` | current user's profile has `role in ('staff','admin')` |
| `current_email()` | `text` | `auth.jwt() ->> 'email'` (the identity) |
| `is_admin()` | `boolean` | current contact has `is_admin = true` |
| `is_staff_or_admin()` | `boolean` | = `is_admin()` (staff is merged into admin) |
| `is_speaker_or_admin()` | `boolean` | admin, **or** a speaker of a session in the active event (via `session_speakers`), **or** a contact whose registration type is `speaker` |
Both are `security definer` so they can read `profiles` inside RLS checks and RPC
guards.
All are `security definer` so they can read `contacts` / `registrations` /
`session_speakers` inside RLS checks and RPC guards.
## Error handling
RPCs raise Postgres exceptions with human-readable messages (e.g. `you cannot
connect with yourself`, `staff or admin only`, `you must be checked in to this
session to give feedback`). The frontend surfaces these via toasts — see
session to give feedback`, `not a speaker of this session`). The frontend
surfaces these via toasts — see
[../frontend/api-client.md](../frontend/api-client.md).
+164 -50
View File
@@ -1,152 +1,266 @@
# Database Schema
All tables live in the `public` schema. Source of truth:
[`supabase/migrations/20260822000000_init.sql`](../../supabase/migrations/20260822000000_init.sql).
[`supabase/migrations/20260824000000_redesign.sql`](../../supabase/migrations/20260824000000_redesign.sql)
(the Redesign migration, which **replaces** the old `profiles`-based schema).
There are **9 tables**: people, schedule, and the event's activity.
There are **13 tables**: people (`contacts`), the event (`events`), participation
(`registrations`, `sponsors`), the schedule (`slots`, `sessions`,
`session_speakers`), and the event's activity (`preferences`, `connections`,
`checkins`, `feedback`, `leaderboard`, `points_log`).
The old `profiles` table is **dropped**. People are now `contacts` (keyed by
email), and every activity table is scoped to an **event** + a **contact email**
instead of a single `profile_id`.
```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"
contacts ||--o{ registrations : "participates"
contacts ||--o{ session_speakers : "speaks"
contacts ||--o{ preferences : "picks"
contacts ||--o{ connections : "from/to"
contacts ||--o{ checkins : "checked in"
contacts ||--o{ feedback : "rates"
contacts ||--o{ leaderboard : "mirrored"
contacts ||--o{ points_log : "audited"
events ||--o{ registrations : "has"
events ||--o{ sponsors : "has"
events ||--o{ slots : "has"
events ||--o{ sessions : "has"
events ||--o{ preferences : "scopes"
events ||--o{ connections : "scopes"
events ||--o{ checkins : "scopes"
events ||--o{ feedback : "scopes"
events ||--o{ leaderboard : "scopes"
events ||--o{ points_log : "scopes"
slots ||--o{ sessions : "contains"
sessions ||--o{ session_speakers : "has speakers"
sessions ||--o{ preferences : "picked"
sessions ||--o{ checkins : "checked into"
sessions ||--o{ feedback : "rated"
```
## `profiles` — people (source of truth)
## `contacts` — people (source of truth)
One row per attendee. `id` **is** the Supabase Auth user id.
One row per person. **`email` is the primary key** (a natural key that matches
`auth.users.email`). The `qr_token` doubles as the Supabase Auth password.
| Column | Type | Notes |
|---|---|---|
| `id` | `uuid` PK | = `auth.users(id)`; `on delete cascade` |
| `email` | `text` **unique** | The ticket-purchase email (login identifier) |
| `email` | `text` **PK** | The ticket-purchase email (login identifier) |
| `full_name` | `text` | |
| `company` | `text` | nullable |
| `role` | `text` | `attendee` \| `staff` \| `admin` (default `attendee`) |
| `linkedin_url` | `text` | nullable |
| `show_email` | `boolean` | default `false` — visibility toggle |
| `show_linkedin` | `boolean` | default `false` — visibility toggle |
| `is_admin` | `boolean` | default `false` — **staff = admin (merged)**; grants check-in + APPE Admin access |
| `qr_token` | `text` **unique** | The lanyard token; **doubles as the Auth password** |
| `created_at` | `timestamptz` | |
Index: `contacts_qr_token_idx (qr_token)` — fast lanyard lookups.
## `events` — a conference
At most **one active event** at a time (partial unique index + trigger). The app
queries everything for the active event and handles "no active event" gracefully.
| Column | Type | Notes |
|---|---|---|
| `id` | `uuid` PK | `gen_random_uuid()` |
| `name` | `text` | e.g. "APPE 2026" |
| `start_date` / `end_date` | `date` | |
| `location` | `text` | nullable |
| `is_active` | `boolean` | default `false` |
| `avg_feedback` | `numeric` | maintained aggregate |
| `num_sessions` | `integer` | maintained aggregate |
| `num_speakers` | `integer` | maintained aggregate |
| `num_registrations` | `integer` | maintained aggregate |
| `num_checked_in_registrations` | `integer` | maintained aggregate |
| `created_at` | `timestamptz` | |
**Constraint:** `unique index events_one_active on (is_active) where is_active`
— at most one active event. The aggregate columns are kept in sync by triggers
(counts) and the `submit_feedback` RPC (`avg_feedback`).
## `registrations` — a contact's participation in an event
Points are scoped **per event** here (one row per contact per event).
| Column | Type | Notes |
|---|---|---|
| `id` | `uuid` PK | |
| `event_id` | `uuid` FK → `events` | `on delete cascade` |
| `contact_email` | `text` FK → `contacts` | `on delete cascade` |
| `type` | `text` | `attendee` \| `speaker` \| `staff` \| `sponsor` (default `attendee`) |
| `checked_in` | `boolean` | default `false` |
| `points` | `integer` | `>= 0`, default 0 |
| `created_at` | `timestamptz` | |
**Constraint:** `unique (event_id, contact_email)` — one registration per contact
per event.
## `sponsors` — a sponsor for an event
Unpaid sponsors are hidden from non-admins (RLS).
| Column | Type | Notes |
|---|---|---|
| `id` | `uuid` PK | |
| `event_id` | `uuid` FK → `events` | `on delete cascade` |
| `type` | `text` | `headline` \| `platinum` \| `gold` \| `silver` \| `community` \| `swag` \| `catering` \| `diversity` |
| `name` | `text` | |
| `email` | `text` | nullable |
| `phone` | `text` | nullable |
| `paid` | `boolean` | default `false` — unpaid hidden from non-admins |
| `amount_eur` | `numeric` | nullable |
| `contact_email` | `text` FK → `contacts` | nullable lookup, `on delete set null` |
| `created_at` | `timestamptz` | |
## `slots` — schedule blocks
| Column | Type | Notes |
|---|---|---|
| `id` | `integer` PK | 1–6 |
| `event_id` | `uuid` FK → `events` | `on delete cascade` |
| `type` | `text` | `session` \| `lunch_break` \| `coffee_break` \| `keynote` \| `close_up` (default `session`) |
| `name` | `text` | e.g. "Slot 1" |
| `slot_date` | `date` | `2026-10-23` |
| `start_time` | `time` | |
| `end_time` | `time` | |
| `start_time` / `end_time` | `time` | |
## `sessions` — one per (slot, room)
| Column | Type | Notes |
|---|---|---|
| `id` | `uuid` PK | `gen_random_uuid()` |
| `event_id` | `uuid` FK → `events` | `on delete cascade` |
| `slot_id` | `integer` FK → `slots` | `on delete cascade` |
| `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` | |
| `capacity` | `integer` | nullable (not enforced) |
| `average_feedback` | `numeric` | maintained by `submit_feedback` |
| `ai_generated_feedback` | `text` | AI-feedback state (stub) |
| `material_path` | `text` | nullable — storage object path for session material |
| `created_at` | `timestamptz` | |
Index: `sessions_slot_id_idx (slot_id)`.
> **Speakers are no longer a `text` column** — they live in the `session_speakers`
> join table below (1:N). The `get_agenda()` RPC aggregates them into a
> comma-separated `speakers` string for display.
Indexes: `sessions_event_id_idx (event_id)`, `sessions_slot_id_idx (slot_id)`.
## `session_speakers` — M:N between sessions and contacts
A session must have **≥ 1 speaker** (enforced by a trigger).
| Column | Type | Notes |
|---|---|---|
| `session_id` | `uuid` FK → `sessions` | `on delete cascade` |
| `contact_email` | `text` FK → `contacts` | `on delete cascade` |
**PK:** `(session_id, contact_email)`.
## `preferences` — one pick per slot
| Column | Type | Notes |
|---|---|---|
| `id` | `uuid` PK | |
| `profile_id` | `uuid` FK → `profiles` | |
| `session_id` | `uuid` FK → `sessions` | |
| `event_id` | `uuid` FK → `events` | `on delete cascade` |
| `contact_email` | `text` FK → `contacts` | `on delete cascade` |
| `session_id` | `uuid` FK → `sessions` | `on delete cascade` |
| `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).
**Constraint:** `unique (event_id, contact_email, slot_id)` — one pick 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 |
| `event_id` | `uuid` FK → `events` | `on delete cascade` |
| `from_email` | `text` FK → `contacts` | the requester |
| `to_email` | `text` FK → `contacts` | 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.
**Constraint:** unique per **unordered pair per event** via
`unique index connections_pair_uniq on (event_id, least(from_email, to_email),
greatest(from_email, to_email))`. So Ana→Bruno and Bruno→Ana are the *same*
connection.
## `checkins` — staff check-in of an attendee
## `checkins` — staff check-in of a contact
| Column | Type | Notes |
|---|---|---|
| `id` | `uuid` PK | |
| `profile_id` | `uuid` FK → `profiles` | the attendee being checked in |
| `event_id` | `uuid` FK → `events` | `on delete cascade` |
| `contact_email` | `text` FK → `contacts` | the attendee being checked in |
| `session_id` | `uuid` FK → `sessions` | |
| `staff_id` | `uuid` FK → `profiles` | the staff member who scanned |
| `staff_email` | `text` FK → `contacts` | the staff member who scanned |
| `created_at` | `timestamptz` | |
**Constraint:** `unique (profile_id, session_id)` — one check-in per attendee per
session (prevents double points).
**Constraint:** `unique (event_id, contact_email, session_id)` — one check-in per
contact per session (prevents double points).
## `feedback` — post-session rating
| Column | Type | Notes |
|---|---|---|
| `id` | `uuid` PK | |
| `profile_id` | `uuid` FK → `profiles` | |
| `event_id` | `uuid` FK → `events` | `on delete cascade` |
| `contact_email` | `text` FK → `contacts` | |
| `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.
**Constraint:** `unique (event_id, contact_email, session_id)` — one feedback per
contact 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)).
A public, Realtime-friendly mirror of points **per event**. **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` | |
| `event_id` | `uuid` PK FK → `events` | |
| `contact_email` | `text` PK FK → `contacts` | |
| `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).
**PK:** `(event_id, contact_email)`. 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.
Powers the per-category points breakdown on the Profile screen (per event).
| Column | Type | Notes |
|---|---|---|
| `id` | `uuid` PK | |
| `profile_id` | `uuid` FK → `profiles` | |
| `event_id` | `uuid` FK → `events` | `on delete cascade` |
| `contact_email` | `text` FK → `contacts` | |
| `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)`.
Index: `points_log_event_id_idx (event_id)`.
## Other indexes
- `profiles_qr_token_idx (qr_token)` — fast lanyard lookups.
- `checkins_session_id_idx (session_id)`.
- `slots_event_id_idx (event_id)`, `registrations_event_id_idx (event_id)`,
`checkins_session_id_idx (session_id)`.
## Storage
A **`materials`** bucket (public read) stores session material. Speakers + admins
can write (see [rls.md](./rls.md#storage--materials-bucket)). A session's
`material_path` points at the object; the public URL is
`/storage/v1/object/public/materials/{material_path}`.
+47 -29
View File
@@ -7,12 +7,16 @@ Source of truth: [`supabase/seed.sql`](../../supabase/seed.sql). The seed runs o
| Data | Count | Notes |
|---|---|---|
| `auth.users` + `auth.identities` | 13 | 12 attendees + 1 admin; **QR token = bcrypt password** |
| `contacts` | 14 | 13 with QR tokens + 1 external keynote speaker (no token) |
| `events` | 1 | **APPE 2026**, 2026-10-23, São Paulo, Brazil, **active** |
| `registrations` | 13 | one per contact (Elena has none); points scoped here |
| `sponsors` | 3 | Nubank (headline, paid), Acme Corp (gold, paid), Globant (community, unpaid) |
| `slots` | 6 | 23 Oct, 09:00–15:45 (see table below) |
| `sessions` | 18 | 3 per slot (Main Stage / Room A / Room B) |
| `auth.users` + `auth.identities` | 13 | 12 attendees + 1 admin; **QR token = bcrypt password** |
| `profiles` | 13 | one per user, with role + starting points |
| `leaderboard` | 13 | mirrored from `profiles` |
| `points_log` | 21 | Ana's coherent breakdown + one `admin` entry per other user |
| `session_speakers` | 22 | M:N session → contact |
| `leaderboard` | 13 | mirrored from `registrations` |
| `points_log` | 16 | Ana's coherent breakdown + one `admin` entry per other user |
| Ana's demo state | — | 6 preferences, 2 check-ins, 4 connections, 1 feedback |
> **GoTrue gotcha:** manually-inserted `auth.users` must have
@@ -21,40 +25,49 @@ Source of truth: [`supabase/seed.sql`](../../supabase/seed.sql). The seed runs o
> grant can't scan a NULL `confirmation_token`. `phone` is left NULL (unique
> constraint).
> **Staff = admin (merged).** Bruno, Rita, and the APPE Admin have
> `is_admin = true` on their `contacts` row. Their registration `type` is
> `staff` (the ticket type shown on the lanyard).
## Slots
| id | Time |
|---|---|
| 1 | 09:00–09:45 |
| 2 | 10:00–10:45 |
| 3 | 11:30–12:15 |
| 4 | 13:15–14:00 |
| 5 | 14:00–14:45 |
| 6 | 15:00–15:45 |
| id | Type | Time |
|---|---|---|
| 1 | keynote | 09:00–09:45 |
| 2 | session | 10:00–10:45 |
| 3 | session | 11:30–12:15 |
| 4 | lunch_break | 13:15–14:00 |
| 5 | session | 14:00–14:45 |
| 6 | close_up | 15:00–15:45 |
## Demo accounts
Login = **QR code** (typed or scanned) + **email**. The QR token is the password.
| Person | Role | QR code | Email | Company | Start pts |
|---|---|---|---|---|---|
| **Ana Silva** | attendee | `CVV-ANA-4821` | ana.silva@nubank.com | Nubank | 40 |
| **Bruno Costa** | staff | `CVV-BRU-1177` | bruno.costa@acme.com | Acme Corp | 140 |
| **Rita Lopes** | staff | `CVV-RIT-9034` | rita.lopes@globant.com | Globant | 95 |
| **Convivo Admin** | admin | `CVV-ADM-0001` | admin@appe.at | Convivo | 0 |
| Tomás Ribeiro | attendee | `CVV-TOM-5566` | tomas.ribeiro@dataprev.com | Dataprev | 88 |
| Sofia Almeida | attendee | `CVV-SOF-2299` | sofia.almeida@loop.com | Loop | 76 |
| Marco Chen | attendee | `CVV-MRC-7712` | marco.chen@deepmind.com | DeepMind | 70 |
| Julia Santos | attendee | `CVV-JUL-3345` | julia.santos@ifood.com | iFood | 64 |
| Pedro Nunes | attendee | `CVV-PED-8801` | pedro.nunes@microsoft.com | Microsoft | 58 |
| Carla Mendes | attendee | `CVV-CAR-6623` | carla.mendes@quintoessencial.com | QuintoEssencial | 52 |
| Diego Ferreira | attendee | `CVV-DIE-4458` | diego.ferreira@stone.com | Stone | 35 |
| Marina Costa | attendee | `CVV-MNA-2210` | marina.costa@olx.com | OLX | 28 |
| Lucas Oliveira | attendee | `CVV-LUC-9987` | lucas.oliveira@usp.br | USP | 15 |
| Person | Type | QR code | Email | Start pts |
|---|---|---|---|---|
| **Ana Silva** | attendee | `CVV-ANA-4821` | ana.silva@nubank.com | 40 |
| **Bruno Costa** | staff (admin) | `CVV-BRU-1177` | bruno.costa@acme.com | 140 |
| **Rita Lopes** | staff (admin) | `CVV-RIT-9034` | rita.lopes@globant.com | 95 |
| **APPE Admin** | staff (admin) | `CVV-ADM-0001` | admin@appe.at | 0 |
| Tomás Ribeiro | attendee | `CVV-TOM-5566` | tomas.ribeiro@dataprev.com | 88 |
| Sofia Almeida | attendee | `CVV-SOF-2299` | sofia.almeida@loop.com | 76 |
| Marco Chen | attendee | `CVV-MRC-7712` | marco.chen@deepmind.com | 70 |
| Julia Santos | attendee | `CVV-JUL-3345` | julia.santos@ifood.com | 64 |
| Pedro Nunes | attendee | `CVV-PED-8801` | pedro.nunes@microsoft.com | 58 |
| Carla Mendes | attendee | `CVV-CAR-6623` | carla.mendes@quintoessencial.com | 52 |
| Diego Ferreira | attendee | `CVV-DIE-4458` | diego.ferreira@stone.com | 35 |
| Marina Costa | attendee | `CVV-MNA-2210` | marina.costa@olx.com | 28 |
| Lucas Oliveira | attendee | `CVV-LUC-9987` | lucas.oliveira@usp.br | 15 |
| Dr. Elena Vasquez | (external speaker) | — | elena.vasquez@keynote.com | — |
> **Dr. Elena Vasquez** is an external keynote speaker: she has a `contacts` row
> (and speaks in `session_speakers`) but **no QR token and no auth user**, so she
> can't log in — she only appears as a speaker on the agenda.
## Ana's demo state (so the app looks alive on first login)
Ana (id `11111111-…`) is seeded with a coherent 40-point history:
Ana (`[email protected]`) is seeded with a coherent 40-point history:
- **Points breakdown** (`points_log`): 2× check-in (+10 each), 2× connection
(+5 each), 1× feedback (+10) = **40**.
@@ -70,7 +83,10 @@ Ana (id `11111111-…`) is seeded with a coherent 40-point history:
- accepted with **Bruno** and **Rita**
- incoming (pending) from **Sofia**
- outgoing (pending) to **Julia**
- **Feedback** — rated Slot 1's *Designing for Trust in AI Products* 5★ with a comment.
- **Feedback** — rated Slot 1's *Designing for Trust in AI Products* 5★ with a
comment.
- **Speaker** — Ana is a speaker of Slot 6's *Open Space: Your Ideas* (so the
Agenda shows a "🎤 you" tag and the material-upload notice).
> Everyone else gets a single `admin` `points_log` entry for their starting points
> (so the Profile breakdown shows "Other"), and no other activity.
@@ -82,3 +98,5 @@ Ana (id `11111111-…`) is seeded with a coherent 40-point history:
3. Log in as **Bruno** (staff) → the Scan tab becomes **Check-in** → pick a
session → scan **Carla** (`CVV-CAR-6623`) → she gets +10.
4. Watch the **Leaderboard** update live (Realtime).
5. Log in as **APPE Admin** (`CVV-ADM-0001` / `[email protected]`) in the admin app
→ Dashboard, Contacts, Registrations, Sponsors, Schedule, Activity, Events.
+8 -5
View File
@@ -14,7 +14,7 @@ the "main docker" of the project.
| `supabase_auth_Convivo` | `supabase/gotrue` | Auth (QR + email login) |
| `supabase_rest_Convivo` | `supabase/postgrest` | REST API over Postgres (tables + RPCs) |
| `supabase_realtime_Convivo` | `supabase/realtime` | WebSocket realtime (leaderboard) |
| `supabase_storage_Convivo` | `supabase/storage-api` | Storage (unused in v1) |
| `supabase_storage_Convivo` | `supabase/storage-api` | Storage — the `materials` bucket (session material) |
| `supabase_kong_Convivo` | `supabase/kong` | **API gateway** — fronts everything on one port |
| `supabase_studio_Convivo` | `supabase/studio` | Web UI (Studio) |
| `supabase_inbucket_Convivo` | `supabase/mailpit` | Captures emails (none sent in this flow) |
@@ -58,10 +58,12 @@ npm run db:stop # = supabase stop
npx supabase status
```
- `db:reset` drops and recreates the database, applies
[`migrations/20260822000000_init.sql`](../../supabase/migrations/20260822000000_init.sql),
then runs [`seed.sql`](../../supabase/seed.sql). Use it any time you want a
clean demo state.
- `db:reset` drops and recreates the database, applies **all** migrations in
order (`20260822000000_init.sql` → `20260823000000_admin_app.sql` →
[`20260824000000_redesign.sql`](../../supabase/migrations/20260824000000_redesign.sql),
the last of which replaces the old schema), then runs
[`seed.sql`](../../supabase/seed.sql). Use it any time you want a clean demo
state.
- Migrations and seed are **idempotent** (`on conflict ... do nothing`), so a
reset is safe to repeat.
@@ -74,6 +76,7 @@ npx supabase status
| `[db] port` | `54322` | Postgres port |
| `[studio] port` | `54323` | Studio port |
| `[auth.email] enable_confirmations` | `false` | **No email is sent** — the QR+email login never emails the user |
| `[auth] jwt_expiry` | `86400` | **24-hour login** — the session JWT lives a full day |
| `[auth] site_url` | `http://127.0.0.1:3000` | The app origin |
| `[db.seed] sql_paths` | `["./seed.sql"]` | Seed runs on reset |
+13 -11
View File
@@ -5,10 +5,10 @@ same-origin paths:
- **Attendee PWA** — a mobile-first single-page app in
[`apps/convivo/`](../../apps/convivo/). The same app for attendees, staff, and
admins — the user's `role` changes what they see (e.g. the Scan tab becomes a
Check-in tab for staff).
- **Admin console** — a desktop-first app in
[`apps/admin/`](../../apps/admin/), guarded to the `admin` role. See
admins — the user's `is_admin` flag changes what they see (e.g. the Scan tab
becomes a Check-in tab for staff).
- **Admin console (APPE Admin)** — a desktop-first app in
[`apps/admin/`](../../apps/admin/), guarded to the `is_admin` flag. See
[admin-app.md](./admin-app.md).
| File | What it covers |
@@ -38,14 +38,15 @@ apps/convivo/src/
├─ App.tsx # Providers + Shell (tab nav + Feedback takeover)
├─ styles.css # All styling (ported from mockup/index.html)
├─ context/
│ ├─ AuthContext.tsx # session + profile + signOut
│ ├─ AuthContext.tsx # session + contact + registration + signOut
│ └─ ToastContext.tsx # transient toasts
├─ lib/
│ ├─ supabase.ts # createClient (same-origin)
│ ├─ api.ts # typed wrapper over rpc/from
│ ├─ types.ts # TS types mirroring the DB
│ ├─ time.ts # event clock + slot status + formatting
│ └─ useEvent.ts # loads the agenda once, exposes it grouped
│ ├─ useEvent.ts # loads the active event + agenda, exposes it grouped
│ └─ usePolling.ts # 5s visibility-aware polling hook
├─ components/
│ └─ ui.tsx # Avatar, Spinner, Empty, Sheet, QrImage, Scanner
└─ screens/
@@ -55,15 +56,16 @@ apps/convivo/src/
## Data flow (high level)
- **Auth** — `AuthContext` holds the Supabase session + the current `Profile`.
See [app-structure.md](./app-structure.md#authcontext).
- **Event data** — `useEvent()` loads the agenda once via the `get_agenda()` RPC
and exposes it grouped by slot plus the event clock. See
- **Auth** — `AuthContext` holds the Supabase session + the current `Contact`
and `Registration`. See [app-structure.md](./app-structure.md#authcontext).
- **Event data** — `useEvent()` loads the active event + agenda via the
`get_agenda()` RPC and exposes it grouped by slot plus the event clock. See
[app-structure.md](./app-structure.md#the-event-hook-useevent).
- **Per-screen data** — each screen fetches what it needs through the typed
[api client](./api-client.md) (e.g. Home fetches preferences + check-ins).
- **Live updates** — the Leaderboard subscribes to Realtime on the `leaderboard`
table. See [screens.md#leaderboard](./screens.md#leaderboard).
table; Connections polls every 5s while the tab is visible (`usePolling`). See
[screens.md#leaderboard](./screens.md#leaderboard).
The app only ever uses the **anon key + the user's session JWT**; all security is
enforced by RLS in the database. See [../backend/rls.md](../backend/rls.md).
+52 -33
View File
@@ -1,9 +1,10 @@
# Frontend — Admin console
# Frontend — APPE Admin
The admin console is a **desktop-first single-page React app** in
[`apps/admin/`](../../apps/admin/). It is a separate app from the attendee PWA
(same stack, same Supabase core, same same-origin proxy pattern) and is **guarded
to the `admin` role** — anyone else who signs in is immediately signed out.
[`apps/admin/`](../../apps/admin/), branded **APPE Admin**. It is a separate app
from the attendee PWA (same stack, same Supabase core, same same-origin proxy
pattern) and is **guarded to the `is_admin` flag** — anyone else who signs in is
immediately signed out.
It runs on **port 3001** (Vite dev) or as the `convivo-admin` Docker container
(nginx). The attendee app stays on 3000.
@@ -12,18 +13,21 @@ It runs on **port 3001** (Vite dev) or as the `convivo-admin` Docker container
| View | Purpose |
|---|---|
| **Dashboard** | Live event stats (attendees, check-ins, connections, avg rating, sessions) + top points + recent activity. |
| **Attendees** | Searchable table of all people. Edit name/company/role, view + **reset the QR token**, and **adjust points**. |
| **Schedule** | Manage **slots** and **sessions** — create, edit, delete. |
| **Activity** | Tables of check-ins, connections, and feedback. |
| **Dashboard** | Active event card (name, dates, location, aggregates: avg feedback, #sessions, #speakers, #registrations, #checked-in) + top points + recent activity. |
| **Contacts** | Table of all contacts (email, name, LinkedIn, visibility toggles, `is_admin`, QR token). Edit, **reset the QR token**, toggle `is_admin`, set visibility. |
| **Registrations** | Per active event: list (contact, type, checked_in). Change type (enforces the sponsor rule), mark checked-in. |
| **Sponsors** | List (paid only visible to attendees; admin sees all). Add/edit (type, name, email, phone, paid, amount, contact lookup). |
| **Schedule** | Slots (with type) + sessions (with speakers 1:N, material upload, `average_feedback`, `ai_generated_feedback` + an **Evaluate** stub button). |
| **Activity** | Tables of check-ins, connections, and feedback (per active event). |
| **Events** | Create event, set active (only one), edit dates/location. |
## Auth guard
Login is the same QR + email flow as the attendee app
(`signInWithPassword({ email, password: qrToken })`), but `AuthContext` checks the
profile's `role` after signing in:
contact's `is_admin` flag after signing in:
- If `role === 'admin'` → the session is accepted and the console is shown.
- If `is_admin === true` → the session is accepted and the console is shown.
- Otherwise → the app calls `signOut()` and shows **"This account is not an
admin."** The same check runs on session restore (page reload) and on every
`onAuthStateChange`, so a non-admin can never see the console.
@@ -38,21 +42,24 @@ apps/admin/src/
├─ App.tsx # Providers + Shell (sidebar nav + view switch)
├─ styles.css # Desktop-first styling (same design tokens as the PWA)
├─ context/
│ ├─ AuthContext.tsx # session + profile + admin-role guard
│ ├─ AuthContext.tsx # session + contact + is_admin guard
│ └─ ToastContext.tsx # transient toasts
├─ lib/
│ ├─ supabase.ts # createClient (same-origin)
│ ├─ api.ts # typed wrapper: reads + updateProfile / adjustPoints / resetQrToken
│ ├─ api.ts # typed wrapper: reads + writes (contacts, registrations, sponsors, schedule, points)
│ └─ types.ts # TS types mirroring the DB
├─ components/
│ └─ ui.tsx # Avatar, Spinner, Empty, Modal, QrImage, RoleBadge
│ └─ ui.tsx # Avatar, Spinner, Empty, Modal, QrImage, TypeBadge, Toggle
├─ screens/
│ └─ Login.tsx # QR + email login (admin-only)
└─ views/
├─ Dashboard.tsx # stats + top points + recent activity
├─ Attendees.tsx # table + edit / QR-reset / points modals
├─ Schedule.tsx # slots + sessions CRUD
└─ Activity.tsx # check-ins / connections / feedback tables
├─ Dashboard.tsx # active event + aggregates + top points + activity
├─ Contacts.tsx # table + edit / QR-reset / is_admin / visibility
├─ Registrations.tsx# per-event list + type / checked-in
├─ Sponsors.tsx # sponsor CRUD
├─ Schedule.tsx # slots + sessions + speakers + material + AI-evaluate
├─ Activity.tsx # check-ins / connections / feedback tables
└─ Events.tsx # event management
```
## Data access
@@ -60,31 +67,43 @@ apps/admin/src/
The admin app uses the **anon key + the admin's session JWT** — no service-role
key. Everything it can do is allowed by RLS:
- **Reads** — admin-only `select` policies on `profiles`, `connections`,
`feedback`, `preferences`, `checkins`, `points_log`, plus the public
`slots` / `sessions` / `leaderboard`. See [../backend/rls.md](../backend/rls.md).
- **Writes** — direct `insert` / `update` / `delete` on `profiles`, `slots`, and
`sessions` (admin-only policies).
- **RPCs** — `reset_qr_token` (regenerate a lanyard token) and `adjust_points`
(manual, audited as `admin`). See [../backend/rpcs.md](../backend/rpcs.md).
- **Reads** — admin-only `select` policies on `contacts`, `registrations`,
`sponsors`, `connections`, `feedback`, `checkins`, `points_log`, plus the public
`events` / `slots` / `sessions` / `session_speakers` / `leaderboard`. See
[../backend/rls.md](../backend/rls.md).
- **Writes** — direct `insert` / `update` / `delete` on `contacts`, `events`,
`registrations`, `sponsors`, `slots`, `sessions`, and `session_speakers`
(admin-only policies).
- **RPCs** — `reset_qr_token` (regenerate a lanyard token), `adjust_points`
(manual, audited as `admin`), `upsert_contact`, `create_registration`,
`set_registration_type`, `evaluate_session_feedback` (AI stub), and
`set_session_material` (attach uploaded material). See
[../backend/rpcs.md](../backend/rpcs.md).
### Resetting a QR token
`reset_qr_token(profile_id)` generates a new `CVV-XXX-NNNN` token, writes it to
`profiles.qr_token`, **re-hashes it as the Auth password** (so the old token stops
working), and deletes the attendee's existing sessions (forcing a re-login). The
UI shows the new token as a scannable QR code.
`reset_qr_token(contact_email)` generates a new `CVV-XXX-NNNN` token, writes it to
`contacts.qr_token`, **re-hashes it as the Auth password** (so the old token stops
working), and deletes the contact's existing sessions (forcing a re-login). The UI
shows the new token as a scannable QR code.
### Adjusting points
`adjust_points(profile_id, delta, reason)` is the same transactional RPC the
`adjust_points(contact_email, delta, reason)` is the same transactional RPC the
event uses, but the `category` is `admin` so manual adjustments are auditable in
`points_log`. It keeps `profiles.points` and the `leaderboard` mirror in sync.
`points_log`. It keeps `registrations.points` and the `leaderboard` mirror in sync.
### Session material
The Schedule view uploads a session's material to the `materials` bucket and sets
`sessions.material_path` (admins can write `sessions` directly). The **Evaluate**
button calls `evaluate_session_feedback` (the AI stub) to set
`ai_generated_feedback`.
## Styling
The admin app reuses the attendee app's **design tokens** (colors, Poppins font,
card/pill/button styles) but is laid out **desktop-first**: a dark sidebar with
the nav + admin identity, and a wide content area with stat cards and data
tables. Below ~760px the sidebar collapses to a top bar so it still works on a
phone.
the **APPE / Admin** brand + nav + admin identity, and a wide content area with
stat cards and data tables. Below ~760px the sidebar collapses to a top bar so it
still works on a phone.
+33 -18
View File
@@ -25,7 +25,8 @@ export const supabase = createClient(url, anonKey, {
user's identity comes from the session JWT, and RLS enforces access. See
[../backend/rls.md](../backend/rls.md).
- **Session persistence** — the session is stored in `localStorage` and
auto-refreshed, so a reload keeps you logged in.
auto-refreshed, so a reload keeps you logged in. The JWT expiry is **24h**
(`jwt_expiry = 86400`), so a login lasts a full day.
## The typed wrapper (`lib/api.ts`)
@@ -40,9 +41,10 @@ These map 1:1 to the Postgres RPCs documented in
| Client function | RPC | Purpose |
|---|---|---|
| `lanyardLookup(qrToken)` | `lanyard_lookup` | Resolve a scanned QR to a public profile |
| `getPublicProfiles()` | `get_public_profiles` | All public profiles (leaderboard, name lookups) |
| `lanyardLookup(qrToken)` | `lanyard_lookup` | Resolve a scanned QR to a public contact + registration type |
| `getPublicContacts()` | `get_public_contacts` | Active-event contact directory (names + types) |
| `getAgenda()` | `get_agenda` | Slots + sessions (flat rows) |
| `getActiveEvent()` | `get_active_event` | The active event row |
| `setPreference(sessionId)` | `set_preference` | Pick a session for its slot |
| `clearPreference(slotId)` | `clear_preference` | Remove a pick |
| `createConnectionRequest(targetQr)` | `create_connection_request` | Send a connection request |
@@ -50,32 +52,41 @@ These map 1:1 to the Postgres RPCs documented in
| `rejectConnection(id)` | `reject_connection` | Decline |
| `checkinAttendee(sessionId, attendeeQr)` | `checkin_attendee` | Staff check-in (+10) |
| `submitFeedback(sessionId, rating, comment)` | `submit_feedback` | Rate a session (+5/+10) |
| `getLeaderboard()` | `get_leaderboard` | Active-event leaderboard |
| `uploadSessionMaterial(sessionId, file)` | `set_session_material` | Upload to `materials` bucket + set `material_path` |
### Direct table reads (RLS-scoped)
These read the caller's own rows (RLS returns only what the user may see):
These read the caller's own rows (RLS returns only what the user may see). For an
admin contact, RLS returns **all** rows, so the "my" reads filter by email
client-side to avoid leaking other people's data:
| Client function | Table | Returns |
|---|---|---|
| `getMyContact(email)` | `contacts` | the caller's contact |
| `getMyRegistration(email)` | `registrations` | the caller's registration (active event) |
| `getMyPreferences()` | `preferences` | the caller's picks |
| `getMyConnections()` | `connections` | connections the caller is in |
| `getMyCheckins()` | `checkins` | the caller's checked-in session ids |
| `getMyFeedback()` | `feedback` | the caller's feedback |
| `getLeaderboard()` | `leaderboard` | all rows (public to authenticated) |
| `getMyPointsLog()` | `points_log` | the caller's points history |
| `getMyCheckins(email)` | `checkins` | the caller's checked-in session ids |
| `getMyFeedback(email)` | `feedback` | the caller's feedback |
| `getMyPointsLog(email)` | `points_log` | the caller's points history |
| `getMySpeakerSessions(email)` | `session_speakers` | session ids the caller speaks |
### Helpers
- **`groupAgenda(rows)`** — turns the flat `get_agenda()` rows into
`{ slot, sessions[] }[]` ordered by slot id. Used by `useEvent()`.
- **`sessionMaterialUrl(path)`** — builds the public URL for a session material
in the `materials` bucket.
## Types (`lib/types.ts`)
TypeScript interfaces mirroring the DB tables and RPC return shapes
(`Profile`, `PublicProfile`, `Slot`, `Session`, `AgendaRow`, `Preference`,
`Connection`, `Checkin`, `Feedback`, `LeaderboardRow`, `PointsLogRow`,
`CheckinResult`, `FeedbackResult`). `PublicProfile` is the safe projection
(no email / qr_token) returned by the public read functions.
(`Contact`, `Registration`, `Event`, `Slot`, `Session`, `AgendaRow`,
`Preference`, `Connection`, `Checkin`, `Feedback`, `LeaderboardRow`,
`PointsLogRow`, `PublicContact`, `CheckinResult`, `FeedbackResult`).
`PublicContact` is the safe projection (email + name + visibility-respected
linkedin + registration type) returned by the public read functions.
## Error handling
@@ -83,11 +94,15 @@ TypeScript interfaces mirroring the DB tables and RPC return shapes
- Screens catch errors and surface them via toasts
(`useToast().toast(message, 'err')`). RPCs raise human-readable messages
(e.g. "staff or admin only", "you must be checked in to this session to give
feedback") — see [../backend/rpcs.md#error-handling](../backend/rpcs.md#error-handling).
feedback", "not a speaker of this session") — see
[../backend/rpcs.md#error-handling](../backend/rpcs.md#error-handling).
## Realtime
## Realtime + polling
The only realtime subscription is on the `leaderboard` table (see
[screens.md#leaderboard](./screens.md#leaderboard)). The `leaderboard` table is
the Realtime source and is kept in sync transactionally by the RPCs — see
[../backend/schema.md#leaderboard--realtime-mirror](../backend/schema.md#leaderboard--realtime-mirror).
- **Realtime** — the only realtime subscription is on the `leaderboard` table
(see [screens.md#leaderboard](./screens.md#leaderboard)). The `leaderboard`
table is the Realtime source and is kept in sync transactionally by the RPCs —
see [../backend/schema.md#leaderboard--realtime-mirror](../backend/schema.md#leaderboard--realtime-mirror).
- **Polling** — Connections and the Shell's pending-connection red dot use
`usePolling` (5s, visibility-aware) — see
[app-structure.md#the-polling-hook-libusepollingts](./app-structure.md#the-polling-hook-libusepollingts).
+27 -13
View File
@@ -23,18 +23,22 @@ see [api-client.md](./api-client.md).
## AuthContext (`context/AuthContext.tsx`)
Holds the Supabase **session**, the current **`Profile`**, and a `loading` flag.
Holds the Supabase **session**, the current **`Contact`**, the current
**`Registration`**, and a `loading` flag.
- On mount, reads the persisted session (`supabase.auth.getSession()`) and loads
the profile for that user id.
the contact + registration for that user's email.
- Subscribes to `onAuthStateChange` so login/logout anywhere updates the context.
- `loadProfile(userId)` fetches `profiles` where `id = userId` (RLS returns only
the caller's own row — see [../backend/rls.md](../backend/rls.md)).
- Exposes: `session`, `user`, `profile`, `loading`, `refreshProfile()`, `signOut()`.
- `loadContact(email)` fetches `contacts` where `email = email` (RLS returns only
the caller's own row — see [../backend/rls.md](../backend/rls.md));
`loadRegistration(email)` fetches the caller's `registrations` row for the
active event.
- Exposes: `session`, `user`, `contact`, `registration`, `loading`,
`refresh()`, `signOut()`.
> The profile is the app's source of truth for the current user's `role` and
> `points`. After any points-changing action, screens call `refreshProfile()` to
> re-fetch.
> The contact is the app's source of truth for the current user's `is_admin`
> (staff powers) and `qr_token`; the registration holds the user's `type` and
> `points`. After any points-changing action, screens re-fetch.
## ToastContext (`context/ToastContext.tsx`)
@@ -43,21 +47,24 @@ Used for login success, connection results, check-in results, and RPC errors.
## The event hook (`lib/useEvent.ts`)
Loads the agenda **once** and exposes it in a convenient shape:
Loads the active event + agenda and exposes it in a convenient shape:
```ts
interface EventData {
event: Event | null; // the active event (name, dates, location)
slots: { slot: Slot; sessions: Session[] }[]; // grouped, ordered by slot id
sessionById: Map<string, Session>;
slotById: Map<number, Slot>;
now: Date; // the (simulated) event clock
loading: boolean;
error: string | null;
reload: () => void; // re-fetch (e.g. after a material upload)
}
```
- Calls `getAgenda()` (the `get_agenda()` RPC) and groups the flat rows with
`groupAgenda()` (see [api-client.md](./api-client.md)).
`groupAgenda()` (see [api-client.md](./api-client.md)); also loads the active
event via `getActiveEvent()`.
- Every screen that needs the schedule calls `useEvent()` — the agenda is fetched
per screen mount (cheap, and keeps each screen self-contained).
@@ -84,6 +91,13 @@ At `10:20`, **Slot 1 (09:00–09:45) is `done`** and **Slot 2 (10:00–10:45) is
> clock just decides which slot is "live" for display. To use the real clock,
> replace `DEFAULT_NOW` with `new Date()`.
## The polling hook (`lib/usePolling.ts`)
`usePolling(fn, ms, enabled)` runs `fn` every `ms` milliseconds, but **only while
the tab is visible** (`document.visibilityState === 'visible'`), and re-runs
immediately when the tab becomes visible again. No background polling. Used by
the Connections screen (5s) and the Shell's pending-connection red dot (5s).
## The Shell (`App.tsx`)
The `Shell` is the navigation container. Render logic, in order:
@@ -100,11 +114,11 @@ The `Shell` is the navigation container. Render logic, in order:
| `home` | 🏠 Home | `Home` | default tab |
| `agenda` | 📅 Agenda | `Agenda` | |
| `scan` | 📷 **Scan** / **Check-in** | `Scan` | label is role-aware (below) |
| `connections` | 🤝 Connect | `Connections` | |
| `connections` | 🤝 Connect | `Connections` | red dot when there are pending incoming requests |
| `profile` | 👤 Profile | `Profile` | |
- **Role-aware Scan tab:** if `profile.role` is `staff` or `admin`, the tab label
is **"Check-in"** and the `Scan` screen defaults to staff mode. Otherwise it's
- **Role-aware Scan tab:** if `contact.is_admin` is true, the tab label is
**"Check-in"** and the `Scan` screen defaults to staff mode. Otherwise it's
**"Scan"**.
- **Leaderboard** is *not* a tab — it's reached from the Home points pill and the
Home quick-actions. It renders as a tab in the shell but is opened via
+49 -34
View File
@@ -4,7 +4,7 @@ Every screen in [`apps/convivo/src/screens/`](../../apps/convivo/src/screens/).
All screens are mobile-first and use the shared UI components
([app-structure.md#shared-ui-components](./app-structure.md#shared-ui-components)).
Data comes from the typed [api client](./api-client.md); the current user comes
from `useAuth()`.
from `useAuth()` (`contact` + `registration`).
| Screen | File | Reach |
|---|---|---|
@@ -21,9 +21,10 @@ from `useAuth()`.
A 3-step flow: **splash → scan → confirm**.
1. **Splash** — "Convivo / Break the ice. Earn the points." Tap anywhere to continue.
1. **Splash** — "APPE / Break the ice. Earn the points." Tap anywhere to continue.
2. **Scan** — scan (or type) your lanyard QR. Calls `lanyardLookup(qrToken)` to
resolve the attendee (pre-login, public). Shows the resolved name/company.
resolve the contact (pre-login, public). Shows the resolved name + registration
type badge.
3. **Confirm** — enter the **email used to buy the ticket**, then
`signInWithPassword({ email, password: qrToken })`. On success the
`AuthContext` updates and the Shell renders the app. On mismatch, an error is
@@ -37,41 +38,54 @@ A 3-step flow: **splash → scan → confirm**.
The landing screen. Shows:
- **Greeting + points pill** — "Good morning, Ana 👋" and `⚡ {points}` (tapping
the pill opens the Leaderboard).
the pill opens the Leaderboard). The event name (`event.name`) is shown under
the greeting.
- **Now card** — the session the user picked for the current slot, with a
"✓ Checked in" or "Show your QR to staff to check in" pill.
- **Next card** — the pick for the next slot.
- **My picks today** — the user's pick per slot (tap to change → opens Agenda).
- **Quick actions** — Scan & connect, Agenda, Connections, Leaderboard.
- **Quick actions** — Scan & connect / Check-in, Agenda, Connections, Leaderboard.
- **No active event** — a graceful empty state ("No active event right now.
Check back soon!").
Data: `useEvent()` (agenda + clock) + `getMyPreferences()` + `getMyCheckins()`.
Slot status comes from `slotStatus(slot, now)` ([app-structure.md#the-event-clock](./app-structure.md#the-event-clock)).
Data: `useEvent()` (event + agenda + clock) + `getMyPreferences()` +
`getMyCheckins(email)`. Slot status comes from `slotStatus(slot, now)`
([app-structure.md#the-event-clock](./app-structure.md#the-event-clock)).
## Agenda
Lists all 6 slots, each with its 3 sessions and a status pill (**Done / ● Live /
Up next**). The user's pick per slot is highlighted (filled check).
Lists all slots, each with its sessions, a **slot-type badge** (keynote / session
/ lunch break / coffee break / close up), and a status pill (**Done / ● Live /
Up next**). The user's pick per slot is highlighted (filled check). A session the
user speaks shows a **"🎤 you"** tag; a session with material shows a **📎**.
- **Tap a session** → opens a bottom **sheet** with details (description, speaker,
room, capacity, checked-in state) and actions:
- **Tap a session** → opens a bottom **sheet** with details (description,
speakers, room, capacity, checked-in state) and actions:
- **Give feedback ⭐** — only when the session is *done* **and** the user is
checked in. Opens the Feedback takeover (`openFeedback(sessionId)`).
- **Pick / Remove my pick** — `setPreference(sessionId)` / `clearPreference(slotId)`.
- **Speaker material** — if the user is a speaker of the session and no material
is uploaded yet, a **non-dismissible** "📎 Upload your session material" notice
with a file input. Uploading stores the file in the `materials` bucket and
calls `set_session_material` (via `uploadSessionMaterial`). Once uploaded, the
notice is gone and a **📎 Download material** link appears (visible to **all**
attendees).
- Picking is "one per slot" — picking a new session in a slot replaces the old
pick (enforced by the `set_preference` RPC).
Data: `useEvent()` + `getMyPreferences()` + `getMyCheckins()`.
Data: `useEvent()` + `getMyPreferences()` + `getMyCheckins(email)` +
`getMySpeakerSessions(email)`.
## Scan / Check-in
One screen, two modes (segmented control: **Attendee / Staff**). The default mode
and the tab label are role-aware: staff/admin default to **Staff** mode and the
tab reads **Check-in**.
and the tab label are role-aware: staff (`contact.is_admin`) default to **Staff**
mode and the tab reads **Check-in**.
- **Attendee mode (connect):** scan a peer's lanyard → `lanyardLookup` → a
"Connect with {name}?" sheet → `createConnectionRequest(qr)`. Guards: can't
connect with yourself. Result toast reflects the connection status (sent /
already connected).
"Connect with {name}?" sheet (with the peer's registration-type badge + LinkedIn
link if visible) → `createConnectionRequest(qr)`. Guards: can't connect with
yourself. Result toast reflects the connection status (sent / already connected).
- **Staff mode (check-in):** pick a session (dropdown grouped by slot), then scan
an attendee's lanyard → `checkinAttendee(sessionId, qr)`. Shows a result sheet:
"✓ {name} — Checked in — +10 pts · now {total}" or "⚠️ Already checked in — no
@@ -83,13 +97,16 @@ Data: `useEvent()` (for the session list) + the RPCs above.
Two tabs: **My connections** and **Requests** (with a count badge).
- **My connections** — accepted connections (the other person's name/company).
- **Requests** — incoming (`to_id = me`, pending) with **Accept / Decline**
buttons (`acceptConnection` / `rejectConnection`), and outgoing (`from_id = me`,
pending) shown as "Sent".
- Accepting awards +5 to both (see [../backend/rpcs.md#accept_connectionp_connection_id--connections](../backend/rpcs.md#accept_connectionp_connection_id--connections)).
- **My connections** — accepted connections (the other person's name +
registration type).
- **Requests** — incoming (`to_email = me`, pending) with **Accept / Decline**
buttons (`acceptConnection` / `rejectConnection`), and outgoing (`from_email =
me`, pending) shown as "Sent".
- Accepting awards +5 to both (see
[../backend/rpcs.md#accept_connectionp_connection_id--connections](../backend/rpcs.md#accept_connectionp_connection_id--connections)).
- **Live-ish:** polls every 5s while the tab is visible (`usePolling`).
Data: `getMyConnections()` + `getPublicProfiles()` (to resolve names/companies).
Data: `getMyConnections()` + `getPublicContacts()` (to resolve names + types).
## Feedback
@@ -97,13 +114,10 @@ A **full-screen takeover** (no tab bar), opened from the Agenda session sheet.
- Shows the session (slot · time · room · title).
- **1–5 star** rating + optional comment ("bonus points for details").
- If the user already rated this session, it pre-fills and the button reads
**"Update feedback"** (the RPC updates without re-awarding points).
- On submit: `submitFeedback(sessionId, rating, comment)` → `refreshProfile()` →
a success card ("+N pts earned!" or "Feedback updated!").
- On submit: `submitFeedback(sessionId, rating, comment)` → a success toast
("+N pts ⭐").
Data: `useEvent()` (session/slot) + `getMyFeedback()` (to detect existing) +
`submitFeedback`.
Data: `useEvent()` (session/slot) + `submitFeedback`.
## Leaderboard
@@ -122,17 +136,18 @@ supabase.channel('leaderboard-live')
.subscribe();
```
Data: `getLeaderboard()` (initial + on each realtime event). The `leaderboard`
table is kept in sync transactionally by the RPCs — see
Data: `getLeaderboard()` (the `get_leaderboard()` RPC — initial + on each realtime
event). The `leaderboard` table is kept in sync transactionally by the RPCs — see
[../backend/schema.md#leaderboard--realtime-mirror](../backend/schema.md#leaderboard--realtime-mirror).
## Profile
- **Header** — avatar, name, company, role pill, points pill.
- **My QR code** — renders `profile.qr_token` as a scannable QR (`QrImage`).
- **Header** — avatar, name, email, registration-type pill, a **staff** pill when
`contact.is_admin`, and a points pill.
- **My QR code** — renders `contact.qr_token` as a scannable QR (`QrImage`).
"Show this to staff for check-in and to peers to connect."
- **Points breakdown** — sums `points_log` by category
(Session check-ins / Connections / Feedback / Other) + Total.
- **Log out** — `signOut()`.
Data: `useAuth()` (profile) + `getMyPointsLog()`.
Data: `useAuth()` (contact + registration) + `getMyPointsLog(email)`.
+19 -14
View File
@@ -4,15 +4,16 @@ What's done, what's next, and the open decisions. The full roadmap lives in the
root [`roadmap.md`](../roadmap.md); this file is the working detail for the
current phase.
> **Current state:** Phases 0–2 are complete and verified. The project is now in
> the **Redesign** (Phases 3–6), driven by a new multi-event data model. We work
> through the redesign phase by phase and stop for review at the end of each.
> **Current state:** Phases 0–6 are complete and verified, including the full
> **Redesign** (Phases 3–6) on the new multi-event data model. The next work is
> the **Pretix** (Phase 7) and **Sessionize** (Phase 8) interfaces.
## Done
### Phase 0 — Dockerized Supabase core ✅
- Full schema (9 tables), RLS on every table, transactional points RPCs.
- Seed: 6 slots, 18 sessions, 13 demo users (QR token = auth password).
- Full schema (13 tables), RLS on every table, transactional points RPCs.
- Seed: 1 event, 6 slots, 18 sessions, 14 contacts, 13 registrations, 3 sponsors
(QR token = auth password).
- Runs via the Supabase CLI (`supabase start` / `supabase db reset`).
- Details: [backend/README.md](./backend/README.md).
@@ -40,11 +41,15 @@ A separate desktop-first web app on :3001, guarded to the admin role.
- Details: [frontend/admin-app.md](./frontend/admin-app.md).
> **Note:** Phases 0–2 built the `profiles`-based single-event model. Phase 3
> **replaces** that schema.
> **replaced** that schema; Phase 4 rebuilt this console on the new model and
> rebranded it to **APPE Admin**.
## The Redesign (Phases 3–6)
## The Redesign (Phases 3–6) — ✅ complete
### Phase 3 — Data model 🔨 (in progress)
All four redesign phases are done and browser-verified. The specs below are kept
as the record of what was built.
### Phase 3 — Data model ✅
A new migration (`20260824000000_redesign.sql`) + seed rewrite. The `profiles`
table is dropped; everything is re-scoped to **event + contact**.
@@ -95,9 +100,9 @@ table is dropped; everything is re-scoped to **event + contact**.
- New `materials` storage bucket (read for event attendees, write for
speakers/admins).
### Phase 4 — APPE Admin ⬜
Rebrand "Convivo Admin" → **APPE Admin** (title, sidebar, manifest, docs) and
rebuild the views on the new model:
### Phase 4 — APPE Admin ✅
Rebranded "Convivo Admin" → **APPE Admin** (title, sidebar, manifest, docs) and
rebuilt the views on the new model:
- **Dashboard** — active event card (name, dates, location, aggregates) + top
points + recent activity; graceful "no active event".
- **Contacts** — table (email, name, LinkedIn, visibility toggles, `is_admin`,
@@ -112,7 +117,7 @@ rebuild the views on the new model:
- **Event management** — create event, set active (only one), edit
dates/location.
### Phase 5 — Convivo App ⬜
### Phase 5 — Convivo App ✅
- **Login ≥24h** — `jwt_expiry` = 86400 in `config.toml`; session persists in
localStorage.
- **5s visibility-aware polling** — poll schedule/connections/points every 5s
@@ -129,9 +134,9 @@ rebuild the views on the new model:
- **Browser-accessible** — responsive layout works in a desktop browser.
- **No active event** — graceful empty state.
### Phase 6 — Branding ⬜
### Phase 6 — Branding ✅
- `https://www.appe.at/assets/appe_full.png` as favicon + PWA icon (192/512)
for **both** apps. Update `index.html` + `manifest.webmanifest` + `public/`.
for **both** apps. Updated `index.html` + `manifest.webmanifest` + `public/`.
## Later (post-redesign)