Stack
Next.js · PostgreSQL · SupabaseTyped App Router server actions over Auth, Postgres, Storage, and contract-aware database functions.Fifth Form
One system, from first impression to publish.
A production-oriented CMS backend for client websites, designed around secure content editing, explicit publishing boundaries, and efficient public delivery without exposing the private administration surface.
- Backend architecture
- Security + access control
- Content delivery



STRUCTURE UNDERNEATH.
TECHNICAL DEEP DIVE
A CMS backend built around explicit trust boundaries.
I developed Fifth Form as a multi-site content platform rather than a collection of editable pages. The architecture separates authenticated editing, database writes, publishing, and anonymous website delivery so each path can be secured, validated, cached, and scaled independently.
Personally ownedPostgreSQL schema design, content contracts, RLS and role-based access control, RPC write workflows, middleware and server actions, public API hardening, publishing state, caching, client adapters, and production deployment.
Security model
RLS · RBAC · guarded RPCsSite-scoped roles, middleware checks, validated inputs, and auditable writes instead of direct table mutation.Delivery model
Layered cache · deduped fetchesCDN stale-while-revalidate, framework revalidation, client TTL caching, and in-flight request reuse.- 01Auth + middleware guard
- 02Contract-validated action
- 03RLS + RPC write boundary
- 04Draft · preview · publish
- 05Sanitized public DTO
- 06CDN + deduped adapter
Database + access control
The schema encodes ownership, roles, and publishing state.
PostgreSQL models clients, sites, memberships, content blocks, collection items, media, versions, and audit events. Row Level Security scopes every authenticated read to an assigned active site, while role checks distinguish platform admins, owners, editors, and viewers. Content mutations go through guarded RPCs that re-check authorization and keep related writes atomic.
27 migrations define the data model and policies; direct CMS mutations are locked down behind site-scoped database functions.
Validation + publishing
Draft, preview, and live content are separate system states.
A typed CMS contract defines the exact editable surface for each website. Server actions validate fields and media before they reach PostgreSQL; preview reads an authenticated draft payload; publish validates the whole site again, snapshots the current release, and atomically promotes draft data. Public traffic never reads from that private editor path.
Contract validation runs in the application and database, with rollback-ready publish history and automated checks for write-path security.
Public delivery + cost control
The fastest backend request is the one the website never makes.
Anonymous websites use one narrow endpoint that returns sanitized published content only. Responses are CDN-cached with stale-while-revalidate; the Next.js adapter adds framework revalidation; the Vite client adds TTL caching and reuses in-flight promises. Typed normalization and checked-in fallback content keep sites available when the CMS is slow or unreachable.
The public DTO is sanitized in SQL and application code, while caching and request deduplication reduce repeated Supabase reads.
ENGINEERING RANGE
What this build demonstrates.
PostgreSQL system design
Modelled multi-site content, membership, roles, media, version history, audit events, and publishing state as one coherent schema.
Secure API boundaries
Separated authenticated editor operations from anonymous delivery using middleware guards, server-side validation, RLS, RBAC, RPCs, and sanitized DTOs.
Transactional publishing
Built draft, preview, publish, discard, and rollback behavior with contract checks and atomic database transitions.
Scalable content delivery
Combined CDN caching, framework revalidation, TTL caches, request deduplication, normalized fetch layers, and resilient fallback content.
BUILT AND SHIPPED
See the product, not a repository.
NEXT PROJECT / 01
MyCFOView technical case study