High-Level Architecture
Relevant source files
The following files were used as context for generating this wiki page:
Graphite is a procedural 2D graphics engine built with a hybrid architecture that combines a lightweight web-based frontend with a high-performance Rust-based backend. The system is designed much like a game engine, where interactive tools wrap a core node graph engine named Graphene. This architecture enables nondestructive editing by treating artwork as data that is redrawn at the current viewing resolution rather than fixed pixel buffers.
Sources: website/content/volunteer/guide/codebase-overview/_index.md, website/content/volunteer/_index.md, website/content/features.md
Core System Components
The project is structured into three primary architectural tiers: the Frontend, the Editor, and Graphene. These components interact to provide a seamless transition between traditional layer-based editing and advanced node-based generative design.
| Component | Responsibility | Technology |
|---|---|---|
| Frontend | GUI presentation, user input handling, and widget management. | TypeScript, Svelte, SCSS |
| Editor | Business logic, state management, and the central message system. | Rust (WebAssembly) |
| Graphene | Node graph engine, document rendering, and runtime environment. | Rust |
Sources: website/content/volunteer/guide/codebase-overview/_index.md:33-55, frontend/README.md
Frontend
The frontend acts as a minimal presentation layer. It captures user interactions and forwards them to the backend via a WebAssembly (Wasm) wrapper. It is built using Svelte for reactive components and Vite as the build toolchain.
Sources: website/content/volunteer/guide/codebase-overview/_index.md:37-45, frontend/README.md
Editor Backend
Located in /editor, this tier contains the application's core logic. It utilizes a "message system" to handle state transitions and coordinate between the UI and the rendering engine. It is compiled to Wasm for browser execution but is designed for native performance.
Sources: website/content/volunteer/guide/codebase-overview/_index.md:47-51, website/content/volunteer/guide/codebase-overview/_index.md:92-98
Graphene Engine
Graphene is a programming language and runtime environment built on Rust. It manages documents as Directed Acyclic Graphs (DAGs), where nodes implement various graphics algorithms. Graphene programs are compiled live as the user edits the graph, enabling fast rendering.
Sources: website/content/volunteer/guide/codebase-overview/_index.md:53-55, website/content/volunteer/_index.md:40-45
Data Flow and Communication
Communication between the TypeScript-based frontend and the Rust backend is facilitated by a translation layer that bridges the gap between incompatible data types.
Frontend-to-Backend
Input events are passed through a Rust wrapper (editor_wrapper.rs) using wasm-bindgen to expose Rust functions as callable TypeScript functions. This allows the frontend to trigger editor logic without direct access to internal Rust structures.
Sources: website/content/volunteer/guide/codebase-overview/_index.md:76-81, frontend/README.md
Backend-to-Frontend
The backend communicates changes by queuing a list of FrontendMessage objects. These messages are mapped to JavaScript data structures and dispatched to the frontend, where TypeScript code subscribes to specific message types to update the UI.
Sources: website/content/volunteer/guide/codebase-overview/_index.md:83-89
The diagram above illustrates the unidirectional flow of input from the user to the engine and the asynchronous message-based updates returned to the UI.
Sources: website/content/volunteer/guide/codebase-overview/_index.md:74-100
Hybrid Editing Architecture
Graphite implements a "Hybrid Workflow" where the layer panel and the node graph are equivalent views of the same document.
- Layer-Based View: Provides a familiar, tool-centric experience for standard manipulations.
- Node-Based View: Exposes the underlying flowchart of operations for procedural and generative tasks.
This architecture ensures that interactive tools in the viewport (such as the Pen or Shape tools) are actually manipulating the node graph core behind the scenes.
This sequence shows how a simple viewport action propagates through the architectural layers to modify the underlying data model.
Sources: website/content/features.md:27-44, website/content/volunteer/guide/codebase-overview/_index.md:47-51
Project Structure and Deployment
Graphite is designed to be "desktop-first and web-ready." The architecture supports cross-platform consistency by using a common Rust core that can target both native desktop environments (Windows, Mac, Linux) and the web via WebAssembly and WebGPU.
| Directory | Purpose |
|---|---|
/frontend | Web app source, assets, and Wasm wrapper. |
/editor | Main application logic and message handling. |
/node-graph | Graphene engine and node implementations. |
/website | Documentation, blog, and community content. |
Sources: website/content/volunteer/guide/codebase-overview/_index.md:33-55, frontend/README.md, website/content/_index.md:213-230
Summary
The high-level architecture of Graphite leverages Rust's performance and WebAssembly's portability to create a modern graphics engine. By abstracting the rendering logic into the Graphene node engine and using a message-based communication system between the UI and the backend, Graphite achieves a nondestructive, scalable, and highly modular environment for 2D content creation.
Sources: website/content/volunteer/guide/codebase-overview/_index.md, website/content/features.md