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.

Agent Readiness

Every storefront ships an AI-agent-facing surface: /llms.txt, content-signal /robots.txt, KV-driven /sitemap.xml with <lastmod>, /.well-known/api-catalog (RFC 9727), /.well-known/oauth-authorization-server (RFC 8414), /.well-known/mcp/server-card.json, and markdown content negotiation on every catalogue page. A dedicated MCP server (sibling Worker) is in progress for agent-driven transactions.

See Agent Readiness for details.

Source Files

FileLinesDescription
src/index.tsx~3000Main app — routes, middleware, caching, gates
src/api-client.ts~400Maho REST API wrapper (paths under /api/rest/v2/)
src/page-config.ts~150Component variant resolver
src/types.ts~400TypeScript type definitions
src/content-store.ts~50KV abstraction layer (with tracked timing for dev toolbar)
src/asset-version.ts~24Cache-bust hash
src/dev-auth.ts~600Password gate, dev tokens, preview, toolbar
src/agents/*.ts~700 totalAgent-readiness surface (llms.txt, robots, sitemap, well-known, markdown)
src/plugins/filterable-pages/Brand pages, megamenu, dependent filters