How worrickcodes/graphite works
1. Repo shape and product split
This is a Rust monorepo centered on the Graphite graphics editor, with a separate Svelte/TypeScript frontend, a native desktop shell, a browser/WASM target, a node-graph computation workspace, supporting libraries, and a public website/docs site. The important architectural boundary is between the interactive UI/runtime layer and the graphics engine / node graph core.
2. Primary runtime: the editor application
The editor crate is the main application logic layer. It is organized around a large typed message system, dispatchers, and message handlers rather than direct UI calls. This crate owns editor state and domain behavior for documents, portfolio/workspace management, tools, dialogs, preferences, input handling, overlays, and viewport behavior.
3. Frontend presentation layer
The frontend directory is a Svelte app that renders the editor UI: panels, menus, floating dialogs, tool widgets, and the main workspace shell. It contains state providers and I/O managers for clipboard, localization, persistence, input, hyperlinks, fullscreen, and panic handling. This layer is mostly declarative UI plus glue code; it does not appear to contain the core graphics algorithms.
4. Message-driven UI-to-engine flow
User actions originate in the frontend and are turned into structured messages. Those messages flow through routers/state providers into the Rust editor layer, where handlers mutate application state or trigger engine work. This message boundary is the core integration mechanism across the repo and is what makes the app architecture suitable for both native and web runtimes.
5. Desktop shell and native integration
The desktop crate is the native host application. It includes platform-specific entry points for Linux, macOS, and Windows, plus bundling/packaging support. The shell also contains native windowing, GPU context setup, persistence, CLI/bootstrapping, and platform integrations such as menus and native handles. This is the boundary where browser-style UI is embedded into a desktop executable.
6. CEF-based UI hosting and IPC
Under desktop/src/cef and desktop/wrapper, the native app uses Chromium Embedded Framework to host the frontend and bridge messages between the JavaScript/Svelte side and the Rust backend. The wrapper intercepts frontend/editor messages and dispatches them across the native boundary. This is a key runtime distinction: native desktop uses CEF+IPC, while the browser target uses WASM.
7. Web/WASM target
The frontend/wasm crate exposes Rust editor functionality to the browser build. It provides the communication layer between the web UI and the Rust-side logic when running outside the desktop shell. So the same conceptual editor can run either through native CEF integration or through a web/WASM bridge.
8. Node graph engine as the computational core
The node-graph workspace is the engine behind Graphite’s nondestructive, node-based workflow. It contains the graph model, node definitions, execution strategies, and many domain-specific node families: vector, raster, text, transform, blending, brush, repeat, path boolean, and core utility nodes. This is the main data-processing subsystem that turns graph structures into rendered graphics and editable document state.
9. Execution backends and rendering pipeline
The node graph has multiple execution paths: an interpreted executor, a graph-craft/compiler path, and GPU-oriented execution support via wgpu-executor. Raster-related nodes also include shader code and shader build steps. In the desktop app, rendered output flows through GPU context/rendering code and compositing shaders before reaching the viewport. This is where document graphs become pixels.
10. Shared domain libraries and specialized engines
Several libraries support the core engine: core-types, vector-types, raster-types, graphic-types, no-std-types, and rendering provide reusable geometry, color, transform, and rendering primitives. libraries/rawkit is a separate RAW image decoding pipeline with preprocessing, demosaicing, metadata, and postprocessing stages. libraries/math-parser supports expression parsing/evaluation, and dyn-any/proc-macros support runtime typing and code generation. These crates are support boundaries, not the primary app shell.
11. Tools, packaging, and non-runtime surfaces
tools contains developer utilities such as crate hierarchy visualization, editor message tree inspection, third-party license gathering, and node documentation generation. The website directory is a separate static site/blog/docs frontend. These do not participate in the editor runtime, but they matter for build, documentation, and distribution architecture.
12. Build and delivery model
The repository is set up for multi-target builds with Cargo, Nix, and CI workflows. That setup reflects the product’s split delivery model: native desktop app, browser app, supporting libraries, and packaged distributions. For an architecture diagram, the most important thing is to show the shared engine in the center, with desktop, web/WASM, and supporting libraries/tools connected around it.
Main entry points: application.rs Editor core · src/lib.rs Graph core · src/lib.rs Node families · mod.rs Message system
Components 22
Runtimes
Interactive application layers and host targets
- Desktop app · Native executable entrypoint and platform integration for the editor.
desktop/src/main.rs - CEF bridge · Chromium Embedded Framework hosting and message bridge between frontend and Rust.
desktop/src/cef.rs - GPU render · Desktop GPU context, compositing, and viewport frame presentation.
desktop/src/render/state.rs - Platform shells · OS-specific windowing, menus, helpers, and packaging targets for Linux, macOS, and Windows.
desktop/platform/linux/src/main.rs - Frontend UI · Declarative editor interface, workspace shell, panels, menus, and widgets.
frontend/src/App.svelte - State providers · Client-side stores and routers that coordinate editor state and IO managers.
frontend/src/state-providers/document.ts - IO managers · Clipboard, persistence, localization, input, fullscreen, panic, and hyperlink adapters.
frontend/src/io-managers/input.ts - WASM bridge · WebAssembly-facing communication layer for running the editor outside the desktop shell.
frontend/wasm/src/lib.rs - Editor core · Application state, dispatchers, and message-driven domain behavior for the editor.
editor/src/application.rs - Message system · Typed message hierarchy and handlers for dialogs, tools, documents, viewport, preferences, and input.
editor/src/messages/mod.rs - Node executor · Editor-side bridge that prepares and runs node-graph execution and runtime IO.
editor/src/node_graph_executor/runtime.rs
Engine
Node graph computation and shared graphics core
- Graph core · Node graph model, execution strategy, and core graphcraft/compiler workflow.
node-graph/graph-craft/src/lib.rs - Node families · Domain-specific node collections for vector, raster, text, transform, blending, brush, repeat, path boolean, and core utility behavior.
node-graph/nodes/vector/src/lib.rs - WGPU executor · GPU-oriented execution path and shader runtime support for graph evaluation.
node-graph/libraries/wgpu-executor/src/lib.rs - Shared types · Reusable geometry, color, raster, vector, graphic, and no-std primitives shared across the engine.
node-graph/libraries/core-types/src/lib.rs - Rendering lib · Conversion and renderer helpers that adapt vector and path data into renderable output.
node-graph/libraries/rendering/src/lib.rs
Support
Libraries, tools, and public site
- RAW pipeline · Standalone RAW image decoding, metadata identification, preprocessing, demosaicing, and postprocessing pipeline.
libraries/rawkit/src/lib.rs - Math parser · Parsing and evaluating mathematical expressions used by the application and engine.
libraries/math-parser/src/lib.rs - Dyn any · Dynamic type support and derive macros used for runtime extensibility.
libraries/dyn-any/src/lib.rs - Proc macros · Repository-wide Rust macros for messages, widgets, hierarchical trees, and related code generation.
proc-macros/src/lib.rs - Tools · Developer utilities for crate visualization, message-tree inspection, node docs, and license collection.
tools/crate-hierarchy-viz/src/main.rs - Website · Public static site for product information, blog posts, and contributor documentation.
website/content/_index.md
Connections 25
- Frontend UI → State providers: drives · UI components read and update shared client state.
- State providers → IO managers: uses · State providers coordinate browser/platform adapters.
- Frontend UI → Editor core: dispatches · User interactions become editor commands and structured messages.
- WASM bridge → Editor core: bridges · Web builds connect browser UI to Rust editor logic through WASM.
- CEF bridge → Frontend UI: hosts · Native desktop embeds the Svelte frontend inside CEF.
- CEF bridge → Message system: routes · CEF IPC forwards frontend actions into the editor message system.
- Desktop app → CEF bridge: starts · The native app initializes the browser host and IPC boundary.
- Desktop app → GPU render: renders · Native app owns GPU context and frame presentation.
- Desktop app → Platform shells: packages · Platform-specific shells provide OS entrypoints and integration.
- Editor core → Message system: owns · Core application behavior is organized around typed message handlers.
- Editor core → Node executor: executes · Editor state delegates node-graph computation to the runtime bridge.
- Node executor → Graph core: runs · Editor-side execution invokes the node graph engine.
- Graph core → Node families: instantiates · Graph model is populated by domain-specific node packs.
- Graph core → WGPU executor: accelerates · Graph execution can use GPU-oriented backends.
- Graph core → Shared types: depends on · Core graph data and execution rely on shared geometric and color types.
- Node families → Shared types: uses · Node implementations build on the shared domain libraries.
- Node families → Rendering lib: emits · Vector and raster nodes feed renderable output through rendering helpers.
- WGPU executor → Rendering lib: feeds · GPU execution path produces data for rendering and display.
- RAW pipeline → Node families: supports · RAW image processing provides specialized input for graphics workflows.
- Math parser → Editor core: supports · Expression evaluation is available to editor and tool logic.
- Proc macros → Message system: generates · Macros reduce boilerplate for typed messages and handlers.
- Proc macros → Graph core: generates · Macros also support node and shader code generation.
- Dyn any → Editor core: supports · Dynamic typing utilities back runtime extensibility.
- Tools → Message system: inspects · Developer tools visualize message structure and architecture.
- Website → Tools: documents · The public site contains contributor and codebase guidance.