# Next Steps 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–8 are complete and verified, plus two polish > rounds: **Fixes & Refinements** (QR token moved to the registration, role-pill > capitalization, connection detail sheet + red-dot recalc, admin schedule > speaker multi-select + upload/speaker bug fixes, sponsor contact search) and > **Admin password + profile self-service** (admin logs in with email + password; > attendees set LinkedIn + visibility on their Profile). > Remaining work is cross-cutting (real event clock, deployment, testing) and > the open questions in [backend/interfaces.md](./backend/interfaces.md). ## Done ### Phase 0 — Dockerized Supabase core ✅ - 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). ### Phase 1 — Attendee web PWA ✅ - Login (QR + email, no email sent), Home, Agenda, Scan/Connect, staff Check-in, Feedback, live Leaderboard, Profile. - Same-origin proxy to Supabase (Vite dev / nginx in Docker). - Docker: multi-stage build → nginx sidecar on the Supabase network. - All flows browser-tested; Docker build + proxy + login verified. - Details: [frontend/README.md](./frontend/README.md). ### Phase 2 — Admin console (Convivo Admin) ✅ A separate desktop-first web app on :3001, guarded to the admin role. - **Login** — same QR + email flow, but guarded: non-admin accounts are signed out and rejected ("This account is not an admin"). - **Dashboard** — live stats + top points + recent activity. - **Attendees** — searchable table; edit name/company/role, view + **reset QR token** (new `reset_qr_token` RPC), **adjust points** (via `adjust_points`). - **Schedule** — manage slots + sessions (create/edit/delete). - **Activity** — check-ins, connections, and feedback tables. - Same-origin proxy to Supabase (Vite dev on :3001 / nginx in Docker). - Docker: `convivo-admin` service on :3001, same network + proxy pattern. - All views + flows browser-tested; Docker build + proxy + login verified. - Details: [frontend/admin-app.md](./frontend/admin-app.md). > **Note:** Phases 0–2 built the `profiles`-based single-event model. Phase 3 > **replaced** that schema; Phase 4 rebuilt this console on the new model and > rebranded it to **APPE Admin**. ## The Redesign (Phases 3–6) — ✅ complete 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**. **New tables** - **contacts** (PK = `email`): `full_name`, `linkedin_url` (null), `show_email` / `show_linkedin` (visibility toggles, default off), `is_admin` (default false), `qr_token` (unique — the login password), `created_at`. Mirrors `auth.users` (email + bcrypt(qr_token) in `encrypted_password`). - **events**: `id`, `name`, `start_date`, `end_date`, `location`, `is_active` (partial unique index → at most one active), + maintained aggregate columns: `avg_feedback`, `num_sessions`, `num_speakers`, `num_registrations`, `num_checked_in_registrations`. - **registrations**: `id`, `event_id`, `contact_email`, `type` (`attendee|speaker|staff|sponsor`, default `attendee`), `checked_in` (default false). Unique `(event_id, contact_email)`. `sponsor` type only allowed if a sponsor lookup is filled (enforced in RPC/trigger). - **sponsors**: `id`, `event_id`, `type` (`headline|platinum|gold|silver|community|swag|catering|diversity`), `name`, `email`, `phone`, `paid` (default false — unpaid hidden from the list), `amount_eur`, `contact_email` (nullable lookup), `created_at`. **Changed tables** - **slots**: + `event_id`, + `type` (`session|lunch_break|coffee_break|keynote|close_up`). - **sessions**: + `event_id`, + `average_feedback` (numeric, null), + `ai_generated_feedback` (text), + `material_path` (text, null — storage object path). - **session_speakers** (new join): `session_id` + `contact_email`, PK on both. A session must have ≥1 speaker (trigger). - **preferences / connections / checkins / feedback / leaderboard / points_log**: re-scoped to `event_id` + `contact_email` (replacing `profile_id`). - **Drop**: `profiles`. **RPCs** - New: `get_active_event()`, `upsert_contact` (create-if-not-exists by email — the interface flow), `create_registration` (contact lookup; enforces sponsor rule), `set_registration_type`, `evaluate_session_feedback` (admin stub). - Updated: `submit_feedback` (recalc `session.average_feedback` + set `ai_generated_feedback` state + event avg), `checkin_attendee` (guard = `contact.is_admin`), `lanyard_lookup` (contact + registration type for the active event, respecting visibility toggles), `reset_qr_token` (on contact), `adjust_points` (per event/registration). **RLS + storage** - Rewrite policies for the new tables. Contacts: own or `is_admin`. Sponsors: only `paid = true` visible to non-admins. Schedule/registrations readable per active event; admin writes. - New `materials` storage bucket (read for event attendees, write for speakers/admins). ### 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`, QR token); edit; reset QR; toggle `is_admin`; set visibility. - **Registrations** — per active event; list (contact, type, checked-in); change type (enforce 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 (speakers 1:N, material upload, `average_feedback`, `ai_generated_feedback` + "Evaluate" stub button). - **Activity** — check-ins / connections / feedback (per active event). - **Event management** — create event, set active (only one), edit dates/location. ### 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 only while `document.visibilityState === 'visible'`; no background polling. - **Staff-only check-in** — guard = `contact.is_admin`. - **QR type badge** — scanning a peer shows their registration type (Attendee/Speaker/Sponsor/Staff). - **Pending-connection red dot** — subtle red dot (top-right) on the Connect box when there are pending incoming requests (`active` class/id). - **Speaker material** — speakers see a subtle non-dismissible notification until material is uploaded; upload in-app (to `materials`); once uploaded the notification disappears and the material is downloadable by **all** event attendees (not just check-ins). - **Browser-accessible** — responsive layout works in a desktop browser. - **No active event** — graceful empty state. ### Phase 6 — Branding ✅ - `https://www.appe.at/assets/appe_full.png` as favicon + PWA icon (192/512) for **both** apps. Updated `index.html` + `manifest.webmanifest` + `public/`. ## The Interfaces (Phases 7–8) — ✅ complete Both external interfaces are built and browser-verified end-to-end (against the local mock API). Full detail: [backend/interfaces.md](./backend/interfaces.md). ### Phase 7 — Pretix interface ✅ Sync **tickets → contacts + registrations** from [Pretix](https://pretix.eu). - **`sync-trigger` Edge Function** pulls `GET /pretix/attendees`, normalizes, and calls the service-role-only `sync_pretix_attendees(jsonb)` RPC. - **Upserts** `contacts` (by email) + `registrations` (by event + contact) + `auth.users` (QR token = password). **Generates a QR token** for new ticket holders so they can log in. - **Type mapping** — `_map_ticket_type` maps the Pretix ticket type to `attendee` / `speaker` / `staff` / `sponsor` (substring match; sponsor auto-creates a sponsor row). - **Idempotent** — keyed on `external_id` (Pretix order code) + email; re-runs update in place. - **QR export** — the APPE Admin **Interfaces** view exports a CSV of lanyard QR codes for the active event. ### Phase 8 — Sessionize interface ✅ Sync the **real agenda** (slots, sessions, speakers, rooms) from [Sessionize](https://sessionize.com). - The same Edge Function pulls `GET /sessionize/sessions` and calls the service-role-only `sync_sessionize_sessions(jsonb)` RPC. - **Slots** are matched/created by `(event, date, start, end)`; **sessions** are upserted by `external_id` (Sessionize id); **speakers** are upserted as contacts + `session_speakers` links. - **Idempotent** — keyed on `external_id`; re-runs update in place. ### Shared plumbing (both phases) - **`sync_runs`** audit table (admin-only read) records every run; the Interfaces view shows the last 8. - **`mock-api`** Docker service (`interfaces/mock-api/`, :54330) serves the real API shapes from fixtures so the pipeline is testable without credentials. - **Auth** — the Edge Function accepts an admin JWT (verified via `is_admin()`) or a `CRON_SECRET` header for scheduled runs. ## Fixes & Refinements — ✅ complete A cross-cutting polish round (migration `20260826000000_registration_qr_token.sql` + app changes), all browser-verified. **Datamodel — QR token moves from `contacts` to `registrations`.** - The token is a property of the **registration** (generated per event by Pretix), not the contact. `contacts.qr_token` is dropped; `registrations.qr_token` is added (partial unique index `registrations_qr_token_uniq`). - `lanyard_lookup`, `create_connection_request`, and `checkin_attendee` now resolve tokens via `registrations` + the active event. - `reset_qr_token(contact)` is replaced by `reset_registration_qr_token(email)` (admin-only; regenerates the active-event registration's token + re-hashes the Auth password + clears sessions). `upsert_contact` no longer takes a token; `create_registration` generates one and syncs it as the password. - The Pretix sync writes the token to the **registration** (keeps the existing token on re-sync so a lanyard is never invalidated). **Registration types.** - Type pills have **distinct colors**; **red is reserved for Staff** (both apps). - Roles are shown **capitalized** in both apps (Attendee / Speaker / Sponsor / Staff). "Attendee" is **not shown at the bottom** of the Home screen (it's the default); it *is* shown (capitalized) on Profile, Login, Scan, and Connections. - The **reset-token button is removed from the Contacts view** (meaningless now that the token lives on the registration) and moved to the **Registrations** view (per-registration QR + reset). **Sessions (APPE Admin).** - Slot types are shown **capitalized** (Session, Keynote, Lunch Break, …). - The session list shows whether material was **submitted / not submitted**. - Speaker selection is a **multi-select search dropdown** (search + chips), replacing the checkbox list. - **Fixed:** editing a session no longer fails with "a session must have a speaker" — `setSessionSpeakers` now **diffs** (insert the new set, then delete only the removed ones) instead of delete-all-then-insert, so the `session_needs_speaker` trigger (which counts the row being deleted) never fires. This also **fixes the file-upload bug** (the speaker save no longer aborts before the material upload runs). **APPE Admin — Sponsors.** - The sponsor **contact lookup is a search field** (filter + click-to-pick), not a dropdown of all contacts. **Convivo App.** - **Other people's QR codes are hidden** — the connection detail sheet shows public info + points only (no QR). - **Connect red dot** — any interaction with the connection logic (accept / decline / send) dispatches a `connections-changed` event; the Shell recalculates the dot **immediately** (stays while any incoming request is pending, clears when none are). 5s polling remains as a fallback. - **Connect menu** — clicking any connection (connected or requested) opens a sheet with that person's **public info + their points**. - **"My picks today"** — shows only **2 rows** (current + next slot's pick); "tap to change" is a **hyperlink** to the Agenda. ## Admin password + profile self-service — ✅ complete Migration `20260827000000_admin_password_profile.sql` + app changes, all browser-verified. **APPE Admin login = email + password (event-independent).** - `contacts.password` (admin-only) records the APPE Admin login password. To work it must match the bcrypt hash in `auth.users.encrypted_password` — set directly in Supabase (no self-service UI/procedure). - The admin app's Login screen is now **Email + Password** (was QR token). `AuthContext.signIn(email, password)` still calls `signInWithPassword` + the `is_admin` guard. - **Design decision:** Supabase Auth has one password per user. The dedicated admin uses a real password (works for any event). Staff (Bruno/Rita) keep their QR tokens as their Auth password — they can still log into the attendee app, and can also open the admin app with email + QR token. - Seed: the admin's password is `appe-admin-2026` (in both `contacts.password` and `auth.users.encrypted_password`); all other contacts have `password = NULL`. **Convivo App — Profile self-service.** - New **Profile settings** card: a **LinkedIn** URL input + two **visibility toggles** ("Show my email" / "Show my LinkedIn") + **Save profile**. - Saving calls the new `update_my_profile(p_linkedin_url, p_show_email, p_show_linkedin)` RPC (security-definer, scoped to `current_email()`, limited to those 3 columns) — needed because the `contacts` UPDATE policy is admin-only, so an attendee can't update their own row via PostgREST. - Visibility is enforced **server-side**: the public projection (`lanyard_lookup` / `get_public_contacts`) nulls `linkedin_url` when `show_linkedin` is off and omits the email when `show_email` is off, so the toggles actually control what other attendees see. ## Cross-cutting / later - **Real event clock** — replace the simulated `DEFAULT_NOW` ([frontend/app-structure.md#the-event-clock](./frontend/app-structure.md#the-event-clock)) with `new Date()` for the live event. - **Subdomains** — `convivo.appe.at`, `admin.appe.at`, `db.appe.at` don't exist yet; everything is on localhost. DNS + TLS + a reverse proxy in front of the Supabase core will be needed for a real deployment. - **Push notifications** — connection requests are currently seen when the app is opened. (Out of scope for v1.) - **Testing** — no automated tests yet. Candidates: RPC unit tests (points idempotency, role guards), and an E2E smoke test (login → check-in → leaderboard). ## Open decisions (need user input) **Resolved in Phases 7–8:** - **Sync runtime** — Supabase **Edge Function** (`sync-trigger`), not a separate container. Keeps the "no custom backend" philosophy. - **Sync style** — **pull** (on-demand from the APPE Admin Interfaces view + cron-ready via `CRON_SECRET`). Webhooks are a later add-on. - **Credentials** — env-configured (`PRETIX_*` / `SESSIONIZE_*`), with a local **mock API** for testing. Real tokens are set as Edge Function secrets. **Still open:** 1. **Pretix type mapping** — confirm the ticket-type → registration-type mapping (the substring matcher is a reasonable default). 2. **Sync cadence** — how often to pull (pre-event vs during the event)? 3. **AI provider** — which LLM/API for `ai_generated_feedback` (the admin "Evaluate" button is still a stub). 4. **Deployment target** — stay on localhost, or plan for the `appe.at` subdomains now? ## How to pick up work 1. Read [architecture.md](./architecture.md) for the system overview. 2. For a phase, read the relevant component docs (backend or frontend) and the source of truth files they link to. 3. Keep the docs updated in the same change that changes behavior (see the conventions in [README.md](./README.md)).