Architecture Overview

Architecture Overview

This demo is a decoupled (headless) architecture in three layers — a WordPress content backend, a Next.js frontend, and the Pantheon platform that runs both. Content flows in one direction: editors work in WordPress, the frontend consumes a read-only API, and the edge serves the result.

1. WordPress — the content backend

  • Content model: Page, Article (native post), and Event content types (body, featured image, tags, and event date / location / virtual fields via ACF) plus a Tags taxonomy.
  • REST API: WordPress exposes content under /wp-json/wp/v2; the frontend fetches collections and single items with embedded media and terms. ACF fields appear under an acf key on events.
  • Anonymous reads: published content is readable without authentication, so the frontend needs no credentials for public pages.
  • Content model as code: the event post type and its ACF fields are registered in a must-use plugin, and the demo content is seeded with WP-CLI — not clicked together by hand.

2. Next.js 16 — the frontend

The App Router maps routes to WordPress content:

Route Renders
/ Homepage — hero, featured & latest posts, events
/blog, /blog/[slug] Article list & detail
/events, /events/[slug] Event list & detail
/tags, /tags/[tag] Taxonomy browse
/[...slug] WordPress pages, by slug
  • Data layer: a typed fetch + transform layer normalizes REST responses into clean frontend objects (images, tags, dates).
  • API routes: /api/revalidate receives publish webhooks and /api/health reports backend connectivity.
  • Images: next/image optimizes media served from WordPress uploads.

3. Pantheon — the WebOps platform

  • One workflow: a single Git workflow and the Terminus CLI manage CMS and frontend together; the GitHub App builds and deploys.
  • Multidev: every pull request spins up a live preview environment.
  • Dev → Test → Live environments with review checkpoints.
  • Container runtime on Google Cloud Run, fronted by the Global CDN.

Caching strategy

Performance in a decoupled stack comes from caching at several layers, so most visitor requests are served from the edge and never reach WordPress. The trade-off is freshness — each layer needs a reliable way to update when content changes.

Layer What it caches How it stays fresh
Pantheon Global CDN (edge) Rendered HTML and static assets, served worldwide Cache-Control / s-maxage TTLs, plus targeted purges
Next.js route & data cache Statically generated / ISR pages and fetched data Time-based and on-demand revalidation
WordPress (Advanced Page Cache) REST API responses from WordPress Surrogate-Key purge when related content changes

Keeping the frontend in sync

When an editor publishes or updates content, a WordPress webhook (a must-use plugin) POSTs the affected surrogate keys to the frontend’s /api/revalidate route. Next.js then revalidates only the cache tags for the pages that changed — so publishing rebuilds just those pages instead of the whole site. The keys (post-*, page-*, event-*, term-*) match the cache tags the frontend attaches when it fetches.

Content flow

  1. An editor publishes or updates content in WordPress.
  2. WordPress exposes it over the REST API and fires the revalidation webhook for the affected keys.
  3. Next.js revalidates only those cache tags; the next request rebuilds those pages.
  4. Visitor requests hit the Global CDN first, so most traffic never touches the application or WordPress.

References: Decoupled guides · Next.js on Pantheon docs · Decoupled CMS. New here? Start with Getting Started or read About This Demo.