Core Concepts
Headless routes incoming HTTP requests through HeadlessKernel, authenticates principals via pluggable AuthGuardInterface guards, and dispatches to namespace providers registered in ProviderRegistry.
Request & Serialization Architecture
Section titled “Request & Serialization Architecture”flowchart TD
A["HTTP Request (/api/v1/* or frontend path in Full Headless)"] --> B{"PassthroughMatcher matches?"}
B -- Yes --> C["Pass through to native ProcessWire template / URL hook"]
B -- No --> D["HeadlessKernel enforces CORS, 2 MiB JSON cap & RateLimiter"]
D --> E["AuthGuardInterface chain (ApiKey / BearerJwt / Hmac / Session / Public)"]
E --> F["ProviderRegistry dispatches namespace (pages / entries / resources / actions / auth / schema / sibling)"]
F --> G["PageAccessPolicy + SelectorGuard + FieldTransformerInterface"]
G --> H["HeadlessResponse JSON envelope (+ ETag / pagination meta)"]
1. Hybrid Mode vs. Full Headless Mode
Section titled “1. Hybrid Mode vs. Full Headless Mode”- Hybrid Mode (default): Your existing ProcessWire frontend templates render HTML normally, while
Headlessserves REST endpoints underapiPrefix(default/api/v1). - Full Headless Mode (
$headless->doHeadless()or Settings -> Full Headless Mode): Intercepts non-admin frontend requests and resolves page paths to JSON automatically (resolvePaths: true), while bypassing patterns inPassthroughMatcher(defaults:['/sitemap.xml', '/sitemap.xsl', '/robots.txt', '/humans.txt', '/llms.txt', '/sitemap-*', '/_react/*']).
2. SecretVault HKDF-SHA256 Key Derivation
Section titled “2. SecretVault HKDF-SHA256 Key Derivation”Instead of reusing one master key everywhere, SecretVault::secretFor($purpose) derives isolated 32-byte HKDF-SHA256 subkeys (headless:jwt, headless:hmac, headless:preview, headless:hash) from the persistent secret stored in the headless singleton blueprint.
3. Providers, Resources, Actions & Transformers
Section titled “3. Providers, Resources, Actions & Transformers”HeadlessProviderInterface: Owns a top-level URL namespace (built-in:pages,entries,resources,actions,auth,schema; plus sibling modules discovered lazily viaheadlessProviders).ResourceBlueprint: Declaratively exposes a ProcessWire selector as a REST collection under/api/v1/resources/{name}with explicitfields,filterable,searchable,readAuth,writeAuth,computed, andcacheTtl.HeadlessAction: Exposes a custom HTTP handler under/api/v1/actions/{path}with auth modes, scopes, and per-action rate limiting.FieldTransformerInterface: Serializes ProcessWire fields cleanly viaTransformationContext(depth,maxDepth,language,visitedcycle guard). Ships withScalarFieldTransformer,MediaFieldTransformer,PageReferenceTransformer, andEntriesFieldTransformer.