case studyhealthcarereference architecture

HIPAA-ready reference architecture for hematology/oncology patient education — Go API, Next.js client, Terraform for GCP.

hemepulse — preview
figure · hemepulse
01 · problem

Problem

Every healthcare web project reinvents the same boring scaffolding: security headers, PHI-aware logging, auth shape, telemetry, Terraform for GCP. I wanted a monorepo that had the boring-but-load-bearing parts right on day one so the interesting product work could start on day two.

02 · shape

Shape

A Go 1.26 API on plain net/http — no framework — sits behind a Next.js 16 client. Terraform provisions Cloud Run, Cloud SQL, Secret Manager, and the OTLP collector. The middleware chain is explicit and ordered: SecurityHeaders → CORS → OTel → Auth stub → RequestLogger.

03 · build

Build

Tests run in two styles: unit tests for contracts, property-based tests for invariants (rapid on the Go side, fast-check on the frontend). Every property test carries a comment naming the invariant it guards so the coverage story is readable. PHI never enters a span attribute or a log line by convention — the observability code knows which fields are opaque.

hemepulse — request lifecycle Browser hits the Next.js frontend, which calls the Go API. Every request flows through SecurityHeaders, OTel tracing, and the structured access logger before the handler runs. OTel exports go to Cloud Trace. BROWSER client next.js frontend go api · cloud run :8080 MIDDLEWARE CHAIN SecurityHeaders — HSTS · X-Frame · TLS redirect OTelTracing — span per route + status RequestLogger — slog json + trace_id cloud trace otlp grpc handlers · in-memory store
figure · service topology
04 · result

Result

This is reference architecture, not a product. It exists so the next healthcare web project I start does not begin with a blank main.go and three weeks of yak-shaving. Compliance, telemetry, and the middleware chain are already load-bearing; the product work gets to start on day two instead of day twenty.

stack

GoNext.jsTypeScriptTerraformGCPOpenTelemetry