myzig architecture
Start with the layers, then follow the two UI paths. Plugins depend on the public API; the CLI creates and builds apps. Platform implementations are selected at compile time.
1. Framework overview
myzig: the framework at a glance
Read top to bottom: app, public API, shared code, two UI paths, then the selected platform backend. Plugins use the public API; the CLI is build tooling. The browser target supports native UI, not desktop page IPC.
One API. Two UI paths. A backend chosen at compile time.
Read downward for dependencies; branches show the two kinds of window content.
Your application
Zig state, services and views / examples/
Optional plugins
Public API clients
fetch / sqlite / more
plugins/<name>/
Public API
src/myzig.zig
App / Window / ui / Call / Event / Channel
CLI / build tooling
init / dev / build
generate / doctor
cli/
Shared behavior and contracts
app_types / window_types / page_core / ipc
documents / transfer / i18n / l10n / audio
Tooling creates and builds
apps; it is not a runtime
layer inside the framework.
Web page path
HTML / CSS / JS frontend
bridge.js + typed Zig IPC
OS webview draws the page
Desktop targets only
Native UI path
Zig views and widgets
src/ui/
Layout → paint → renderer
Desktop + browser target
A desktop app can use
both kinds of window.
PLATFORM ADAPTERS → selected by builtin.os.tag
Selected backend → native OS or browser APIs
macOS
src/*.zig
AppKit / WKWebView
Metal
Linux
src/linux/
GTK 3 / WebKitGTK
OpenGL
Windows
src/windows/
Win32 / WebView2
Direct3D 11
Browser
src/web/
wasm32-wasi / host.js
WebGL 2
Solid arrows: dependencies / integration. Dashed boxes: optional packages and tooling.
2. Web page IPC
myzig: a web page calling Zig
Desktop page IPC: frontend to bridge, native webview transport, shared dispatch and bound Zig service. Replies, events and channels return through a batched outbox. TypeScript generation happens at compile time.
Web pages: typed calls across the webview boundary
Desktop only: WKWebView (macOS), WebKitGTK (Linux), WebView2 (Windows).
Frontend
Generated myzig.js client
myzig.d.ts type checking
HTML / CSS / JavaScript
Page runtime
src/bridge.js
window.myzig
Call IDs → Promise results
Native transport
Webview postMessage
Platform Page adapter
JSON messages
Shared IPC dispatch
src/ipc.zig / bindings.zig
Trust check → decode → method dispatch
Bound methods run on the main thread
Your Zig service
app.bind(&service)
Typed method arguments
Return value or error
Per-page outbox → native evaluation → bridge receive
Replies, events and channel values are batched once per main-loop turn.
__myzig.receive([...]) settles calls and delivers messages.
Compile-time client generation
tsgen.zig + bindings.zig / myzig.js + myzig.d.ts
Runtime return path goes back to the frontend; generation is separate from message dispatch.
Solid arrows: runtime messages. Dashed arrow / box: generated client supplied to the frontend.
3. Native UI rendering
myzig: native UI from state to pixels
A surface or ui.Tester calls frame.run. A Zig view builds a Context box tree; layout and paint produce gpu.Instance data. A platform GPU renderer or CPU renderer draws it. Damage limits redraw; input uses previous frame layout.
Native UI: the same frame pipeline in windows and tests
Input, resize, explicit redraw or animation requests a frame; idle views do not poll.
Frame caller
Platform window surface
or headless ui.Tester
ui/frame.zig → run
Build view
State → ui.View(Context)
Widgets → box tree
c.changed → rebuild
Layout
ui/layout.zig
Measure → arrange
Rects + text shaping
Paint
ui/paint.zig → gpu.Instance[]
Backgrounds / glyphs / images / effects
Clipping, hit regions and draw order
Damage
ui/damage.zig
Find changed regions
Limit redraw work
GPU renderer
Metal / D3D11
OpenGL / WebGL 2
Selected for the target
CPU renderer / reference twin
ui/raster*.zig
Offscreen Tester rendering and CPU path
GPU tests compare against CPU pixels
Interaction reads the previous layout; frame commit updates hit state for the next event.
Arrows: frame data / drawing work. GPU and CPU are alternative render paths for the same instances.