IB Scheduling: Go + Next.js Booking Platform
Portfolio booking engine: Supabase Auth + Postgres, Go API (chi, pgx, OIDC JWT) on Railway, Next.js on Vercel, Prometheus/Grafana for metrics - race-safe reservations and full telemetry.
- Built with
- Next.js · Go · Supabase · PostgreSQL · Railway · Vercel · Prometheus · Grafana
The live app
Screenshots from the running build.

Architecture at a glance
The summary above names the pieces; here is how work is divided: Next.js (TypeScript) owns the product UI and browser session; Go owns booking rules, JWT verification against Supabase's OIDC issuer, and Postgres access via pgx. Nothing authoritative runs in the client.
- Identity: Supabase Auth issues JWTs; Next keeps the session; Go verifies tokens with OIDC (JWKS).
- Data: Single Postgres (Supabase). Go connects with
DATABASE_URLusing a service / pooler role - never exposed in the browser. - Deploy pattern: Next on Vercel, Go API on Railway (long-lived), CORS restricted to the web origin.
The Go service never sees the Supabase anon key - only the user's access_token as a Bearer JWT, verified against the Auth issuer.
| Layer | What runs there |
|---|---|
| Web app | Next.js and TypeScript on Vercel: the product UI and the browser session |
| API | Go with chi and pgx on Railway: booking rules and all database access |
| Identity | Supabase Auth issues the JWT; Go verifies it against the OIDC issuer's JWKS |
| Data | One Supabase Postgres database, reached through a service or pooler role |
| Metrics | Prometheus scrapes the API's /metrics; Grafana dashboards query it |
System diagram
How the browser, Next.js, Supabase (Auth + Postgres), and the Go API exchange requests. Observability shows metrics scrape/query (Prometheus/Grafana), not centralized logs.
Deployment diagram
How Supabase, Vercel, and Railway services connect in production.
Telemetry and monitoring
The stack exposes a full metrics path: the Go API serves Prometheus text at /metrics; Prometheus scrapes and stores time-series; Grafana dashboards query Prometheus (e.g. PromQL). This is the operational layer for runtime and app health.
- Grafana (Railway) - dashboards and queries
- Prometheus (Railway) - scrape targets and TSDB
- Go API /metrics - raw Prometheus exposition from the booking service
Go booking API dashboard (Grafana)

Go API surface
Public vs JWT-protected routes are mounted in apps/api/cmd/server/main.go. Protected handlers expect Authorization: Bearer <supabase access_token>.
| Route | Auth |
|---|---|
GET/health | None |
GET/api/ | Bearer |
GET/api/ | Bearer |
GET/api/ | Bearer |
POST/api/ | Bearer |
POST/api/ | Bearer |
POST/api/ | Bearer |
POST/api/ | Bearer |
POST/api/ | Bearer |
Database invariants
| Table | Constraint | What it guarantees |
|---|---|---|
public.resources | No extra constraint | The bookable entity |
public.slots | UNIQUE (resource_id, starts_at) | Discrete windows: one slot per resource per start time |
public.reservations | UNIQUE (slot_id) | At most one confirmed reservation per slot; this is the ON CONFLICT target |
reservations.user_id | References auth.users(id) | Matches the JWT sub, so a booking always belongs to a real user |
Booking mechanics (race-safe)
POST /api/v1/reservations with a body { "slot_id": "uuid" } runs in a transaction: lock the slot row, insert reservation, commit. The unique constraint on slot_id plus FOR UPDATE serializes competing bookings; duplicate inserts return 409.
GET /api/v1/availability returns open slots (no confirmed reservation) via LEFT JOIN; the UI sends the Supabase access token on every call through a small fetch wrapper.
| Guarantee | Enforced by |
|---|---|
| Two people cannot book the same slot | A transaction that locks the slot row with FOR UPDATE, plus UNIQUE (slot_id) on reservations |
| The loser of a race gets a clear answer | A duplicate insert returns 409 instead of a second booking |
| Only signed-in users can read or book | Every booking route verifies the Supabase JWT against the OIDC issuer |
| Nothing authoritative runs in the browser | Booking rules and Postgres access are owned by the Go API |
| Database credentials never reach the browser | DATABASE_URL stays on the Go service, which never sees the Supabase anon key |
| Only the web app can call the API from a browser | CORS restricted to the web origin |
Source and live demo
Full source and deployment notes live in the repo sibtihaj/go-booking-system. Try the hosted app at go-booking-system.vercel.app and the Architecture pages for interactive diagrams.
