# worrickcodes/graphite architecture

> Architecture diagram of the GitHub repository worrickcodes/graphite, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/worrickcodes/graphite
- Repository: https://github.com/worrickcodes/graphite

## Overview

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: [`editor/src/application.rs`](https://github.com/worrickcodes/graphite/blob/master/editor/src/application.rs) (Editor core), [`node-graph/graph-craft/src/lib.rs`](https://github.com/worrickcodes/graphite/blob/master/node-graph/graph-craft/src/lib.rs) (Graph core), [`node-graph/nodes/vector/src/lib.rs`](https://github.com/worrickcodes/graphite/blob/master/node-graph/nodes/vector/src/lib.rs) (Node families), [`editor/src/messages/mod.rs`](https://github.com/worrickcodes/graphite/blob/master/editor/src/messages/mod.rs) (Message system)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_runtime["Runtimes"]
  node_desktop_app["Desktop app<br/>native host<br/>[main.rs]"]
  node_desktop_cef["CEF bridge<br/>ipc host<br/>[cef.rs]"]
  node_desktop_render["GPU render<br/>render pipeline<br/>[state.rs]"]
  node_desktop_platform["Platform shells<br/>platform code<br/>[main.rs]"]
  node_frontend_ui["Frontend UI<br/>svelte app<br/>[App.svelte]"]
  node_frontend_state["State providers<br/>ui state<br/>[document.ts]"]
  node_frontend_io["IO managers<br/>browser io<br/>[input.ts]"]
  node_frontend_wasm["WASM bridge<br/>web runtime<br/>[lib.rs]"]
  node_editor_core["Editor core<br/>app logic<br/>[application.rs]"]
  node_editor_messages["Message system<br/>message bus<br/>[mod.rs]"]
  node_editor_executor["Node executor<br/>runtime bridge<br/>[runtime.rs]"]
end

subgraph group_group_engine["Engine"]
  node_node_graph_core["Graph core<br/>graph engine<br/>[lib.rs]"]
  node_node_families["Node families<br/>node packs<br/>[lib.rs]"]
  node_wgpu_executor["WGPU executor<br/>[lib.rs]"]
  node_shared_types["Shared types<br/>core libraries<br/>[lib.rs]"]
  node_rendering_lib["Rendering lib<br/>render helpers<br/>[lib.rs]"]
end

subgraph group_group_support["Support"]
  node_rawkit["RAW pipeline<br/>image decoder<br/>[lib.rs]"]
  node_math_parser["Math parser<br/>expression engine<br/>[lib.rs]"]
  node_dyn_any["Dyn any<br/>runtime typing<br/>[lib.rs]"]
  node_proc_macros["Proc macros<br/>codegen<br/>[lib.rs]"]
  node_tools_suite["Tools<br/>dev tooling<br/>[main.rs]"]
  node_website_site["Website<br/>docs site<br/>[_index.md]"]
end

node_frontend_ui -->|"drives"| node_frontend_state
node_frontend_state -->|"uses"| node_frontend_io
node_frontend_ui -->|"dispatches"| node_editor_core
node_frontend_wasm -->|"bridges"| node_editor_core
node_desktop_cef -->|"hosts"| node_frontend_ui
node_desktop_cef -->|"routes"| node_editor_messages
node_desktop_app -->|"starts"| node_desktop_cef
node_desktop_app -->|"renders"| node_desktop_render
node_desktop_app -->|"packages"| node_desktop_platform
node_editor_core -->|"owns"| node_editor_messages
node_editor_core -->|"executes"| node_editor_executor
node_editor_executor -->|"runs"| node_node_graph_core
node_node_graph_core -->|"instantiates"| node_node_families
node_node_graph_core -->|"accelerates"| node_wgpu_executor
node_node_graph_core -->|"depends on"| node_shared_types
node_node_families -->|"uses"| node_shared_types
node_node_families -->|"emits"| node_rendering_lib
node_wgpu_executor -->|"feeds"| node_rendering_lib
node_rawkit -.->|"supports"| node_node_families
node_math_parser -.->|"supports"| node_editor_core
node_proc_macros -.->|"generates"| node_editor_messages
node_proc_macros -.->|"generates"| node_node_graph_core
node_dyn_any -.->|"supports"| node_editor_core
node_tools_suite -.->|"inspects"| node_editor_messages
node_website_site -.->|"documents"| node_tools_suite

click node_desktop_app "https://github.com/worrickcodes/graphite/blob/master/desktop/src/main.rs"
click node_desktop_cef "https://github.com/worrickcodes/graphite/blob/master/desktop/src/cef.rs"
click node_desktop_render "https://github.com/worrickcodes/graphite/blob/master/desktop/src/render/state.rs"
click node_desktop_platform "https://github.com/worrickcodes/graphite/blob/master/desktop/platform/linux/src/main.rs"
click node_frontend_ui "https://github.com/worrickcodes/graphite/blob/master/frontend/src/App.svelte"
click node_frontend_state "https://github.com/worrickcodes/graphite/blob/master/frontend/src/state-providers/document.ts"
click node_frontend_io "https://github.com/worrickcodes/graphite/blob/master/frontend/src/io-managers/input.ts"
click node_frontend_wasm "https://github.com/worrickcodes/graphite/blob/master/frontend/wasm/src/lib.rs"
click node_editor_core "https://github.com/worrickcodes/graphite/blob/master/editor/src/application.rs"
click node_editor_messages "https://github.com/worrickcodes/graphite/blob/master/editor/src/messages/mod.rs"
click node_editor_executor "https://github.com/worrickcodes/graphite/blob/master/editor/src/node_graph_executor/runtime.rs"
click node_node_graph_core "https://github.com/worrickcodes/graphite/blob/master/node-graph/graph-craft/src/lib.rs"
click node_node_families "https://github.com/worrickcodes/graphite/blob/master/node-graph/nodes/vector/src/lib.rs"
click node_wgpu_executor "https://github.com/worrickcodes/graphite/blob/master/node-graph/libraries/wgpu-executor/src/lib.rs"
click node_shared_types "https://github.com/worrickcodes/graphite/blob/master/node-graph/libraries/core-types/src/lib.rs"
click node_rendering_lib "https://github.com/worrickcodes/graphite/blob/master/node-graph/libraries/rendering/src/lib.rs"
click node_rawkit "https://github.com/worrickcodes/graphite/blob/master/libraries/rawkit/src/lib.rs"
click node_math_parser "https://github.com/worrickcodes/graphite/blob/master/libraries/math-parser/src/lib.rs"
click node_dyn_any "https://github.com/worrickcodes/graphite/blob/master/libraries/dyn-any/src/lib.rs"
click node_proc_macros "https://github.com/worrickcodes/graphite/blob/master/proc-macros/src/lib.rs"
click node_tools_suite "https://github.com/worrickcodes/graphite/blob/master/tools/crate-hierarchy-viz/src/main.rs"
click node_website_site "https://github.com/worrickcodes/graphite/blob/master/website/content/_index.md"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_desktop_app,node_desktop_cef,node_desktop_render,node_desktop_platform,node_frontend_ui,node_frontend_state,node_frontend_io,node_frontend_wasm,node_editor_core,node_editor_messages,node_editor_executor toneBlue
class node_node_graph_core,node_node_families,node_wgpu_executor,node_shared_types,node_rendering_lib toneAmber
class node_rawkit,node_math_parser,node_dyn_any,node_proc_macros,node_tools_suite,node_website_site toneMint
```

## Components

### Runtimes

Interactive application layers and host targets

- [Desktop app](https://github.com/worrickcodes/graphite/blob/master/desktop/src/main.rs): native host · Native executable entrypoint and platform integration for the editor. · `desktop/src/main.rs`
- [CEF bridge](https://github.com/worrickcodes/graphite/blob/master/desktop/src/cef.rs): ipc host · Chromium Embedded Framework hosting and message bridge between frontend and Rust. · `desktop/src/cef.rs`
- [GPU render](https://github.com/worrickcodes/graphite/blob/master/desktop/src/render/state.rs): render pipeline · Desktop GPU context, compositing, and viewport frame presentation. · `desktop/src/render/state.rs`
- [Platform shells](https://github.com/worrickcodes/graphite/blob/master/desktop/platform/linux/src/main.rs): platform code · OS-specific windowing, menus, helpers, and packaging targets for Linux, macOS, and Windows. · `desktop/platform/linux/src/main.rs`
- [Frontend UI](https://github.com/worrickcodes/graphite/blob/master/frontend/src/App.svelte): svelte app · Declarative editor interface, workspace shell, panels, menus, and widgets. · `frontend/src/App.svelte`
- [State providers](https://github.com/worrickcodes/graphite/blob/master/frontend/src/state-providers/document.ts): ui state · Client-side stores and routers that coordinate editor state and IO managers. · `frontend/src/state-providers/document.ts`
- [IO managers](https://github.com/worrickcodes/graphite/blob/master/frontend/src/io-managers/input.ts): browser io · Clipboard, persistence, localization, input, fullscreen, panic, and hyperlink adapters. · `frontend/src/io-managers/input.ts`
- [WASM bridge](https://github.com/worrickcodes/graphite/blob/master/frontend/wasm/src/lib.rs): web runtime · WebAssembly-facing communication layer for running the editor outside the desktop shell. · `frontend/wasm/src/lib.rs`
- [Editor core](https://github.com/worrickcodes/graphite/blob/master/editor/src/application.rs): app logic · Application state, dispatchers, and message-driven domain behavior for the editor. · `editor/src/application.rs`
- [Message system](https://github.com/worrickcodes/graphite/blob/master/editor/src/messages/mod.rs): message bus · Typed message hierarchy and handlers for dialogs, tools, documents, viewport, preferences, and input. · `editor/src/messages/mod.rs`
- [Node executor](https://github.com/worrickcodes/graphite/blob/master/editor/src/node_graph_executor/runtime.rs): runtime bridge · 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](https://github.com/worrickcodes/graphite/blob/master/node-graph/graph-craft/src/lib.rs): graph engine · Node graph model, execution strategy, and core graphcraft/compiler workflow. · `node-graph/graph-craft/src/lib.rs`
- [Node families](https://github.com/worrickcodes/graphite/blob/master/node-graph/nodes/vector/src/lib.rs): node packs · 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](https://github.com/worrickcodes/graphite/blob/master/node-graph/libraries/wgpu-executor/src/lib.rs): gpu executor · GPU-oriented execution path and shader runtime support for graph evaluation. · `node-graph/libraries/wgpu-executor/src/lib.rs`
- [Shared types](https://github.com/worrickcodes/graphite/blob/master/node-graph/libraries/core-types/src/lib.rs): core libraries · Reusable geometry, color, raster, vector, graphic, and no-std primitives shared across the engine. · `node-graph/libraries/core-types/src/lib.rs`
- [Rendering lib](https://github.com/worrickcodes/graphite/blob/master/node-graph/libraries/rendering/src/lib.rs): render helpers · 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](https://github.com/worrickcodes/graphite/blob/master/libraries/rawkit/src/lib.rs): image decoder · Standalone RAW image decoding, metadata identification, preprocessing, demosaicing, and postprocessing pipeline. · `libraries/rawkit/src/lib.rs`
- [Math parser](https://github.com/worrickcodes/graphite/blob/master/libraries/math-parser/src/lib.rs): expression engine · Parsing and evaluating mathematical expressions used by the application and engine. · `libraries/math-parser/src/lib.rs`
- [Dyn any](https://github.com/worrickcodes/graphite/blob/master/libraries/dyn-any/src/lib.rs): runtime typing · Dynamic type support and derive macros used for runtime extensibility. · `libraries/dyn-any/src/lib.rs`
- [Proc macros](https://github.com/worrickcodes/graphite/blob/master/proc-macros/src/lib.rs): codegen · Repository-wide Rust macros for messages, widgets, hierarchical trees, and related code generation. · `proc-macros/src/lib.rs`
- [Tools](https://github.com/worrickcodes/graphite/blob/master/tools/crate-hierarchy-viz/src/main.rs): dev tooling · Developer utilities for crate visualization, message-tree inspection, node docs, and license collection. · `tools/crate-hierarchy-viz/src/main.rs`
- [Website](https://github.com/worrickcodes/graphite/blob/master/website/content/_index.md): docs site · Public static site for product information, blog posts, and contributor documentation. · `website/content/_index.md`

## Connections

- 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.
