404human Projects Writing Build logs Learning Books Progress
Rust · Zola
zsh · 404human@dev:~ Tab complete · ↑↓ history · type help

Headless CMS architecture diagram (real design)

A complete headless CMS architecture diagram built from a live Rust, PostgreSQL, and SvelteKit CMS—covering RLS, immutable releases, and MCP auth.

Published
Read time
5 min read
Kind
guide
Topics

Most headless CMS architecture diagrams are three generic boxes connected by arrows: Admin UI → API → Frontend. That diagram looks tidy in a slide deck and leaves out every hard question you actually face in production:

  • How do you guarantee a public website can never leak an unpublished draft—even if an API handler has a bug?
  • How do you roll back a broken publish cleanly without chasing stale CDN caches?
  • How do you let AI clients (like Claude over MCP) edit posts without giving them admin keys?
  • Where do media files, member-gated content, and SvelteKit/Astro static builds actually fit?

Below is the real architecture we built and now run live for Colophon CMS (colophonapp.404human.dev), which powers its own marketing site and blog at colophon.404human.dev as well as five demo sites.

Complete headless CMS architecture diagram

┌────────────────────────────────────────────────────────────────────────────┐
│ 1. AUTHORING & AI CLIENTS                                                  │
│   ├─ SvelteKit Studio (browser SPA/SSR editor, role-based UI, media)       │
│   └─ Remote MCP Clients (Claude / Codex via OAuth 2.1 PKCE at /mcp)        │
└───────────────────────────────┬────────────────────────────────────────────┘
                                │ HTTPS (Caddy + Cloudflare)
                                ▼
┌────────────────────────────────────────────────────────────────────────────┐
│ 2. CORE CMS SERVER (Rust / Axum)                                           │
│   ├─ Auth & RBAC (Argon2id sessions, OAuth PKCE, per-project roles)        │
│   ├─ Draft & Revision Engine (optimistic locking, no-op save rejection)    │
│   ├─ MCP Adapter (draft-only writes, explicit human approval on publish)   │
│   └─ Release Publisher (atomic numbered release + SHA-256 receipt)         │
└──────────────┬──────────────────────────────────┬──────────────────────────┘
               │ (staff / publisher DB role)      │ (content-addressed blobs)
               ▼                                  ▼
┌──────────────────────────────────┐   ┌─────────────────────────────────────┐
│ 3. POSTGRESQL (Source of Truth)  │   │ 4. OBJECT STORAGE (Media History)   │
│   ├─ Entries, drafts, revisions  │   │   ├─ Immutable digest-pinned blobs  │
│   ├─ Releases & receipts table   │   │   └─ Verified upload before swap    │
│   ├─ Row-Level Security (RLS)    │   └─────────────────────────────────────┘
│   └─ Transactional Outbox        │
└──────────────┬───────────────────┘
               │ (read-only PUBLIC DB role — literally cannot read drafts)
               ▼
┌────────────────────────────────────────────────────────────────────────────┐
│ 5. DELIVERY & PREVIEW SURFACES                                             │
│   ├─ Public Static Sites (Astro / SvelteKit / Zola carrying release ID)    │
│   ├─ Public Delivery API (CDN-cached, published rows only)                 │
│   ├─ Member-Gated Reads (RLS visibility gate, strictly bypasses cache)     │
│   └─ Private Draft Previews (signed short-lived token, noindex, no cache)  │
└────────────────────────────────────────────────────────────────────────────┘

Five architectural boundaries that prevent real CMS outages

1. Separate database roles for authoring vs. public delivery

Never run your public read path on the same database credentials as your admin Studio. In Colophon, public delivery connects through a dedicated PostgreSQL role that has permission to read published release rows and nothing else—no drafts, no staff tables, no writes. Multi-tenant and member visibility gates (public, signed-in members, or named audience roles) are enforced directly inside PostgreSQL Row-Level Security (RLS), so even an application-level query bug cannot leak a draft across tenants.

2. Numbered immutable releases (instead of mutable “is_published” flags)

Flipping an is_published = true boolean on individual rows creates half-published states when an entry, its navigation link, and its cover image change together—and makes rollback messy.

Publishing in Colophon creates an atomic numbered release with a receipt. Static builds (like colophon.404human.dev) embed the release number they were built from and stay pending until a live post-deploy probe verifies that the expected release marker is actually serving. Rolling back simply points the active release pointer back to the previous verified release number.

3. Member-gated reads must bypass the shared cache

If your CMS supports both public articles and subscriber/member-only content, never let an authenticated read populate a shared edge or in-memory cache. Member reads must always bypass shared caches and evaluate RLS under the visitor’s verified session.

4. Content-addressed media with immutable versions

Overwriting hero.jpg in place breaks rollbacks and causes mixed old/new assets behind CDNs. Storing uploads content-addressed by SHA-256 digest guarantees every release pins the exact bytes it was published with, and a failed upload verification leaves the live asset untouched.

5. Remote MCP as a first-class, draft-only adapter

Instead of forcing AI tools to scrape your UI or hold admin REST keys, mount an MCP adapter directly onto your domain layer (how to build an MCP server):

  • Users sign in via OAuth 2.1 + PKCE, so the agent inherits only that person’s project roles.
  • Edits use targeted patching with optimistic locking (so fixing a typo doesn’t resend an 85 KB body) and ignore byte-identical no-op saves.
  • Publishing, deleting, or changing permissions requires explicit human confirmation; deleting a project is never exposed to MCP at all.

API-driven headless CMS vs. Git-based CMS vs. release-verified hybrid

ModelHow content is storedStrengthsMain trade-off
Git-based CMS (Markdown in Git + Zola/Astro/Hugo)Files in a Git repositoryZero DB to run, instant PR diffs, rock-solid static hostingPainful for non-technical editors, media bloat in Git, no built-in RBAC or member gating
Traditional API-driven headless CMS (Strapi, Directus, Payload, Contentful)Relational/document DB + REST/GraphQLRich editorial UI, relational schemas, webhooks, rolesMutable rows make atomic rollback harder; stale CDN/ISR caches are common
Release-verified hybrid (Colophon CMS)PostgreSQL + RLS + numbered releases + static/API deliveryAtomic rollbacks, verifiable release receipts, safe member gating, MCP editingMore upfront engineering than plain Markdown files

For a deeper side-by-side of when a plain static generator still wins, see Headless CMS vs Static Site Generator (Zola / Astro) and How draft preview actually works on a static site.

Why SvelteKit pairs cleanly with a headless CMS

If you are choosing a frontend or Studio framework for a SvelteKit CMS stack (SvelteKit vs Next.js for dashboards and internal consoles):

  • Small client bundles keep rich editorial dashboards responsive without shipping heavy hydration overhead.
  • Clean server load functions make it straightforward to fetch public release snapshots at build/edge time while keeping authenticated Studio and draft-preview routes strictly server-side with Cache-Control: no-store.
  • Reserved route hygiene: Keep a CI check that compares SvelteKit’s static route directory (/media, /tasks, /audience, /import) against your CMS’s reserved collection-slug list so a user can never create a content collection that shadows a Studio page (why naming a collection /media broke our app).

Frequently asked questions

What is the difference between a headless CMS and a traditional monolithic CMS? A traditional CMS (like classic WordPress) couples the database, admin editor, and HTML theme renderer in one runtime. A headless CMS separates content storage and authoring from presentation, exposing content via APIs, webhooks, or static build pipelines to any frontend (SvelteKit, Astro, Next.js, or mobile apps).

How do static sites stay fresh when backed by a headless CMS? Use a transactional outbox inside the CMS database to trigger a webhook or CI rebuild whenever a new numbered release commits, then verify the deployed site serves the new release ID before marking the publish complete.

Should a headless CMS expose direct database access to the frontend? No. Keep the database behind the CMS domain layer (or strictly scoped read-only views/RLS roles) so schema migrations, permissions, media digests, and release receipts stay enforced in one place.

Related reading