Skip to content

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.

IB Scheduling: Go + Next.js Booking Platform, screenshot 1 of 3

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_URL using 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.

The stack, layer by layer
LayerWhat runs there
Web appNext.js and TypeScript on Vercel: the product UI and the browser session
APIGo with chi and pgx on Railway: booking rules and all database access
IdentitySupabase Auth issues the JWT; Go verifies it against the OIDC issuer's JWKS
DataOne Supabase Postgres database, reached through a service or pooler role
MetricsPrometheus 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.

IB Scheduling system diagramThe browser runs the Next.js App Router UI, with middleware and server rendering handling session cookies at the edge. The browser refreshes its session with Supabase Auth through supabase-js and calls the Go API with a Bearer JWT. The Go API, built with chi, go-oidc and pgx, validates tokens against Supabase Auth, reads and writes slots and reservations in Postgres, and exports counters and gauges on /metrics, which Prometheus scrapes and Grafana queries with PromQL.SupabaseObservabilityBrowserNext.js App RouterGo APIchi · go-oidc · pgxMiddlewareSSR, session cookiesAuthOIDC, JWKSPostgresslots, bookings/metricsexported by the Go APIPrometheusscrapes and storesGrafanaPromQL dashboardsBearer JWTvalidatepgx SQL
The browser refreshes its session with Supabase Auth and calls the Go API with a Bearer JWT. Observability here is metrics (scrape and query), not centralised logs.

Deployment diagram

How Supabase, Vercel, and Railway services connect in production.

IB Scheduling deploymentUsers reach the Next.js frontend on Vercel over HTTPS. The frontend uses supabase-js for auth with Supabase Cloud and calls the Go API on Railway with a Bearer JWT. The Go API verifies tokens with OIDC and JWKS against Supabase Auth, uses pgx for SQL against Supabase Postgres, and exports metrics that Prometheus scrapes and Grafana charts, both on Railway. Vercel rewrites on the app domain proxy the Grafana and Prometheus dashboards so users can open observability without leaving the app.VercelSupabase CloudRailwayUsersNext.jsfrontendRewritesdashboard proxyGo APIchi · pgx · go-oidc, on RailwayAuthOIDC, JWKSPostgresslots, reservations/metricsexported by the Go APIPrometheusproxied by the rewritesGrafanaproxied by the rewritesHTTPSdashboardsBearer JWTJWKSpgxscrapes
Users reach everything through the app domain: Vercel serves the frontend and proxies the Grafana and Prometheus dashboards, Railway runs the Go API and metrics stack, and Supabase Cloud holds auth and data. The frontend also talks to Supabase Auth directly through supabase-js.

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.

Go booking API dashboard (Grafana)

Grafana dashboard showing Go booking API metrics including goroutines and runtime signals
Snapshot of the live Go booking API dashboard (last 15 minutes). Use the demo credentials above if Grafana prompts for login.

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

Routes and the auth each one needs
RouteAuth
GET/healthNone
GET/api/v1/db-statusBearer
GET/api/v1/availabilityBearer
GET/api/v1/reservationsBearer
POST/api/v1/reservationsBearer
POST/api/v1/slotsBearer
POST/api/v1/benchmark/booking-rushBearer
POST/api/v1/mimic/notification/emailBearer
POST/api/v1/mimic/notification/whatsappBearer

Database invariants

Tables, their constraints and what each guarantees
TableConstraintWhat it guarantees
public.resourcesNo extra constraintThe bookable entity
public.slotsUNIQUE (resource_id, starts_at)Discrete windows: one slot per resource per start time
public.reservationsUNIQUE (slot_id)At most one confirmed reservation per slot; this is the ON CONFLICT target
reservations.user_idReferences 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.

What the system guarantees, and what enforces it
GuaranteeEnforced by
Two people cannot book the same slotA transaction that locks the slot row with FOR UPDATE, plus UNIQUE (slot_id) on reservations
The loser of a race gets a clear answerA duplicate insert returns 409 instead of a second booking
Only signed-in users can read or bookEvery booking route verifies the Supabase JWT against the OIDC issuer
Nothing authoritative runs in the browserBooking rules and Postgres access are owned by the Go API
Database credentials never reach the browserDATABASE_URL stays on the Go service, which never sees the Supabase anon key
Only the web app can call the API from a browserCORS 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.