Files
Convivo/docs/backend/supabase-core.md
T
Lago 22f5f1d317 Redesign Phases 3-6: multi-event model, APPE Admin, Convivo App behaviors, APPE branding
- Phase 3: new migration 20260824000000_redesign.sql (contacts/events/registrations/sponsors, slot types, session speakers + feedback/material), seed rewrite
- Phase 4: APPE Admin rebrand + Contacts/Registrations/Sponsors/Schedule/Activity/Events views
- Phase 5: Convivo App (24h login, 5s polling, QR type badge, red dot, speaker material)
- Phase 6: APPE favicon + PWA icons for both apps
- Docs: schema/rpcs/rls/seed/screens/api-client/admin-app/architecture/next-steps/README/roadmap updated
2026-08-23 02:53:16 +02:00

92 lines
4.1 KiB
Markdown

# Supabase Core — Local Stack
The Supabase core is a set of Docker containers managed by the **Supabase CLI**
(installed as a root devDependency — `npx supabase` works out of the box). It is
the "main docker" of the project.
## Containers
`supabase start` brings up the full local stack (project id `Convivo`):
| Container | Image | Role |
|---|---|---|
| `supabase_db_Convivo` | `supabase/postgres:17` | Postgres 17 — schema, RLS, RPCs, data |
| `supabase_auth_Convivo` | `supabase/gotrue` | Auth (QR + email login) |
| `supabase_rest_Convivo` | `supabase/postgrest` | REST API over Postgres (tables + RPCs) |
| `supabase_realtime_Convivo` | `supabase/realtime` | WebSocket realtime (leaderboard) |
| `supabase_storage_Convivo` | `supabase/storage-api` | Storage — the `materials` bucket (session material) |
| `supabase_kong_Convivo` | `supabase/kong` | **API gateway** — fronts everything on one port |
| `supabase_studio_Convivo` | `supabase/studio` | Web UI (Studio) |
| `supabase_inbucket_Convivo` | `supabase/mailpit` | Captures emails (none sent in this flow) |
| `supabase_pg_meta_Convivo` | `supabase/postgres-meta` | Metadata API (used by Studio) |
| `supabase_edge_runtime_Convivo` | `supabase/edge-runtime` | Edge functions (unused in v1) |
| `supabase_vector_Convivo` | `supabase/vector` | Log shipping |
| `supabase_analytics_Convivo` | `supabase/logflare` | Analytics |
All containers share the external Docker network **`supabase_network_Convivo`**
(named `supabase_network_<project_id>`). The app sidecar joins this network — see
[docker.md](./docker.md).
## Ports
| Service | Host port | Container port | Notes |
|---|---|---|---|
| **API (Kong)** | **54321** | 8000 | The single gateway the app proxies to. **Inside the network, Kong is on 8000** — the `54321→8000` mapping is host-only. |
| Studio | 54323 | 3000 | UI — login `postgres` / `postgres` |
| Postgres | 54322 | 5432 | Direct DB — `postgres` / `postgres` |
| SMTP (Mailpit) | 54324 | 8025 | Captures emails |
| Analytics | 54327 | 4000 | Logflare |
> **Gotcha:** from *inside* the shared network (e.g. the app container), reach
> Kong at `supabase_kong_Convivo:8000`, **not** `:54321`. The `54321` port only
> exists on the host. This is why the app's nginx proxies to
> `supabase_kong_Convivo:8000` by default.
## How to run
```bash
# Start the core (creates containers + the supabase_network_Convivo network)
npm run db:start # = supabase start
# (Re)apply migrations + seed, then restart the stack
npm run db:reset # = supabase db reset (NOT `supabase reset`)
# Stop the core
npm run db:stop # = supabase stop
# Show status / URLs / keys
npx supabase status
```
- `db:reset` drops and recreates the database, applies **all** migrations in
order (`20260822000000_init.sql` → `20260823000000_admin_app.sql` →
[`20260824000000_redesign.sql`](../../supabase/migrations/20260824000000_redesign.sql),
the last of which replaces the old schema), then runs
[`seed.sql`](../../supabase/seed.sql). Use it any time you want a clean demo
state.
- Migrations and seed are **idempotent** (`on conflict ... do nothing`), so a
reset is safe to repeat.
## Config highlights (`supabase/config.toml`)
| Setting | Value | Why |
|---|---|---|
| `project_id` | `Convivo` | Names the Docker network + containers |
| `[api] port` | `54321` | Kong gateway port |
| `[db] port` | `54322` | Postgres port |
| `[studio] port` | `54323` | Studio port |
| `[auth.email] enable_confirmations` | `false` | **No email is sent** — the QR+email login never emails the user |
| `[auth] jwt_expiry` | `86400` | **24-hour login** — the session JWT lives a full day |
| `[auth] site_url` | `http://127.0.0.1:3000` | The app origin |
| `[db.seed] sql_paths` | `["./seed.sql"]` | Seed runs on reset |
## Keys
| Key | Value | Where it's used |
|---|---|---|
| **Anon key** | standard local anon JWT (see `apps/convivo/.env.example`) | **Ships in the app** (public by design) |
| **Service-role key** | standard local service-role JWT | **Never in the app** — server-side only (used for admin ops / verification) |
The app's security model (anon key + session JWT + RLS) is documented in
[rls.md](./rls.md).