Files
Convivo/docs/frontend/admin-app.md
T
32c86767ef Phase 2: Admin console (admin.appe.at)
A desktop-first React app for organizers, guarded to the admin role.

Backend (supabase/migrations/20260823000000_admin_app.sql):
- Admin-only SELECT policies on preferences, connections, feedback
- reset_qr_token RPC: regenerates a lanyard token, re-hashes it as the
  Auth password (old token stops working), and clears the attendee's
  sessions to force re-login

App (apps/admin, port 3001):
- Login: same QR+email flow, but non-admin sessions are rejected
- Dashboard: live stats + top points + recent activity
- Attendees: search, edit name/company/role, reset QR, adjust points
- Schedule: manage slots + sessions (create/edit/delete)
- Activity: check-ins / connections / feedback tables
- Same-origin proxy (Vite dev / nginx in Docker), same design tokens

Docker + scripts:
- convivo-admin service in docker-compose.yml (:3001)
- admin:dev / admin:build root scripts
- fixed db:reset script (supabase reset -> supabase db reset)

Docs: new frontend/admin-app.md; updated architecture, rls, rpcs,
docker, next-steps, and READMEs.

Verified: build clean, all views + flows browser-tested, Docker build +
proxy + login + admin guard confirmed. DB reset to clean seed.

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-08-22 19:47:22 +02:00

4.0 KiB

Frontend — Admin console

The admin console is a desktop-first single-page React app in 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 / [email protected].

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.
  • 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.

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.