KJDRAW / ARCHITECTURE
Architecture
Understand where document truth lives, how commands cross boundaries and which responsibilities remain with the embedding host.
Layer model#
Product UI · Reference workbench · Plugins · AI agents
│
Commands + transactions
│
Typed document model + KJD / KJP / DXF
│
TypeScript reference path ↔ optional Rust/WASM
│
Project · Compute · Scene providers
The document is canonical. Component state, canvas display lists and selection overlays are projections that can be rebuilt. File and compute services enter through explicit adapters instead of becoming hidden global dependencies.
Documents and transactions#
A KJDocument owns stable IDs and handles, object ownership, tables, blocks, model/paper spaces, resources and a monotonically changing revision. A transaction edits a draft, validates the result and then publishes it atomically. Undo/redo is session history; reopening a KJP does not claim to reconstruct the in-memory undo stack.
TypeScript and Rust authority#
Every public runtime module is authored in strict TypeScript. The package provides browser and Node.js ESM together with type declarations. The TypeScript path is the portable reference implementation.
Rust/WebAssembly can provide document authority, geometry predicates and explicitly bounded solid-mesh operations. Backend identity is observable. Missing WASM is never silently described as Rust-authoritative output.
Host responsibilities#
KJDraw provides capability wiring. The embedding product supplies authentication, authorization, tenant isolation, transport policy, durable audit storage, model isolation and the sandbox policy for third-party plugin code.
Remote activity begins when the host invokes a configured remote provider, keeping data flow explicit and observable.