Theme Structure
The WebbiOS Storefront Engine is an ultra-fast, edge-rendered system designed to serve dynamic content in under 50ms globally.
The Theme Engine Flow
Section titled “The Theme Engine Flow”When a user visits a WebbiOS storefront, the following sequence occurs at the Cloudflare Edge:
- Request Interception: The Cloudflare Worker intercepts the request and extracts the domain.
- KV Cache Lookup: The system uses the domain to query Cloudflare KV for the
theme.jsonconfiguration (e.g.,cache:theme:config:webbios.dev). This lookup takes single-digit milliseconds. - Fallback Mechanism: If the KV cache misses (e.g., a newly linked domain or a temporary failure), the system falls back to a hardcoded
theme.jsonbundled with the Worker to ensure the site never goes down. - Routing: Based on the requested path, the engine extracts the specific page configuration from the
theme.json. - Edge Rendering: WebbiOS uses React’s
renderToReadableStreamto statically render the content at the edge. A<SectionRenderer>iterates over the page’s sections and maps them to@webbios/storefront-uicomponents. - Edge Caching: The resulting HTML is streamed to the browser with a
Cache-Controlheader (e.g., 5 minutes), instructing the CDN to serve subsequent requests directly from the edge cache without hitting the Worker.
The theme.json Architecture
Section titled “The theme.json Architecture”WebbiOS uses a Headless Architecture for themes. The entire visual structure of a site is defined in a single theme.json file.
{ "themeName": "Corporate 01", "version": "1.0.0", "pages": { "/": { "title": "Home", "description": "SEO description for home", "sections": [ { "id": "hero-1", "type": "hero", "props": { "headline": "Welcome to WebbiOS", "primaryCtaText": "Shop Now" } } ] } }}Sections and Components
Section titled “Sections and Components”Each item in the sections array represents a UI block. The type (e.g., hero) tells the <SectionRenderer> which React component to instantiate, and the props provide the data for that component.
This JSON-driven approach allows for future Theme Builders where merchants can drag-and-drop UI components, and the system simply updates the theme.json in KV without needing to rebuild or redeploy any code.