Architecture Overview
The runtime is built on composition, not layers. A single kernel is constructed with its dependencies injected; there is no inheritance, no plugin registry, and no middleware chain.
Composition model
Each adapter category is independently composable. A browser host wires the web-layering engine and the full React provider stack; a CI host wires the headless engine and no providers at all. The kernel contract does not change.
The three adapter categories
- Rendering adapters turn the kernel's layer-sync calls into actual pixels (or nothing, for headless). See Rendering Adapters.
- Service providers satisfy host-capability contracts — authentication, theming, analytics, credits, monetization. The React provider stack assembles these from Picsart's React ecosystem.
- Tooling adapters add out-of-band capabilities: the CLI, profiler, and dev server.
Execution targets
The same kernel runs across five orthogonal targets — browser, Node.js, CLI, CI, and headless — because the environment-specific concerns live entirely in the adapters, not the kernel. The kernel makes zero environment assumptions.
Source organization
| Directory | Responsibility |
|---|---|
src/client/ | Public kernel API (createRuntime, createStore, deeplink, fetch overrider) |
src/core/ | Runtime.ts lifecycle orchestrator, cache, deeplink, registry |
src/context/ | 16 context factories composed into the bootstrap context |
src/state/ | createStore — event-storm-backed observable state |
src/adapters/ | Rendering engine implementations |
src/providers/react/ | React provider wrappers, bridges, and adapters |
src/cli/ | CLI entry point (commander + puppeteer + Vite dev server) |
src/handlers/ | Event handlers (analytics, context changes, storage) |
src/types/ | All TypeScript interface contracts |
Going deeper
The Deep Dive covers the factory-level specifics:
the createRuntime entry point, the runtime orchestrator, DOM scaffolding, the
MiniappHandle lifecycle, cache and deeplink systems, adapter contract
surfaces, the permission model, and the context-factory/bootstrap assembly.