Skip to content
ApexSutra

Reference build 04 · Retail

Headless Commerce

Prerendered catalogue with edge cart state and inventory reservation that prevents oversell.

Reference architecture · illustrative
The problem

What we'd be solving.

A multi-channel retailer has a storefront that is slow on mobile and oversells during sale events. Catalogue pages are rendered per request, and stock is synced between channels on a schedule.

Next.jsTypeScriptPostgreSQLRedisCloudflareStripe

The approach

Four decisions that shape everything else.

  • 01

    Static catalogue, revalidated on change

    Product pages are prerendered and invalidated by webhook when the catalogue updates. The common path becomes a CDN hit instead of a database query.

  • 02

    Cart state at the edge

    Per-session cart and pricing run in an edge runtime near the user. Only the genuinely dynamic part pays a latency cost.

  • 03

    Reserve stock at add-to-cart

    A short-lived reservation with automatic expiry, held centrally. Oversell comes from treating inventory as eventually consistent across channels; reservation removes the window.

  • 04

    Rehearse the peak

    Sale events are known dates. Load is tested against the real architecture beforehand, so capacity is a decision rather than a discovery.

Shape of it

Headless Commerce, in one picture.

  1. 01BuildCatalogue pages prerendered, not rendered per request
  2. 02CDNStatic pages revalidated when the catalogue changes
  3. 03Edge cartCart state held at the edge, close to the shopper

Deliberately off the main path

  • Stock reservationTaken at add-to-cart against Postgres, so two shoppers cannot both be sold the last unit.branches from 03 Edge cart
The catalogue is prerendered and served from the edge, so page speed does not depend on request-time rendering. Stock is reserved the moment an item enters a cart, which is what makes oversell structurally impossible rather than unlikely.

What we rejected

The alternatives, and why they lost.

Anyone can list the technology they chose. What tells you whether a team can be trusted with your system is whether they can explain what they didn't choose.

Architecture options rejected for the Headless Commerce reference build, and the reasoning for rejecting each
Option rejectedWhy it lost
Server-rendering catalogue pages per requestPays a database round trip for content that changes a few times a day, and it is the direct cause of the mobile slowness.
Scheduled inventory sync between channelsThe sync interval is precisely the oversell window. Shortening it reduces the symptom without removing the cause.
A single monolithic commerce platformSimpler initially, but it couples storefront performance to a release cycle the retailer does not control.

Start here

Tell us the problem.
We'll be honest about the fit.

A first conversation costs nothing and is useful even if you go elsewhere — you'll leave with an architecture opinion and a realistic sense of scope.

  • Reply within 24 hours
  • No sales sequence