One model · one view · two faces

Kinogaki architecture

A Document is the source of truth, a Prism file on disk. A view is a pure function of that Document. The C++ libraries render the view — in a browser as WebAssembly, or in a native window — and Prism is the wire between them. This is the whole system in one page, then the pieces.

The shape in one paragraph

A Document is the source of truth — a Prism file on disk, a set of typed Elements at hierarchical Paths. A view is a pure function of that Document: give it the state, it returns a tree of widgets. The C++ libraries render that view tree, and they render it two ways from one codebase — in a browser as WebAssembly, or in a native window on the device. Between the server that authors the view and the client that draws it, Prism is the wire: the view is a Prism Document, an edit is a Prism Document, and a change is a sparse Prism overlay applied to the last one. Author the model once; render it anywhere; send only what changed.

A Document is a set of Elements indexed by Path, each carrying typed Propertys; a Property is a Value, optionally varying over time.

That sentence is the whole model. Everything on this site builds on it: the libraries that hold and draw it, the loop that ships it over a socket, and the two faces that render it.

The flow

state (a Document)                  the source of truth — a Prism file
   │
   │  view(state)                   a pure function → a view Document
   ▼
view (a Document)                   widgets as typed Elements at Paths
   │
   │  Prism on the wire             snapshot, or a sparse overlay of what changed
   ▼
the client renders                  C++ kinogaki-ui — WebAssembly or native
   │
   │  an event (a Document)         a press, a form submit — back over the wire
   ▼
the server re-runs view(state)      and the cycle closes

Three things make this small instead of sprawling, and all three come from Prism:

Where to go next