Skip to content

Architecture Overview

Maho Storefront is a server-side rendered headless storefront that runs entirely on Cloudflare's edge network. It fetches catalog data from a Maho backend, caches it in Cloudflare KV, and renders HTML responses at the edge using Hono.js JSX.

System Diagram

Technology Stack

LayerTechnologyPurpose
Edge ComputeCloudflare WorkersRequest handling, SSR, caching
FrameworkHono.jsRouting, middleware, JSX rendering
Data StoreCloudflare KVCatalog data cache (products, categories, CMS)
CSSUnoCSS + DaisyUI v5Atomic utilities + component library
NavigationTurboSPA-like page transitions without a JS framework
Client JSStimulus.js 3.2Declarative client-side controllers
Buildesbuild + UnoCSS CLIJS bundling + CSS generation
BackendMaho (OpenMage fork)Catalog, cart, checkout, admin

Key Concepts

Edge-First Rendering

Every catalog page is rendered as static HTML at the Cloudflare edge. There is no client-side framework runtime — Stimulus controllers attach behavior to server-rendered DOM elements.

Three-Tier Caching

  1. Edge Cache (~1ms) — HTML responses cached per PoP with version-tagged keys
  2. KV Store (~10-50ms) — Catalog data (products, categories, config) cached globally
  3. Origin API (~100-300ms) — Maho backend, hit only on KV miss or revalidation

See Caching for the full strategy.

Component Variant System

The storefront uses a slot-based component system where each UI element (product card, header, footer, gallery) has multiple interchangeable variants. Which variant renders is controlled by page.json configuration per store.

See Component Variants for details.

Multi-Store Support

A single Worker deployment serves multiple stores. Each store has its own theme, page config, and KV-prefixed data. Store resolution happens at request time based on the hostname.

See Multi-Store for details.

Source Files

FileLinesDescription
src/index.tsx~700Main app — routes, middleware, caching
src/api-client.ts~200Maho REST API wrapper
src/page-config.ts~115Component variant resolver
src/types.ts~310TypeScript type definitions
src/content-store.ts~37KV abstraction layer
src/asset-version.ts~24Cache-bust hash