Phase 7+8: Pretix + Sessionize interfaces

- Migration 20260825000000_interfaces.sql: external_id on contacts/
  registrations/sessions (+ partial unique indexes), slots_id_seq, sync_runs
  audit table, and service-role-only sync_pretix_attendees /
  sync_sessionize_sessions RPCs (idempotent upserts).
- sync-trigger Edge Function: admin-JWT or CRON_SECRET auth, pulls from
  Pretix/Sessionize base URLs, normalizes, calls the service-role RPCs.
- interfaces/mock-api: dependency-free Node server (:54330) + fixtures so the
  full pipeline is testable without real tokens.
- APPE Admin 'Interfaces' view: per-source + 'Sync all' triggers, result
  counts, recent sync runs, and QR CSV export; /functions proxy added.
- Docs: new docs/backend/interfaces.md; updated README, roadmap, next-steps,
  schema, rls, rpcs, architecture, admin-app, and docs index.
This commit is contained in:
Lago committed 2026-08-23 03:34:30 +02:00
1 parent 22f5f1d317
commit 16f304d145
26 files changed
+1529 -80

No files matched your search

+52 -36
View File
@@ -4,9 +4,10 @@ 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–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.
> **Current state:** Phases 0–8 are complete and verified. The **Redesign**
> (Phases 3–6) and the **Pretix + Sessionize interfaces** (Phases 7–8) are done.
> Remaining work is cross-cutting (real event clock, deployment, testing) and
> the open questions in [backend/interfaces.md](./backend/interfaces.md).
## Done
@@ -138,40 +139,45 @@ rebuilt the views on the new model:
- `https://www.appe.at/assets/appe_full.png` as favicon + PWA icon (192/512)
for **both** apps. Updated `index.html` + `manifest.webmanifest` + `public/`.
## Later (post-redesign)
## The Interfaces (Phases 7–8) — ✅ complete
### Phase 7 — Pretix interface ⬜
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).
Replaces the hand-written seed with real ticket data.
**Goal:** when someone buys a ticket in Pretix, a contact is created (if it
doesn't exist) and a registration is created using the contact lookup.
- **`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.
Likely scope:
- A **sync job / edge function** (or a small service) that pulls
orders/attendees from the Pretix API and upserts `contacts` +
`registrations` (+ `auth.users`).
- **QR token generation** for each contact (the lanyard token).
- **Type mapping** — which Pretix ticket type maps to
`attendee` / `speaker` / `staff` / `sponsor` (open question).
- **Idempotency** — re-running the sync must not duplicate (key on the Pretix
order/attendee id + email).
- A way to **print/export lanyard QR codes** for the event.
**Open questions:**
1. Which Pretix fields map to registration type and contact?
2. Push (webhook on new order) vs pull (scheduled sync)?
3. Where does the sync job run (Supabase Edge Function vs a separate container)?
### Phase 8 — Sessionize interface ⬜
### Phase 8 — Sessionize interface ✅
Sync the **real agenda** (slots, sessions, speakers, rooms) from
[Sessionize](https://sessionize.com) instead of the hand-written seed.
[Sessionize](https://sessionize.com).
Likely scope:
- A sync job that pulls the event schedule from the Sessionize API and upserts
`slots` + `sessions` + `session_speakers`.
- Map Sessionize track/room/time → our `slots` / `sessions` shape.
- This makes the agenda **data-driven** from the real event.
- 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.
## Cross-cutting / later
@@ -189,11 +195,21 @@ Likely scope:
## Open decisions (need user input)
1. **Pretix type mapping** — which ticket type = speaker/staff/sponsor?
2. **Sync style** — webhook (push) vs scheduled (pull) for Pretix/Sessionize?
3. **Sync runtime** — Supabase Edge Functions vs separate containers?
4. **AI provider** — which LLM/API for `ai_generated_feedback` (Phase 4+)?
5. **Deployment target** — stay on localhost, or plan for the `appe.at`
**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