diff --git a/.gitignore b/.gitignore
index ef4468f..31c5ef4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -24,3 +24,6 @@ npm-debug.log*
Thumbs.db
.vscode/
.idea/
+
+# Browser test artifacts
+.playwright-mcp/
diff --git a/README.md b/README.md
index 84ac518..31dce02 100644
--- a/README.md
+++ b/README.md
@@ -2,11 +2,12 @@
**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:** Phase 0 + Phase 1 complete.
+> **Status:** Phase 0 + Phase 1 + Phase 2 complete.
> - **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.
>
-> Next: Phase 2 (Admin app), Phase 3 (Pretix ticketing interface), Phase 4 (Sessionize interface).
+> Next: Phase 3 (Pretix ticketing interface), Phase 4 (Sessionize interface).
---
@@ -43,7 +44,7 @@ The schedule is **data-driven** (stored in Postgres), so times and sessions can
|---|---|
| **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 future Admin app) |
+| **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 an attribute on the profile and changes the Scan tab into a Check-in tab.
@@ -197,20 +198,21 @@ npm run db:start
# 2. (Re)apply migrations + seed, then restart the stack
npm run db:reset
-# 3. Run the app (Vite dev server on :3000, proxies to the core)
-npm run app:dev
+# 3. 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
```
-Open **http://localhost:3000**. Studio is at **http://localhost:54323** (user `postgres`, password `postgres`).
+Open **http://localhost:3000** (attendee) and **http://localhost:3001** (admin). Studio is at **http://localhost:54323** (user `postgres`, password `postgres`).
-### Option B — Docker (app as a sidecar)
+### 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 container on :3000 (joins the Supabase network)
+# 2. Build + run both app containers (joins the Supabase network)
docker compose up --build
```
-Open **http://localhost:3000**. The app's nginx proxies the Supabase paths to the Kong container on the shared network.
+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.
> **Reset the demo data at any time:** `npm run db:reset` (re-applies migrations + seed).
@@ -218,7 +220,8 @@ Open **http://localhost:3000**. The app's nginx proxies the Supabase paths to th
| Service | Port |
|---|---|
-| Convivo app | **3000** |
+| Convivo app (attendee) | **3000** |
+| Convivo admin | **3001** |
| Supabase API (Kong) | 54321 |
| Supabase Studio | 54323 |
| Postgres | 54322 |
@@ -249,6 +252,7 @@ Login = **QR code** (typed or scanned) + **email**. The QR token is the password
2. Scan **Marco** (`CVV-MRC-7712`) → send a connection request.
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.
+5. Open the **admin console** on **:3001** → log in as **Convivo Admin** (`CVV-ADM-0001` / admin@appe.at) → see the Dashboard, reset an attendee's QR, adjust points, and edit the schedule.
## 13. Roadmap
@@ -256,8 +260,8 @@ Login = **QR code** (typed or scanned) + **email**. The QR token is the password
|---|---|---|
| **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 app** (admin.appe.at) — manage attendees, sessions, points, event | ⬜ next |
-| **3** | **Pretix** interface — sync tickets → attendees (QR tokens, roles) | ⬜ |
+| **2** | **Admin app** (admin.appe.at) — manage attendees, sessions, points, event | ✅ |
+| **3** | **Pretix** interface — sync tickets → attendees (QR tokens, roles) | ⬜ next |
| **4** | **Sessionize** interface — sync the real agenda (slots, sessions, speakers) | ⬜ |
> **Subdomains** (`convivo.appe.at`, `admin.appe.at`, `db.appe.at`, `pretix.eu`, `sessionize.com`) do not exist yet — everything runs on **localhost** for now.
diff --git a/apps/admin/.dockerignore b/apps/admin/.dockerignore
new file mode 100644
index 0000000..9b7c8b5
--- /dev/null
+++ b/apps/admin/.dockerignore
@@ -0,0 +1,13 @@
+# Keep the Docker build context small and avoid leaking local state.
+# NOTE: nginx.conf.template and docker-entrypoint.sh are COPYed by the
+# Dockerfile, so they must NOT be excluded here.
+node_modules
+dist
+.env
+.env.*
+!.env.example
+*.tsbuildinfo
+.git
+.gitignore
+Dockerfile
+.dockerignore
diff --git a/apps/admin/.env.example b/apps/admin/.env.example
new file mode 100644
index 0000000..a789941
--- /dev/null
+++ b/apps/admin/.env.example
@@ -0,0 +1,9 @@
+# Convivo Admin — Supabase local stack.
+#
+# Same-origin paths (/auth, /rest, /realtime, /storage) are proxied to the local
+# Supabase stack (Vite dev server in dev, nginx in Docker). So no URL is needed —
+# the client falls back to window.location.origin. Only the anon key is required.
+#
+# VITE_SUPABASE_URL is intentionally left unset (same-origin).
+# The value below is the standard local Supabase anon key (not a secret).
+VITE_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0
diff --git a/apps/admin/Dockerfile b/apps/admin/Dockerfile
new file mode 100644
index 0000000..3b7b9c0
--- /dev/null
+++ b/apps/admin/Dockerfile
@@ -0,0 +1,35 @@
+# Convivo Admin app — multi-stage build.
+#
+# Stage 1 (build): compile the Vite/React/TS app into static assets.
+# Stage 2 (serve): nginx serves the static build and proxies the Supabase
+# same-origin paths (/auth, /rest, /realtime, /storage) to the Supabase core.
+#
+# The Supabase core itself is NOT built here — it runs via the Supabase CLI
+# (`supabase start`) or as a separate container. See the root docker-compose.yml.
+
+# ---- Build stage -------------------------------------------------------------
+FROM node:20-alpine AS build
+WORKDIR /app
+
+# Install deps first for better layer caching (reproducible via lock file).
+COPY package.json package-lock.json ./
+RUN npm ci
+
+# Copy sources and build. The anon key is baked in at build time (it is not a
+# secret — it is the standard local Supabase anon key). Override with
+# --build-arg VITE_SUPABASE_ANON_KEY=... if you use a custom key.
+ARG VITE_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0
+ENV VITE_SUPABASE_ANON_KEY=$VITE_SUPABASE_ANON_KEY
+COPY . .
+RUN npm run build
+
+# ---- Serve stage -------------------------------------------------------------
+FROM nginx:1.27-alpine AS serve
+# nginx template: serve the SPA + proxy Supabase paths to the core. The proxy
+# target is injected at container start (see docker-entrypoint.sh).
+COPY nginx.conf.template /etc/nginx/conf.d/default.conf.template
+COPY docker-entrypoint.sh /docker-entrypoint.sh
+RUN chmod +x /docker-entrypoint.sh
+COPY --from=build /app/dist /usr/share/nginx/html
+EXPOSE 3001
+ENTRYPOINT ["/docker-entrypoint.sh"]
diff --git a/apps/admin/docker-entrypoint.sh b/apps/admin/docker-entrypoint.sh
new file mode 100644
index 0000000..b954f55
--- /dev/null
+++ b/apps/admin/docker-entrypoint.sh
@@ -0,0 +1,19 @@
+#!/bin/sh
+# Convivo Admin app — container entrypoint.
+#
+# Injects the Supabase proxy target into the nginx config template, then starts
+# nginx. The target defaults to the Kong container on the shared Supabase
+# network (supabase_kong_Convivo:8000 — Kong's internal port; 54321 is the
+# host-only mapping). Override with SUPABASE_PROXY_TARGET
+# (e.g. host.docker.internal:54321) if the core is not on the shared network.
+set -eu
+
+TARGET="${SUPABASE_PROXY_TARGET:-supabase_kong_Convivo:8000}"
+TEMPLATE=/etc/nginx/conf.d/default.conf.template
+CONF=/etc/nginx/conf.d/default.conf
+
+echo "[convivo-admin] Proxying Supabase paths to: ${TARGET}"
+sed "s|__SUPABASE_PROXY_TARGET__|${TARGET}|g" "${TEMPLATE}" > "${CONF}"
+
+# Run nginx in the foreground.
+exec nginx -g "daemon off;"
diff --git a/apps/admin/index.html b/apps/admin/index.html
new file mode 100644
index 0000000..e9acdb9
--- /dev/null
+++ b/apps/admin/index.html
@@ -0,0 +1,19 @@
+
+
+
+ );
+}
+
+/** Render a string (e.g. a QR token) as a scannable QR code. */
+export function QrImage({ value, size = 180 }: { value: string; size?: number }) {
+ return (
+
+
+
+ );
+}
+
+/** Small colored badge for a role. */
+export function RoleBadge({ role }: { role: string }) {
+ return {role};
+}
diff --git a/apps/admin/src/context/AuthContext.tsx b/apps/admin/src/context/AuthContext.tsx
new file mode 100644
index 0000000..2979ba3
--- /dev/null
+++ b/apps/admin/src/context/AuthContext.tsx
@@ -0,0 +1,108 @@
+import { createContext, useContext, useEffect, useState, type ReactNode } from 'react';
+import { supabase } from '../lib/supabase';
+import type { Profile } from '../lib/types';
+
+interface AuthState {
+ profile: Profile | null;
+ loading: boolean;
+ signIn: (email: string, qrToken: string) => Promise;
+ signOut: () => Promise;
+}
+
+const AuthContext = createContext(null);
+
+export function AuthProvider({ children }: { children: ReactNode }) {
+ const [profile, setProfile] = useState(null);
+ const [loading, setLoading] = useState(true);
+
+ // On mount: restore any existing session and load the profile. If the
+ // session belongs to a non-admin, sign out immediately (admin-only app).
+ useEffect(() => {
+ let cancelled = false;
+
+ async function init() {
+ const { data } = await supabase.auth.getSession();
+ const session = data.session;
+ if (!session) {
+ if (!cancelled) setLoading(false);
+ return;
+ }
+ const { data: prof } = await supabase
+ .from('profiles')
+ .select('*')
+ .eq('id', session.user.id)
+ .maybeSingle();
+ if (cancelled) return;
+ if (prof && prof.role === 'admin') {
+ setProfile(prof as Profile);
+ } else {
+ // Not an admin — clear the session.
+ await supabase.auth.signOut();
+ }
+ setLoading(false);
+ }
+
+ init();
+
+ const { data: sub } = supabase.auth.onAuthStateChange(async (_event, session) => {
+ if (!session) {
+ setProfile(null);
+ return;
+ }
+ const { data: prof } = await supabase
+ .from('profiles')
+ .select('*')
+ .eq('id', session.user.id)
+ .maybeSingle();
+ if (prof && prof.role === 'admin') {
+ setProfile(prof as Profile);
+ } else {
+ await supabase.auth.signOut();
+ setProfile(null);
+ }
+ });
+
+ return () => {
+ cancelled = true;
+ sub.subscription.unsubscribe();
+ };
+ }, []);
+
+ async function signIn(email: string, qrToken: string) {
+ const { data, error } = await supabase.auth.signInWithPassword({
+ email,
+ password: qrToken,
+ });
+ if (error) throw new Error(error.message);
+
+ const { data: prof } = await supabase
+ .from('profiles')
+ .select('*')
+ .eq('id', data.user.id)
+ .maybeSingle();
+
+ if (!prof || prof.role !== 'admin') {
+ // Signed in, but not an admin — reject and sign out.
+ await supabase.auth.signOut();
+ throw new Error('This account is not an admin.');
+ }
+ setProfile(prof as Profile);
+ }
+
+ async function signOut() {
+ await supabase.auth.signOut();
+ setProfile(null);
+ }
+
+ return (
+
+ {children}
+
+ );
+}
+
+export function useAuth(): AuthState {
+ const ctx = useContext(AuthContext);
+ if (!ctx) throw new Error('useAuth must be used within AuthProvider');
+ return ctx;
+}
diff --git a/apps/admin/src/context/ToastContext.tsx b/apps/admin/src/context/ToastContext.tsx
new file mode 100644
index 0000000..bfde4ad
--- /dev/null
+++ b/apps/admin/src/context/ToastContext.tsx
@@ -0,0 +1,53 @@
+import { createContext, useCallback, useContext, useState, type ReactNode } from 'react';
+
+type ToastKind = 'success' | 'error' | 'info';
+interface Toast {
+ id: number;
+ kind: ToastKind;
+ message: string;
+}
+
+interface ToastState {
+ toasts: Toast[];
+ push: (kind: ToastKind, message: string) => void;
+ dismiss: (id: number) => void;
+}
+
+const ToastContext = createContext(null);
+let nextId = 1;
+
+export function ToastProvider({ children }: { children: ReactNode }) {
+ const [toasts, setToasts] = useState([]);
+
+ const dismiss = useCallback((id: number) => {
+ setToasts((t) => t.filter((x) => x.id !== id));
+ }, []);
+
+ const push = useCallback(
+ (kind: ToastKind, message: string) => {
+ const id = nextId++;
+ setToasts((t) => [...t, { id, kind, message }]);
+ window.setTimeout(() => dismiss(id), 3800);
+ },
+ [dismiss],
+ );
+
+ return (
+
+ {children}
+
+
+ );
+}
+
+function fmtDate(d: string): string {
+ return new Date(d + 'T00:00:00').toLocaleDateString([], { weekday: 'short', month: 'short', day: 'numeric' });
+}
+function fmtTime(t: string): string {
+ return t.slice(0, 5);
+}
diff --git a/apps/admin/src/vite-env.d.ts b/apps/admin/src/vite-env.d.ts
new file mode 100644
index 0000000..4a7a149
--- /dev/null
+++ b/apps/admin/src/vite-env.d.ts
@@ -0,0 +1,10 @@
+///
+
+interface ImportMetaEnv {
+ readonly VITE_SUPABASE_URL: string;
+ readonly VITE_SUPABASE_ANON_KEY: string;
+}
+
+interface ImportMeta {
+ readonly env: ImportMetaEnv;
+}
diff --git a/apps/admin/tsconfig.app.json b/apps/admin/tsconfig.app.json
new file mode 100644
index 0000000..d109555
--- /dev/null
+++ b/apps/admin/tsconfig.app.json
@@ -0,0 +1,21 @@
+{
+ "compilerOptions": {
+ "target": "ES2020",
+ "useDefineForClassFields": true,
+ "lib": ["ES2020", "DOM", "DOM.Iterable"],
+ "module": "ESNext",
+ "skipLibCheck": true,
+ "moduleResolution": "bundler",
+ "allowImportingTsExtensions": true,
+ "resolveJsonModule": true,
+ "isolatedModules": true,
+ "moduleDetection": "force",
+ "noEmit": true,
+ "jsx": "react-jsx",
+ "strict": true,
+ "noUnusedLocals": true,
+ "noUnusedParameters": true,
+ "noFallthroughCasesInSwitch": true
+ },
+ "include": ["src"]
+}
diff --git a/apps/admin/tsconfig.json b/apps/admin/tsconfig.json
new file mode 100644
index 0000000..1ffef60
--- /dev/null
+++ b/apps/admin/tsconfig.json
@@ -0,0 +1,7 @@
+{
+ "files": [],
+ "references": [
+ { "path": "./tsconfig.app.json" },
+ { "path": "./tsconfig.node.json" }
+ ]
+}
diff --git a/apps/admin/tsconfig.node.json b/apps/admin/tsconfig.node.json
new file mode 100644
index 0000000..58d3eed
--- /dev/null
+++ b/apps/admin/tsconfig.node.json
@@ -0,0 +1,13 @@
+{
+ "compilerOptions": {
+ "target": "ES2022",
+ "lib": ["ES2022"],
+ "module": "ESNext",
+ "skipLibCheck": true,
+ "moduleResolution": "bundler",
+ "allowSyntheticDefaultImports": true,
+ "strict": true,
+ "noEmit": true
+ },
+ "include": ["vite.config.ts"]
+}
diff --git a/apps/admin/vite.config.ts b/apps/admin/vite.config.ts
new file mode 100644
index 0000000..7290313
--- /dev/null
+++ b/apps/admin/vite.config.ts
@@ -0,0 +1,20 @@
+import { defineConfig } from 'vite';
+import react from '@vitejs/plugin-react';
+
+// Dev server proxies /auth, /rest, /realtime, /storage to the local Supabase
+// stack so the app can use relative URLs (works in Docker + localhost).
+const SUPABASE_TARGET = 'http://127.0.0.1:54321';
+
+export default defineConfig({
+ plugins: [react()],
+ server: {
+ host: true,
+ port: 3001,
+ proxy: {
+ '/auth': { target: SUPABASE_TARGET, changeOrigin: true },
+ '/rest': { target: SUPABASE_TARGET, changeOrigin: true },
+ '/realtime': { target: SUPABASE_TARGET, changeOrigin: true, ws: true },
+ '/storage': { target: SUPABASE_TARGET, changeOrigin: true },
+ },
+ },
+});
diff --git a/docker-compose.yml b/docker-compose.yml
index e28169e..d421bff 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -9,14 +9,18 @@
# (supabase_network_; here: supabase_network_Convivo) and a Kong
# container (supabase_kong_Convivo) that fronts the API on port 54321.
#
-# This compose file runs the attendee app as a sidecar that JOINS that network
-# and proxies the Supabase same-origin paths to the Kong container.
+# This compose file runs the attendee app (:3000) and the admin app (:3001) as
+# sidecars that JOIN that network and proxy the Supabase same-origin paths to
+# the Kong container.
#
# 1. npm run db:start # start the Supabase core (CLI)
-# 2. docker compose up --build # build + run the app on :3000
+# 2. docker compose up --build # build + run both apps
#
-# Then open http://localhost:3000 and log in with a demo QR code
-# (e.g. CVV-ANA-4821 / ana.silva@nubank.com).
+# Then open:
+# - http://localhost:3000 (attendee app) — log in with a demo QR code
+# (e.g. CVV-ANA-4821 / ana.silva@nubank.com)
+# - http://localhost:3001 (admin app) — log in as admin
+# (CVV-ADM-0001 / admin@appe.at)
name: convivo
@@ -49,6 +53,29 @@ services:
retries: 5
start_period: 10s
+ convivo-admin:
+ build:
+ context: ./apps/admin
+ args:
+ # Standard local Supabase anon key (not a secret). Override if needed.
+ VITE_SUPABASE_ANON_KEY: ${VITE_SUPABASE_ANON_KEY:-eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0}
+ image: convivo-admin:latest
+ container_name: convivo-admin
+ ports:
+ - "3001:3001"
+ environment:
+ # Same proxy target as the attendee app (Kong on the shared network).
+ SUPABASE_PROXY_TARGET: ${SUPABASE_PROXY_TARGET:-supabase_kong_Convivo:8000}
+ networks:
+ - supabase
+ restart: unless-stopped
+ healthcheck:
+ test: ["CMD", "wget", "-qO-", "http://127.0.0.1:3001/"]
+ interval: 15s
+ timeout: 5s
+ retries: 5
+ start_period: 10s
+
networks:
supabase:
# External network created by `supabase start`. Name = supabase_network_.
diff --git a/docs/README.md b/docs/README.md
index 68a921e..c8753a6 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -4,8 +4,8 @@ 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:** Phase 0 (Dockerized Supabase core) + Phase 1 (attendee web PWA)
-> are complete and verified. Phases 2–4 are planned — see
+> **Status:** Phase 0 (Dockerized Supabase core) + Phase 1 (attendee web PWA) +
+> Phase 2 (admin console) are complete and verified. Phases 3–4 are planned — see
> [next-steps.md](./next-steps.md).
## Where things live
@@ -20,11 +20,12 @@ system works*; the root [`README.md`](../README.md) is the quick-start.
| Row Level Security policies | [backend/rls.md](./backend/rls.md) |
| Seed data + demo accounts | [backend/seed.md](./backend/seed.md) |
| Docker (app image + compose) | [backend/docker.md](./backend/docker.md) |
-| **Frontend (attendee PWA) — overview** | [frontend/README.md](./frontend/README.md) |
-| App structure, state, contexts, routing | [frontend/app-structure.md](./frontend/app-structure.md) |
-| Every screen (Login, Home, Agenda, Scan, …) | [frontend/screens.md](./frontend/screens.md) |
+| **Frontend — overview (both apps)** | [frontend/README.md](./frontend/README.md) |
+| Attendee app: structure, state, contexts, routing | [frontend/app-structure.md](./frontend/app-structure.md) |
+| Attendee app: every screen (Login, Home, Agenda, Scan, …) | [frontend/screens.md](./frontend/screens.md) |
| API client (how the app talks to Supabase) | [frontend/api-client.md](./frontend/api-client.md) |
-| **What's next (Phase 2/3/4 + open items)** | [next-steps.md](./next-steps.md) |
+| **Admin console** (views, auth guard, QR reset, points, schedule) | [frontend/admin-app.md](./frontend/admin-app.md) |
+| **What's next (Phase 3/4 + open items)** | [next-steps.md](./next-steps.md) |
## Reading order
@@ -35,6 +36,7 @@ system works*; the root [`README.md`](../README.md) is the quick-start.
[backend/rls.md](./backend/rls.md).
3. **Working on the UI?** Go to [frontend/app-structure.md](./frontend/app-structure.md)
→ [frontend/screens.md](./frontend/screens.md) → [frontend/api-client.md](./frontend/api-client.md).
+ For the admin console, read [frontend/admin-app.md](./frontend/admin-app.md).
4. **Planning the next phase?** Read [next-steps.md](./next-steps.md).
## Conventions
@@ -45,7 +47,9 @@ system works*; the root [`README.md`](../README.md) is the quick-start.
- **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)
- Seed: [`supabase/seed.sql`](../supabase/seed.sql)
- - App source: [`apps/convivo/src/`](../apps/convivo/src/)
+ - Attendee app source: [`apps/convivo/src/`](../apps/convivo/src/)
+ - Admin app source: [`apps/admin/src/`](../apps/admin/src/)
- **Keep it current.** Update the relevant doc in the same change that changes the
behavior it describes.
diff --git a/docs/architecture.md b/docs/architecture.md
index 3730040..c578ce5 100644
--- a/docs/architecture.md
+++ b/docs/architecture.md
@@ -16,14 +16,18 @@ make connections, get checked in by staff, and rate sessions. Every action earns
```mermaid
flowchart LR
- subgraph Browser["Browser (attendee / staff phone)"]
+ subgraph Browser["Browser"]
A["Convivo PWA React 18 + Vite 5 + TS mobile-first, installable"]
+ AD["Convivo Admin React 18 + Vite 5 + TS desktop-first console"]
end
subgraph Docker["Docker (local)"]
subgraph AppC["convivo-app container (:3000)"]
N["nginx serves SPA + proxies Supabase paths"]
end
+ subgraph AdminC["convivo-admin container (:3001)"]
+ NA["nginx serves SPA + proxies Supabase paths"]
+ end
subgraph Core["Supabase core (Supabase CLI)"]
K["Kong API gateway :54321"]
K --> G["GoTrue (Auth)"]
@@ -37,7 +41,9 @@ flowchart LR
end
A -->|"same-origin /auth /rest /realtime /storage"| N
+ AD -->|"same-origin /auth /rest /realtime /storage"| NA
N -->|"proxy (supabase_kong_Convivo:8000)"| K
+ NA -->|"proxy (supabase_kong_Convivo:8000)"| K
```
**Key idea:** there is **no custom backend**. Supabase provides auth, data,
@@ -72,6 +78,16 @@ 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).
+- **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)).
+
## 5. How a request flows (example: staff check-in)
```mermaid
@@ -113,7 +129,8 @@ the work atomically, and the `leaderboard` table change fans out over Realtime.
| Service | Port | Notes |
|---|---|---|
| **Convivo app** | **3000** | Vite dev server (dev) or nginx (Docker) |
-| Supabase API (Kong) | 54321 | The single gateway the app proxies to |
+| **Convivo admin** | **3001** | Vite dev server (dev) or nginx (Docker) |
+| Supabase API (Kong) | 54321 | The single gateway the apps proxy to |
| Supabase Studio | 54323 | UI — login `postgres` / `postgres` |
| Postgres | 54322 | Direct DB access (`postgres` / `postgres`) |
| SMTP (Mailpit) | 54324 | Captures emails (none are sent in this flow) |
@@ -122,9 +139,10 @@ the work atomically, and the `leaderboard` table change fans out over Realtime.
```bash
npm run db:start # start the Supabase core (Docker)
npm run db:reset # (re)apply migrations + seed
-npm run app:dev # dev server on :3000
+npm run app:dev # attendee dev server on :3000
+npm run admin:dev # admin dev server on :3001
# — or —
-docker compose up --build # app as a Docker sidecar on :3000
+docker compose up --build # both apps as Docker sidecars (:3000 + :3001)
```
## 8. The demo clock
@@ -142,11 +160,17 @@ Convivo/
│ ├─ Dockerfile # Multi-stage: build → nginx
│ ├─ nginx.conf.template # SPA + same-origin proxy to the Supabase core
│ └─ src/ # screens, components, lib, context
+├─ apps/admin/ # Admin console (React + Vite + TS, desktop-first)
+│ ├─ Dockerfile # Multi-stage: build → nginx
+│ ├─ nginx.conf.template # SPA + same-origin proxy to the Supabase core
+│ └─ src/ # views, components, lib, context
├─ supabase/
│ ├─ config.toml # Local stack config (ports, auth, RLS defaults)
-│ ├─ migrations/ # 20260822000000_init.sql — schema, RLS, RPCs
+│ ├─ 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
-├─ docker-compose.yml # Runs the app sidecar on the Supabase network
+├─ docker-compose.yml # Runs both app sidecars on the Supabase network
├─ docs/ # ← this documentation
└─ mockup/index.html # Original interactive mockup (design reference)
```
diff --git a/docs/backend/README.md b/docs/backend/README.md
index 0fdde63..5784240 100644
--- a/docs/backend/README.md
+++ b/docs/backend/README.md
@@ -34,5 +34,6 @@ 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)
- Seed: [`supabase/seed.sql`](../../supabase/seed.sql)
- Stack config: [`supabase/config.toml`](../../supabase/config.toml)
diff --git a/docs/backend/docker.md b/docs/backend/docker.md
index 1359ed8..b9e82a2 100644
--- a/docs/backend/docker.md
+++ b/docs/backend/docker.md
@@ -4,12 +4,14 @@ Docker is the backbone. Two pieces:
1. **The Supabase core** — a set of containers managed by the **Supabase CLI**
(not by a compose file in this repo). See [supabase-core.md](./supabase-core.md).
-2. **The app sidecar** — a single container built from
- [`apps/convivo/Dockerfile`](../../apps/convivo/Dockerfile) and orchestrated by
- the root [`docker-compose.yml`](../../docker-compose.yml).
+2. **The app sidecars** — two containers, the attendee app
+ ([`apps/convivo/Dockerfile`](../../apps/convivo/Dockerfile), `:3000`) and the
+ admin console ([`apps/admin/Dockerfile`](../../apps/admin/Dockerfile), `:3001`),
+ orchestrated by the root [`docker-compose.yml`](../../docker-compose.yml).
-The app container **joins the network the CLI created** for the core and proxies
-the Supabase same-origin paths to the Kong container.
+Each app container **joins the network the CLI created** for the core and proxies
+the Supabase same-origin paths to the Kong container. Both use the identical
+multi-stage build + nginx proxy pattern (only the port and build context differ).
## How the pieces fit
@@ -21,10 +23,13 @@ flowchart LR
subgraph Net["supabase_network_Convivo (external)"]
K["supabase_kong_Convivo :8000 (internal)"]
APP["convivo-app nginx :3000"]
+ ADM["convivo-admin nginx :3001"]
end
CLI -.creates.-> Net
APP -->|"proxy /auth /rest /realtime /storage"| K
+ ADM -->|"proxy /auth /rest /realtime /storage"| K
APP -->|"host port 3000"| U["Browser"]
+ ADM -->|"host port 3001"| U
```
## The app image (`apps/convivo/Dockerfile`)
@@ -62,15 +67,17 @@ same-origin paths to the core:
## Root `docker-compose.yml`
-Runs **only the app** (the core is CLI-managed). Key settings:
+Runs **only the apps** (the core is CLI-managed). There are two services —
+`convivo-app` (`:3000`) and `convivo-admin` (`:3001`) — with identical settings
+except the build context and port:
-| Setting | Value | Why |
-|---|---|---|
-| `build.context` | `./apps/convivo` | Builds the app image |
-| `ports` | `3000:3000` | The app on the host |
-| `environment.SUPABASE_PROXY_TARGET` | `supabase_kong_Convivo:8000` (default) | Where nginx proxies |
-| `networks.supabase` | **external**, name `supabase_network_Convivo` | Joins the CLI-created network |
-| `healthcheck` | `wget http://127.0.0.1:3000/` | Container reports healthy |
+| Setting | `convivo-app` | `convivo-admin` | Why |
+|---|---|---|---|
+| `build.context` | `./apps/convivo` | `./apps/admin` | Builds the app image |
+| `ports` | `3000:3000` | `3001:3001` | The app on the host |
+| `environment.SUPABASE_PROXY_TARGET` | `supabase_kong_Convivo:8000` (default) | same | Where nginx proxies |
+| `networks.supabase` | **external**, name `supabase_network_Convivo` | same | Joins the CLI-created network |
+| `healthcheck` | `wget http://127.0.0.1:3000/` | `wget http://127.0.0.1:3001/` | Container reports healthy |
> If you change `project_id` in `supabase/config.toml`, update the external
> network name (`supabase_network_`) and the default proxy target
@@ -85,25 +92,28 @@ npm run db:start
# 2. (Optional) reset to clean seed data
npm run db:reset
-# 3. Build + run the app sidecar on :3000
+# 3. Build + run both app sidecars (:3000 + :3001)
docker compose up --build
```
-Open **http://localhost:3000**.
+Open **http://localhost:3000** (attendee) and **http://localhost:3001** (admin).
### Alternative: dev server (no app container)
-For faster iteration you can skip the app container and use the Vite dev server,
-which proxies the same paths to `127.0.0.1:54321` (host port):
+For faster iteration you can skip the app containers and use the Vite dev
+servers, which proxy the same paths to `127.0.0.1:54321` (host port):
```bash
npm run db:start
-npm run app:dev # Vite on :3000
+npm run app:dev # attendee Vite on :3000
+npm run admin:dev # admin Vite on :3001
```
## Verified behavior
-- `docker compose build` → `npm ci` + `tsc` + `vite build` all pass in-container.
-- `GET /` → HTTP 200 (SPA served by nginx).
+- `docker compose build` → `npm ci` + `tsc` + `vite build` all pass in-container
+ (both `convivo-app` and `convivo-admin`).
+- `GET /` → HTTP 200 (SPA served by nginx) on both `:3000` and `:3001`.
- `GET /auth/v1/health` through the proxy → GoTrue health JSON (proxy works).
-- Full login (QR + email) works through the Docker-served app.
+- Full login (QR + email) works through the Docker-served apps, including the
+ admin console's admin-role guard.
diff --git a/docs/backend/rls.md b/docs/backend/rls.md
index d18e5c2..46ce295 100644
--- a/docs/backend/rls.md
+++ b/docs/backend/rls.md
@@ -37,13 +37,18 @@ Two `security definer` functions drive role checks (see [rpcs.md](./rpcs.md#role
| `profiles` | own **or** admin | — | admin only | admin only |
| `slots` | all authenticated | admin only | admin only | admin only |
| `sessions` | all authenticated | admin only | admin only | admin only |
-| `preferences` | own (`profile_id = auth.uid()`) | — | — | — |
-| `connections` | rows you're in (`from_id` or `to_id` = you) | — | — | — |
+| `preferences` | own **or** admin | — | — | — |
+| `connections` | rows you're in **or** admin | — | — | — |
| `checkins` | own **or** staff/admin | — | — | — |
-| `feedback` | own | — | — | — |
+| `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
@@ -89,6 +94,12 @@ create policy "leaderboard_select_all" on public.leaderboard for select to authe
-- 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());
```
## GRANTs
@@ -113,9 +124,10 @@ full DML at the Postgres level, but **RLS narrows it** to the policies above.
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, and the only role with **direct** write
- access to `profiles` / `slots` / `sessions` (this is what the future Admin app
- in Phase 2 will use).
+- **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.
## Things to revisit later
diff --git a/docs/backend/rpcs.md b/docs/backend/rpcs.md
index 87b9ed1..8c52f9f 100644
--- a/docs/backend/rpcs.md
+++ b/docs/backend/rpcs.md
@@ -104,8 +104,28 @@ Post-session feedback.
- Otherwise inserts and awards `earned` (category `feedback`).
### `adjust_points(p_profile_id, p_delta, p_reason)` → `void`
-**Admin-only** manual points adjustment (category `admin`). Used by the future
-Admin app (Phase 2).
+**Admin-only** manual points adjustment (category `admin`). Used by the Admin
+console (Phase 2) 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.
+- 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
+> `extensions` schema (not `public`), so the function — whose `search_path` is
+> pinned to `public` — must qualify them as `extensions.gen_salt(...)` /
+> `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).
## Role helper functions
diff --git a/docs/frontend/README.md b/docs/frontend/README.md
index cb1dac5..897c0fa 100644
--- a/docs/frontend/README.md
+++ b/docs/frontend/README.md
@@ -1,15 +1,22 @@
-# Frontend — Attendee PWA
+# Frontend
-The frontend is a **mobile-first single-page React app** (PWA) in
-[`apps/convivo/`](../../apps/convivo/). It is 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).
+There are **two** React apps, both talking to the same Supabase core through
+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
+ [admin-app.md](./admin-app.md).
| File | What it covers |
|---|---|
-| [app-structure.md](./app-structure.md) | Entry, contexts, the event hook, the tab shell, the demo clock |
-| [screens.md](./screens.md) | Every screen: Login, Home, Agenda, Scan/Check-in, Connections, Feedback, Leaderboard, Profile |
+| [app-structure.md](./app-structure.md) | Attendee app: entry, contexts, the event hook, the tab shell, the demo clock |
+| [screens.md](./screens.md) | Attendee app: Login, Home, Agenda, Scan/Check-in, Connections, Feedback, Leaderboard, Profile |
| [api-client.md](./api-client.md) | The typed API wrapper + how the app talks to Supabase (auth, REST, realtime) |
+| [admin-app.md](./admin-app.md) | Admin console: views, the admin auth guard, QR reset, points, schedule |
## Tech
diff --git a/docs/frontend/admin-app.md b/docs/frontend/admin-app.md
new file mode 100644
index 0000000..0049937
--- /dev/null
+++ b/docs/frontend/admin-app.md
@@ -0,0 +1,90 @@
+# Frontend — Admin console
+
+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.
+
+It runs on **port 3001** (Vite dev) or as the `convivo-admin` Docker container
+(nginx). The attendee app stays on 3000.
+
+## What it does
+
+| 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. |
+
+## 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:
+
+- If `role === 'admin'` → 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.
+
+The demo admin is `CVV-ADM-0001` / `admin@appe.at`.
+
+## Source layout
+
+```
+apps/admin/src/
+├─ main.tsx # ReactDOM entry
+├─ 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
+│ └─ ToastContext.tsx # transient toasts
+├─ lib/
+│ ├─ supabase.ts # createClient (same-origin)
+│ ├─ api.ts # typed wrapper: reads + updateProfile / adjustPoints / resetQrToken
+│ └─ types.ts # TS types mirroring the DB
+├─ components/
+│ └─ ui.tsx # Avatar, Spinner, Empty, Modal, QrImage, RoleBadge
+├─ 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
+```
+
+## Data access
+
+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).
+
+### 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.
+
+### Adjusting points
+
+`adjust_points(profile_id, 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.
+
+## 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.
diff --git a/docs/next-steps.md b/docs/next-steps.md
index 32210f6..277a144 100644
--- a/docs/next-steps.md
+++ b/docs/next-steps.md
@@ -8,10 +8,10 @@ interface → **4** Sessionize interface.
> sync), and the Pretix interface is **Phase 3**. (Originally the whiteboard had
> Pretix as Phase 2 and the admin app as Phase 3.)
-> **Current state:** Phase 0 + Phase 1 are **complete and verified** (browser-
-> tested end-to-end, Docker-verified, pushed to `git.lago.dev/Lago/Convivo.git`).
-> Per the working agreement, we **stop here** and let the user evaluate before
-> starting Phase 2.
+> **Current state:** Phase 0 + Phase 1 + Phase 2 are **complete and verified**
+> (browser-tested end-to-end, Docker-verified, pushed to
+> `git.lago.dev/Lago/Convivo.git`). Per the working agreement, we **stop here**
+> and let the user evaluate before starting Phase 3 (Pretix).
## Done
@@ -29,22 +29,27 @@ interface → **4** Sessionize interface.
- All flows browser-tested; Docker build + proxy + login verified.
- Details: [frontend/README.md](./frontend/README.md).
-## Next
-
-### Phase 2 — Admin app (admin.appe.at) ⬜ (next)
-A separate web app for event organizers, using the **admin** role (which already
-has direct write access to `profiles` / `slots` / `sessions` via RLS — see
+### Phase 2 — Admin app (admin.appe.at) ✅
+A separate desktop-first web app for event organizers, using the **admin** role
+(which has direct write access to `profiles` / `slots` / `sessions` via RLS — see
[backend/rls.md](./backend/rls.md)).
-Likely scope:
-- Manage **attendees** (view, edit role/company, reset QR, adjust points via
- `adjust_points`).
-- Manage **schedule** (slots + sessions) — create/edit/delete.
-- **Live overview** — who's checked in, connection activity, leaderboard.
-- Reuse the same Supabase core + anon/service key pattern; a new `apps/admin`
- PWA.
+- **Login** — same QR + email flow, but guarded: non-admin accounts are signed
+ out and rejected ("This account is not an admin").
+- **Dashboard** — live stats (attendees, check-ins, connections, avg rating,
+ sessions) + 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).
-### Phase 3 — Pretix interface ⬜
+## Next
+
+### Phase 3 — Pretix interface ⬜ (next)
Sync **tickets → attendees** from [Pretix](https://pretix.eu) (the ticketing
system). This replaces the hand-written seed with real ticket data.
@@ -96,8 +101,7 @@ Likely scope:
1. **Pretix role mapping** — which ticket type = staff/admin?
2. **Sync style** — webhook (push) vs scheduled (pull) for Pretix/Sessionize?
3. **Sync runtime** — Supabase Edge Functions vs separate containers?
-4. **Admin app scope** — which admin features are must-haves for the event?
-5. **Deployment target** — stay on localhost, or plan for the `appe.at`
+4. **Deployment target** — stay on localhost, or plan for the `appe.at`
subdomains now?
## How to pick up work
diff --git a/package.json b/package.json
index 37cde1b..2241201 100644
--- a/package.json
+++ b/package.json
@@ -6,10 +6,12 @@
"scripts": {
"db:start": "supabase start",
"db:stop": "supabase stop",
- "db:reset": "supabase reset",
+ "db:reset": "supabase db reset",
"db:types": "supabase gen types typescript --local > packages/shared/src/database.types.ts",
"app:dev": "npm --prefix apps/convivo run dev",
- "app:build": "npm --prefix apps/convivo run build"
+ "app:build": "npm --prefix apps/convivo run build",
+ "admin:dev": "npm --prefix apps/admin run dev",
+ "admin:build": "npm --prefix apps/admin run build"
},
"devDependencies": {
"supabase": "^2.28.1"
diff --git a/supabase/migrations/20260823000000_admin_app.sql b/supabase/migrations/20260823000000_admin_app.sql
new file mode 100644
index 0000000..3404f33
--- /dev/null
+++ b/supabase/migrations/20260823000000_admin_app.sql
@@ -0,0 +1,79 @@
+-- =============================================================================
+-- Convivo — Phase 2 (Admin app): admin read access + QR reset RPC
+--
+-- The admin app (apps/admin) needs to:
+-- 1. Read ALL profiles, preferences, connections, feedback, checkins,
+-- points_log (a full event overview), not just the admin's own rows.
+-- 2. Reset an attendee's QR token (which doubles as their auth password),
+-- forcing them to re-login with the new lanyard code.
+--
+-- This migration adds the missing admin SELECT policies and a single
+-- admin-only RPC. It does NOT change any existing policy.
+-- =============================================================================
+
+-- -----------------------------------------------------------------------------
+-- ADMIN READ POLICIES
+-- (profiles, checkins, points_log, leaderboard already allow admin/all reads.)
+-- -----------------------------------------------------------------------------
+
+-- preferences: admin can read everyone's picks
+create policy "prefs_select_admin" on public.preferences for select to authenticated
+ using (public.is_admin());
+
+-- connections: admin can read all connections (event overview)
+create policy "conn_select_admin" on public.connections for select to authenticated
+ using (public.is_admin());
+
+-- feedback: admin can read all feedback
+create policy "feedback_select_admin" on public.feedback for select to authenticated
+ using (public.is_admin());
+
+-- -----------------------------------------------------------------------------
+-- reset_qr_token(p_profile_id) — admin only
+--
+-- Regenerates the attendee's QR token, syncs it into auth.users as the new
+-- bcrypt password (the QR token IS the login password), and clears their
+-- existing sessions so they must re-login with the new code.
+--
+-- security definer: runs as the table owner (postgres), which has write access
+-- to both public.profiles and auth.* (verified).
+-- -----------------------------------------------------------------------------
+create or replace function public.reset_qr_token(p_profile_id uuid)
+returns table (profile_id uuid, qr_token text)
+language plpgsql security definer set search_path = public as $$
+declare
+ v_uid uuid := auth.uid();
+ v_token text;
+ v_salt text;
+begin
+ if v_uid is null then raise exception 'not authenticated'; end if;
+ if not public.is_admin() then raise exception 'admin only'; end if;
+
+ if not exists (select 1 from public.profiles where id = p_profile_id) then
+ raise exception 'profile not found';
+ end if;
+
+ -- Generate a fresh, human-friendly token: CVV-XXX-NNNN
+ v_token := 'CVV-' || upper(substr(md5(random()::text), 1, 3)) || '-' ||
+ lpad((floor(random() * 10000))::int::text, 4, '0');
+
+ -- Update the profile (source of truth for the lanyard).
+ update public.profiles set qr_token = v_token where id = p_profile_id;
+
+ -- Sync the auth password so the new token works for login.
+ -- (pgcrypto's gen_salt/crypt live in the `extensions` schema — qualify them,
+ -- since this function's search_path is pinned to `public`.)
+ v_salt := extensions.gen_salt('bf');
+ update auth.users
+ set encrypted_password = extensions.crypt(v_token, v_salt),
+ updated_at = now()
+ where id = p_profile_id;
+
+ -- Force re-login: drop the user's existing sessions.
+ delete from auth.sessions where user_id = p_profile_id;
+
+ return query select p_profile_id, v_token;
+end;
+$$;
+
+grant execute on function public.reset_qr_token(uuid) to authenticated;