Files
f0f88c2b15 docs: remove credentials from deployment.md + document co-authors
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]>
2026-10-29 22:11:27 +01:00

339 lines
19 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Convivo 🎤
**Turn a conference into a game.** Convivo is a mobile-first web app (PWA) that gets attendees out of their seats: mark the sessions you want, scan lanyards to make connections, get checked in by staff, and climb the live leaderboard. The whole thing runs on a **Dockerized Supabase core** — no custom backend.
> **Status:** Phases 0–6 complete and verified. The **Redesign** (Phases 3–6)
> is done — the new multi-event data model is live, the admin app is **APPE
> Admin**, the Convivo App has all the new behaviors, and both apps carry the
> APPE branding.
>
> - **Phase 0** — Dockerized Supabase core (Postgres + GoTrue + PostgREST + Realtime + Kong + Studio) with the full schema, RLS, and transactional points RPCs.
> - **Phase 1** — Attendee web PWA: login (QR + email), Home, Agenda, Scan/Connect, staff Check-in, Feedback, live Leaderboard, Profile.
> - **Phase 2** — Admin console (desktop-first, admin-role only): Dashboard, Attendees (edit / reset QR / adjust points), Schedule (slots + sessions), Activity.
> - **Phase 3** — Redesign data model: contacts / events / registrations / sponsors, slot types, session speakers + feedback/material.
> - **Phase 4** — APPE Admin: rebrand + Contacts / Registrations / Sponsors / Schedule / Activity / event mgmt.
> - **Phase 5** — Convivo App: 24h login, 5s polling, QR type badge, red dot, speaker material.
> - **Phase 6** — Branding: APPE favicon + icons for both apps.
>
> **Next:** cross-cutting work (deployment, automated testing, push
> notifications). The real event clock is implemented as a per-event
> `use_realtime_clock` toggle (see §4.7). See [`roadmap.md`](./roadmap.md).
---
## 1. The problem
Conferences are full of people who want to meet each other but don't know how to start. Convivo removes the friction:
- **No awkward "hi, I'm…"** — scanning a lanyard QR starts the conversation for you.
- **No FOMO** — you pick one session per slot, so you always know where to be.
- **No invisible networking** — every check-in, connection, and review earns points, and the leaderboard makes it fun.
## 2. Event format
The schedule is **data-driven** (stored in Postgres), so times and sessions can
be changed without an app update. The seed uses the real **Global Power
Platform Bootcamp (Austria)** agenda — 2026-02-20, Vienna — with 10 slots
(7 `session` + 3 `service_session`) and 22 sessions.
> **Demo clock:** by default the app uses a simulated "now" of
> `2026-02-20 10:20` so a slot is *live* — matching the mockup. A per-event
> `use_realtime_clock` flag (toggled in the admin Events view) switches the
> app to the real system clock. See `apps/convivo/src/lib/time.ts`.
## 3. Roles
| Role | What they can do |
|---|---|
| **Attendee** | Log in, view agenda, mark preferences, scan peers to connect, get checked in, give feedback, view leaderboard |
| **Staff** | Everything an attendee can do, **plus** a Check-in mode: pick a session, scan attendee lanyards to check them in |
| **Admin** | Staff powers **plus** full read/write on all event data (used by the Admin console) |
Staff and attendees use the **same app** — the role is the contact's
**registration type** for the active event and changes the Scan tab into a
Check-in tab.
## 4. Features
### 4.1 Login (QR + email)
1. Open the app → **Scan** your own lanyard QR (or type the code).
2. The app resolves the attendee from the QR and asks for your **email to confirm** it's really you.
3. On match → you're in. On mismatch → error, try again.
**How it works:** the QR token is stored as the Supabase Auth **password** and the email as the **identifier**. Login is a standard `signInWithPassword({ email, password: qrToken })` — no custom JWT, no separate backend, and **no email is ever sent** (`enable_confirmations = false`).
### 4.2 Agenda & preferences
- The agenda shows every slot and its parallel sessions (title, room, speaker, description).
- Attendees mark **one preferred session per slot** (they can change their pick until the slot starts).
- Home shows "Now / Next" based on the current time and the user's picks.
### 4.3 Connections (the core loop)
1. While logged in, scan **another person's** lanyard QR.
2. A popup appears: *"Connect with Felix Berger?"*
3. The other person sees the request in **Connections → Requests** and accepts (or rejects).
4. On acceptance, **both** earn points and both see each other in **My connections**.
### 4.4 Session check-in (staff)
- Staff open the Check-in tab, select the session, and scan attendees' lanyards.
- Each successful check-in awards the attendee points.
- Duplicate scans are rejected with a clear message ("Already checked in — no extra points").
### 4.5 Feedback
- After a session ends, attendees who were checked in can rate it **1–5 stars** and optionally leave free text.
- Rating only earns a small bonus; adding comments earns more.
### 4.6 Leaderboard
- All attendees ranked by total points, with a top-3 podium.
- Your own row is highlighted.
- **Live:** the leaderboard table is a Realtime source, so it updates in every open app the moment points change.
### 4.7 Real-time clock toggle
- A per-event `use_realtime_clock` flag (default `false`), toggled in the admin Events view.
- When `false`, the app drives slot status (Live/Next/Done) from a **simulated mid-event clock** so the demo always looks live. When `true`, it uses the **real system clock**.
- The Home header shows a "🎬 Demo clock" badge only in simulated mode.
## 5. Points system
| Action | Points |
|---|---|
| Checked into a session (by staff) | **+10** |
| Connection accepted | **+5 each** (both people) |
| Connection accepted **with a shared talk** | **+`talk_networking_bonus` each** (per event, default 2, `0` = off) |
| Feedback — rating only | **+5** |
| Feedback — rating + free text | **+10 total** |
Points are updated **transactionally** by Postgres RPCs (`security definer`): each RPC updates `registrations.points`, inserts the related row, and re-syncs the `leaderboard` mirror **in a single transaction**. This guarantees the leaderboard is always consistent and that duplicate actions (re-check-in, re-feedback) never double-award.
## 6. Architecture
```mermaid
flowchart LR
subgraph Browser
A["Convivo PWA<br/>React + Vite + TS<br/>(mobile-first, installable)"]
end
subgraph Docker
K["Kong (API gateway)<br/>:54321"]
K --> G["GoTrue (Auth)"]
K --> R["PostgREST"]
K --> RT["Realtime"]
K --> S["Storage"]
R --> P[("Postgres 17<br/>schema · RLS · points RPCs")]
RT --> P
G --> P
end
A -->|"same-origin /auth /rest /realtime"| K
```
**Why no custom backend?** Supabase gives us the whole backend as a managed local stack:
- **Auth** (GoTrue) — QR token as password, email as identifier.
- **Data + logic** (Postgres) — the schema, **Row Level Security**, and the transactional points RPCs live in the database. The app calls RPCs directly; Postgres enforces who can do what.
- **Realtime** — the `leaderboard` table is broadcast to all connected clients.
- **Kong** — a single API gateway fronting everything on one port.
The app talks to Supabase through **same-origin paths** (`/auth`, `/rest`, `/realtime`, `/storage`). In dev, Vite proxies them to the local stack; in Docker, the app's nginx does the same. This avoids CORS entirely.
### App → Supabase connectivity
| Path | Proxied to | Purpose |
|---|---|---|
| `/auth/*` | Kong `:54321` | GoTrue login / session |
| `/rest/*` | Kong `:54321` | PostgREST (tables + RPCs) |
| `/realtime/*` | Kong `:54321` | WebSocket (leaderboard) |
| `/storage/*` | Kong `:54321` | Storage (unused in v1) |
## 7. Data model (Postgres)
The model is **multi-event**: people (`contacts`) register for `events` via
`registrations`, and all activity is scoped to `event_id` + `contact_email`.
| Table | Key fields | Notes |
|---|---|---|
| `contacts` | email (PK), full_name, linkedin_url, show_email, show_linkedin, is_admin, qr_token (unique), external_id | One row per person; mirrors `auth.users` (email + bcrypt(qr_token)); `external_id` reserved for an external system |
| `events` | id, name, start_date, end_date, location, is_active, + aggregates | Partial unique index → at most one active event |
| `registrations` | id, event_id, contact_email, type (attendee/speaker/staff/sponsor), checked_in, points, external_id | Unique (event_id, contact_email); points live here |
| `sponsors` | id, event_id, type, name, email, phone, paid, amount_eur, contact_email | `paid` gates visibility to non-admins |
| `slots` | id, event_id, type (`session`/`service_session` enum), name, slot_date, start_time, end_time | 10 rows in the seed (7 session + 3 service) |
| `sessions` | id, event_id, slot_id, title, description, room, capacity, average_feedback, ai_generated_feedback, material_path, external_id | 22 rows in the seed; `external_id` reserved for an external system |
| `session_speakers` | session_id, contact_email | Join; a session must have ≥1 speaker |
| `preferences` | event_id, contact_email, session_id, slot_id | Unique per (event, contact, slot) — one pick per slot |
| `connections` | event_id, from_email, to_email, status, created_at, resolved_at | Unique per unordered pair (via `least`/`greatest` index) |
| `checkins` | event_id, contact_email, session_id, staff_email, created_at | Unique per (event, contact, session) |
| `feedback` | event_id, contact_email, session_id, rating (1–5), comment, created_at | Unique per (event, contact, session); only after session end |
| `leaderboard` | event_id, contact_email, full_name, points, updated_at | Realtime mirror, kept in sync by the RPCs |
| `points_log` | event_id, contact_email, delta, category, created_at | Audit trail powering the per-category breakdown |
**Key RPCs** (all `security definer`, transactional): `lanyard_lookup`, `get_active_event`, `get_agenda`, `get_public_contacts`, `get_leaderboard`, `set_preference`, `clear_preference`, `create_connection_request`, `accept_connection`, `reject_connection`, `checkin_attendee`, `submit_feedback`, `adjust_points`, `reset_qr_token`, `upsert_contact`, `create_registration`, `set_registration_type`, `evaluate_session_feedback`, `set_session_material`.
**RLS:** every table has policies. Contacts are self-or-admin; sponsors are visible only when `paid` (or to admins); schedule/registrations are readable per active event and writable by admin; the leaderboard is readable by any authenticated user. A `materials` storage bucket holds session materials (read for attendees, write for speakers/admins).
## 8. Tech stack
| Layer | Choice | Why |
|---|---|---|
| Core | **Supabase (local, Docker)** via the Supabase CLI | Postgres + Auth + REST + Realtime + Storage in one managed stack; RLS + RPCs keep logic in the DB |
| App | **React 18 + Vite 5 + TypeScript** (PWA) | Fast, mobile-first, installable; same-origin proxy avoids CORS |
| QR | `html5-qrcode` (scan) + `qrcode.react` (render) | Camera scan with manual-entry fallback |
| Client | `@supabase/supabase-js` | Auth + REST + Realtime in one client |
| Packaging | **Docker** (multi-stage build → nginx) | The app is a sidecar that joins the Supabase network |
## 9. Security
- **No secrets in the app** — only the anon key (public by design) ships in the bundle. The service-role key stays server-side.
- **User login** = QR token + email match via GoTrue; the session JWT is short-lived and stored in `localStorage`.
- **QR tokens are opaque** — scanning a lanyard reveals no personal data by itself.
- **RLS on every table** — the database, not the app, enforces who can read/write what.
- **Transactional points** — RPCs make points + related row + leaderboard sync atomic, so there's no race or double-award.
## 10. Repository layout
```
Convivo/
├─ apps/convivo/ # Attendee web PWA (React + Vite + TS)
│ ├─ Dockerfile # Multi-stage: build → nginx (serves SPA + proxies Supabase)
│ ├─ nginx.conf.template # SPA + same-origin proxy to the Supabase core
│ └─ src/ # screens, components, lib, context
├─ supabase/
│ ├─ config.toml # Local stack config (ports, auth, RLS defaults)
│ ├─ migrations/ # 13 migrations (init → real-time clock toggle)
│ └─ seed.sql # 1 real event (Power Platform Bootcamp AT), 10 slots, 22 sessions, 54 contacts
├─ apps/admin/ # APPE Admin console (React + Vite + TS)
├─ apps/sidecar/ # Sessionize sync sidecar (Node, one dep: xlsx)
├─ docker-compose.yml # Runs the app sidecars on the Supabase network
└─ mockup/index.html # Original interactive mockup (design reference)
```
## 11. Getting started
### Prerequisites
- **Docker** (with the Docker daemon running)
- **Node.js 20+**
- **Supabase CLI** (installed as a devDependency — `npx supabase` works out of the box)
### Option A — Dev (Vite dev server)
```bash
# 1. Start the Supabase core (Postgres, Auth, REST, Realtime, Studio, Kong)
npm run db:start
# 2. (Re)apply migrations + seed, then restart the stack
npm run db:reset
# 3. One-time: provision each app's dev env (git-ignored, never committed)
cp apps/convivo/.env.example apps/convivo/.env
cp apps/admin/.env.example apps/admin/.env
# 4. Run the apps (Vite dev servers, proxy to the core)
npm run app:dev # attendee app on :3000
npm run admin:dev # admin console on :3001
npm run sidecar:dev # Sessionize sync sidecar on :3002
```
Open **http://localhost:3000** (attendee) and **http://localhost:3001** (admin). Studio is at **http://localhost:54323** (user `postgres`, password `postgres`).
> **Blank white page?** You skipped step 3. Without `VITE_SUPABASE_ANON_KEY` the Supabase client throws at load and React renders nothing (the server still answers HTTP 200 — the failure is in the browser console). The `.env` files are git-ignored, so a fresh clone or worktree never has them; the values in `.env.example` are the standard local-stack demo keys and are not secrets. After creating them, restart Vite (env is read only at startup) and hard-refresh the browser (Ctrl+Shift+R).
### Option B — Docker (apps as sidecars)
```bash
# 1. Start the Supabase core (creates the supabase_network_Convivo network)
npm run db:start
# 2. Build + run the app containers + sync sidecar (join the Supabase network)
docker compose up --build
```
Open **http://localhost:3000** (attendee) and **http://localhost:3001** (admin). Each app's nginx proxies the Supabase paths to the Kong container on the shared network; the admin also proxies `/sidecar/` to the sync sidecar (`:3002`).
> **Reset the demo data at any time:** `npm run db:reset` (re-applies migrations + seed).
### Local port map
| Service | URL |
|---|---|
| Attendee app | **http://localhost:3000** |
| Admin console (APPE Admin) | **http://localhost:3001** |
| Sync sidecar (Sessionize) | **http://localhost:3002** (`/health`, `/status`, `/run`) |
| Supabase Studio | **http://localhost:54323** (user `postgres`, password `postgres`) |
| Supabase API (Kong) | http://127.0.0.1:54321 |
| Postgres (direct) | `postgresql://postgres:[email protected]:54322/postgres` |
| SMTP (Mailpit) | http://127.0.0.1:54324 (captures emails; none are sent in this flow) |
> The `appe.at` subdomains (`convivo.appe.at`, `admin.appe.at`, `db.appe.at`) do
> not exist yet — everything runs on **localhost** for now.
## 12. Demo accounts
The seed uses **real data** from the **Global Power Platform Bootcamp (Austria)**:
the real agenda (22 sessions) plus **50 made-up attendees** and **4 staff**.
Speakers are **not** seeded — import them via **Interfaces → Import Excel** (the
Sessionize "Sessions and speakers (advanced)" `.xlsx`).
**Attendees** log in with **QR code** (typed or scanned) + **email** — the QR
token is the password. **Staff** log in with **email + password** in the admin
app (event-independent).
| Person | Role | Login | Email |
|---|---|---|---|
| **Amelia Hernandez** | staff (admin) | **password** `appe-admin-2026` | amelia@appe.at |
| **Sabrina Hota** | staff (admin) | **password** `appe-admin-2026` | sabrina@appe.at |
| **Jose Lago** | staff (admin) | **password** `appe-admin-2026` | jose@appe.at |
| **Markus Franz** | staff (admin) | **password** `appe-admin-2026` | markus@appe.at |
| 50 attendees | attendee | QR `CVV-ATT-1000`…`CVV-ATT-1049` | e.g. lena.huber@gmail.com |
**Suggested demo flow:**
1. Open the **APPE Admin** console on **:3001** → log in as **Amelia** (`[email protected]` / password `appe-admin-2026`) → see the Dashboard (54 registrations, 22 sessions).
2. **Interfaces → Import Excel** → choose the Sessionize `.xlsx` → **Import** → speakers, session links, and speaker registrations are created.
3. **Schedule** → slots show **Session** / **Service Session** types; sessions list their speakers.
4. Log in as an **attendee** on **:3000** (QR `CVV-ATT-1000` + `[email protected]`) → see Home, Agenda, Leaderboard.
5. Scan another attendee → send a connection request; watch the **Leaderboard** update live.
## 13. Roadmap
Full detail in [`roadmap.md`](./roadmap.md).
| Phase | Scope | Status |
|---|---|---|
| **0** | Dockerized Supabase core: schema, RLS, transactional points RPCs, seed | ✅ |
| **1** | Attendee web PWA: login, Home, Agenda, Scan/Connect, Check-in, Feedback, Leaderboard, Profile | ✅ |
| **2** | Admin console (Convivo Admin): Dashboard, Attendees, Schedule, Activity | ✅ |
| **3** | **Redesign — data model**: contacts / events / registrations / sponsors, slot types, session speakers + feedback/material | ✅ |
| **4** | **Redesign — APPE Admin**: rebrand + Contacts / Registrations / Sponsors / Schedule / Activity / event mgmt | ✅ |
| **5** | **Redesign — Convivo App**: 24h login, 5s polling, QR type badge, red dot, speaker material | ✅ |
| **6** | **Redesign — branding**: APPE favicon + icons for both apps | ✅ |
> **Subdomains** (`convivo.appe.at`, `admin.appe.at`, `db.appe.at`) do not exist yet — everything runs on **localhost** for now.
## 14. Out of scope (v1)
- Push notifications (connection requests are seen when the app is opened)
- Multi-day events
## 16. Authors & co-authors
Convivo is developed by **Jose Lago** together with the following co-authors.
Every commit in the repository history carries a `Co-authored-by` trailer for each
of them (added retroactively to all existing commits), and new commits should
include the same trailers.
| Co-author | Email |
|---|---|
| Stephan Charles | stephan@appe.at |
| Amelia Hernandez | amelia@appe.at |
| Markus Franz | markus@appe.at |
| Sabrina Hota | sabrina@appe.at |
| Nilüfer Doğan | nilufer@appe.at |
Trailers to append to every commit message (after a blank line):
```
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]>
```
- Session capacity enforcement
- i18n / offline mode
## 15. Open questions
1. **Schedule times** — the 6 slot times above are an assumption; confirm against the real agenda.
2. **Connection acceptance** — in-app only for v1? (Push notifications would be a later add-on.)