Service sessions (new slot semantics): - Sidecar maps isServiceSession OR isPlenumSession -> service_session (Excel path also matches 'plenum' in Session Format). - checkin_attendee rejects service sessions; Scan check-in dropdown excludes them. - New _assign_service_session_speakers helper links every registered staff member as a speaker of a service session; both sync RPCs call it (and the API sync now actually types slots from is_service_session). - No material requirement + no mic emoji for service sessions. Home redesign: - Now/Next cards show all concurrent sessions as sub-sections when there's no pick (1/2/3 sessions -> 1/2/3 sub-sections), with a "Nothing scheduled" fallback for empty slots. - My picks today lists every pick (slot order) + empty state. - Demo clock EVENT_DATE fixed to 2026-02-20 (matches seed) so a slot is live at 10:20. Feedback loop: - Attendee pending-feedback pill on Home (checked into an over session, not its speaker, no feedback yet); clears on submit. - Speaker sees rating + AI summary for their own session in the Agenda sheet only after it's over. Migration 20260833000000_service_sessions_feedback.sql. Docs updated. 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]>
137 lines
7.1 KiB
Markdown
137 lines
7.1 KiB
Markdown
# Sidecar — Sessionize sync
|
|
|
|
The **sidecar** is a small Node HTTP service that syncs an event's agenda from
|
|
[Sessionize](https://sessionize.com) into Convivo. It is the only server-side
|
|
component that holds the **service-role key**, and it is driven entirely by the
|
|
APPE Admin **Interfaces** menu — it runs **on demand only** (no scheduling).
|
|
|
|
- Code: [`apps/sidecar/`](../../apps/sidecar/) (single file:
|
|
[`src/server.js`](../../apps/sidecar/src/server.js))
|
|
- Image: [`apps/sidecar/Dockerfile`](../../apps/sidecar/Dockerfile)
|
|
(`node:20-alpine`; one runtime dependency, **`xlsx`**, to parse the Sessionize
|
|
Excel export — everything else is built-in `http` + `fetch`)
|
|
- Compose service: `convivo-sidecar` in the root
|
|
[`docker-compose.yml`](../../docker-compose.yml) (`:3002`)
|
|
- DB side: the `sync_sessionize_event` RPC + `sync_runs` audit table — see
|
|
[rpcs.md](./rpcs.md) and [schema.md](./schema.md)
|
|
|
|
## What it does
|
|
|
|
There are **two import paths**, both on demand:
|
|
|
|
**A. API sync** (`POST /run`) — fetches the event's `sessionize_endpoint` and
|
|
imports, in order: (1) speakers as contacts (matched by **email**), (2) sessions
|
|
(upserted by `external_id`), (3) the agenda/schedule (slots find-or-created by
|
|
date/start/end + `session_speakers` links). The public `/view/` payload has no
|
|
speaker emails, so this path imports sessions + agenda but **skips speakers**
|
|
(unless an authenticated `/api/` endpoint + key is configured).
|
|
|
|
> **Service sessions.** A session is flagged `is_service_session` when
|
|
> Sessionize marks it `isServiceSession` **or** `isPlenumSession` (a plenum is a
|
|
> full-hall item — breaks, lunch, closing, or a plenary — with no individual
|
|
> speaker). The RPC then types its slot `service_session` and links every
|
|
> registered **staff** member as a speaker.
|
|
|
|
**B. Excel import** (`POST /import-excel`) — the admin uploads the Sessionize
|
|
**"Sessions and speakers (advanced)"** `.xlsx` export (generated on the fly by
|
|
any organizer with admin access to the event). The sidecar parses it (two sheets:
|
|
*Accepted sessions* + *Accepted speakers*) and calls the
|
|
`sync_sessionize_excel` RPC, which imports, in order: (1) speakers as contacts
|
|
(matched by **email** — the Excel carries emails, so this is reliable), (2)
|
|
sessions + agenda (slots typed `session` / `service_session` from the
|
|
**Session Format** column — `service`/`break`/`lunch`/`closing`/`plenum` →
|
|
`service_session` — + `session_speakers` links, with every registered **staff**
|
|
member linked as a speaker of service sessions), and (3) **a `speaker`
|
|
registration for every speaker** (create, or update `attendee`→`speaker`; never
|
|
overrides `staff`/`sponsor`). This is the path that creates the missing speaker
|
|
contacts + registrations.
|
|
|
|
Linking a speaker to a session fires the `session_speakers_speaker_promote`
|
|
trigger, which promotes an existing registration to `speaker`.
|
|
|
|
## How it reaches things
|
|
|
|
```mermaid
|
|
flowchart LR
|
|
ADM["convivo-admin<br/>nginx :3001"] -->|"/sidecar/*"| SC["convivo-sidecar<br/>node :3002"]
|
|
SC -->|"service-role key"| K["supabase_kong_Convivo<br/>:8000 (PostgREST)"]
|
|
SC -->|"GET (key optional)"| SZ["Sessionize /view/ or /api/"]
|
|
K --> PG["Postgres 17"]
|
|
```
|
|
|
|
- **Supabase:** PostgREST at `supabase_kong_Convivo:8000` (Kong's internal port
|
|
on the shared network — see [supabase-core.md#ports](./supabase-core.md#ports)),
|
|
authenticated with the **service-role key**.
|
|
- **Sessionize:** the event's stored `sessionize_endpoint`, fetched **as-is**.
|
|
The public `/view/` endpoint needs no key. If `SESSIONIZE_API_KEY` is set it
|
|
is sent as the `X-Sessionize-API-Key` header (harmless for `/view/`, required
|
|
for an `/api/` endpoint).
|
|
|
|
> **Key is optional.** The public `/view/` endpoint (the one stored on the
|
|
> event) returns sessions, speakers, and rooms **without** speaker email
|
|
> addresses. Email is the matching key, so a keyless sync imports sessions +
|
|
> agenda but **skips speakers** (reported in `skipped_speakers`). To import
|
|
> speakers by email, set `SESSIONIZE_API_KEY` and point the event at the
|
|
> authenticated `/api/` endpoint, which returns `email` on each speaker.
|
|
|
|
## HTTP API
|
|
|
|
| Method | Path | Body | Returns |
|
|
|---|---|---|---|
|
|
| `GET` | `/health` | — | `{ ok: true }` (compose healthcheck) |
|
|
| `GET` | `/status` | — | `{ ok, running, lastRun }` |
|
|
| `POST` | `/run` | `{ event_id }` | **blocking** — the API-sync result (summary + errors) |
|
|
| `POST` | `/import-excel` | `multipart/form-data` (`event_id` + `file` = the `.xlsx`) | **blocking** — the Excel-import result (summary + errors) |
|
|
|
|
`/run` is **blocking**: it reads the event's endpoint, fetches Sessionize,
|
|
transforms, calls the RPC, and returns the summary. The admin's "Sync" button and
|
|
the Interfaces "Run sync" both call it and show the result inline.
|
|
|
|
`/import-excel` is **blocking** too: it reads the uploaded `.xlsx` (parsed with
|
|
`xlsx`), transforms the two sheets into the `sync_sessionize_excel` payload, and
|
|
calls that RPC. The admin's Interfaces **"Import Excel"** control posts the file
|
|
here and shows the result inline.
|
|
|
|
## Env vars
|
|
|
|
| Var | Default | Notes |
|
|
|---|---|---|
|
|
| `SUPABASE_URL` | `http://supabase_kong_Convivo:8000` | Where PostgREST lives |
|
|
| `SUPABASE_SERVICE_ROLE_KEY` | standard local service-role JWT | **First server-side holder** of this key (bypasses RLS). Override for a real deployment. |
|
|
| `SESSIONIZE_API_KEY` | *(empty)* | **Optional.** Only needed if the endpoint is an authenticated `/api/` URL. Sent as `X-Sessionize-API-Key` when set. |
|
|
| `PORT` | `3002` | |
|
|
|
|
> **Secrets convention:** the anon key ships in the apps (public by design); the
|
|
> service-role key is **never in the app** and stays server-side. The sidecar is
|
|
> the first consumer of that rule — it holds the key in a container env var,
|
|
> defaulting to the standard local key (overridable), mirroring how the anon key
|
|
> is defaulted inline in compose. See [rls.md](./rls.md).
|
|
|
|
## Running
|
|
|
|
```bash
|
|
# With the rest of the stack (recommended)
|
|
docker compose up --build # brings up convivo-sidecar on :3002
|
|
|
|
# Or just the sidecar, against a running core
|
|
npm run sidecar:dev # node apps/sidecar/src/server.js (SUPABASE_URL -> 127.0.0.1:54321)
|
|
```
|
|
|
|
The admin app reaches the sidecar through the same-origin `/sidecar/` proxy
|
|
(nginx in Docker, Vite in dev) — see [docker.md](./docker.md).
|
|
|
|
## Verified behavior
|
|
|
|
- `GET /health` → `{ ok: true }` (direct `:3002` and via `:3001/sidecar/health`).
|
|
- `POST /run` against a public `/view/` endpoint (no key) → fetches, transforms,
|
|
calls the RPC, and writes sessions/slots (speakers skipped — no emails in the
|
|
public payload — reported in `skipped_speakers`).
|
|
- `POST /run` with `SESSIONIZE_API_KEY` set + an `/api/` endpoint → speakers
|
|
imported by email.
|
|
- `POST /run` with a reachable Sessionize endpoint → fetches, transforms, calls
|
|
the RPC, and writes contacts/sessions/slots/links (idempotent on re-run).
|
|
- `POST /import-excel` with the real "Sessions and speakers (advanced)" export →
|
|
creates the speaker contacts, links them to sessions, and creates/updates their
|
|
`speaker` registrations (idempotent on re-run). Verified: 21 speakers created,
|
|
25 speaker links, 21 speaker registrations, 0 errors.
|