Desktop vs Web Application Builds
Relevant source files
The following files were used as context for generating this wiki page:
The Graphite editor is architected as a cross-platform application capable of running as a high-performance native desktop client or as a lightweight web application. While both targets share the same core business logic written in Rust and a Svelte-based frontend, they utilize different build toolchains and distribution methods to optimize for their respective environments.
The project is designed to deliver professional desktop performance on Windows, Mac, and Linux while remaining accessible via a browser for quick access. Regardless of the build target, Graphite runs locally on the user's hardware without a server, utilizing WebAssembly (Wasm) and WebGPU to minimize overhead on the web. Sources: website/content/_index.md, frontend/README.md
Build Architecture Comparison
The architecture separates the presentation layer (frontend) from the business logic (editor/Graphene). The communication between these layers varies slightly depending on whether the build is targeting the browser environment or a native desktop wrapper.
Core Components
- Frontend: A reactive GUI built with Svelte, TypeScript, and SCSS. It acts as the entry point for user input.
- Editor Backend: The core business logic written in Rust. It is compiled to WebAssembly for web builds.
- Graphene Engine: The node-based graphics engine that manages and renders documents.
- Wasm Wrapper: A thin Rust translation layer that provides a TypeScript-compatible API using
wasm-bindgen.
Sources: website/content/volunteer/guide/codebase-overview/_index.md, frontend/README.md
Build Flow Diagram
The following diagram illustrates how the source code is processed into the two primary build targets.
Web Application Build (Wasm)
The web build targets modern browsers and Progressive Web App (PWA) environments. It relies heavily on the npm ecosystem and the Vite build system to bundle Svelte components and interop with the Rust backend.
Key Technologies
- Vite: Used as the primary bundler and development server.
- wasm-pack: Compiles the Rust
wrappercrate into a WebAssembly module with TypeScript bindings. - Svelte: Powers the reactive UI components.
Build Commands
Specific scripts in package.json manage the compilation of the Wasm module and the frontend assets.
| Command | Description |
|---|---|
npm run wasm:build-dev | Builds the Wasm wrapper in debug mode. |
npm run wasm:build-production | Builds the Wasm wrapper with release optimizations. |
npm run build | Full production build including Wasm and Vite bundling. |
Sources: frontend/package.json:10-30, frontend/README.md
Native Desktop Build
The native desktop application is currently in a release candidate stage for Windows, Mac, and Linux. It is designed to provide "true native performance" for graphically intensive workloads.
Architecture Differences
- Feature Flags: The build system uses Rust features (e.g.,
--features native) to toggle desktop-specific logic. - No-Default Features: Native builds often disable default web features to reduce overhead and use native system APIs.
- Vite Native Mode: Vite is configured to build in a specific
nativemode to package assets for the desktop client.
Build Scripts
Native builds are triggered through specialized npm scripts that pass specific flags to wasm-pack and vite.
"native:build-production": "wasm-pack build ./wrapper --release --target=web --no-default-features --features native && vite build --mode native"
Sources: frontend/package.json:26-27, website/content/_index.md, website/content/features.md
Communication and Interop
Communication between the frontend and the backend is handled via a message-passing system. This ensures that the frontend remains lightweight and the backend serves as the single source of truth.
Frontend-to-Backend
The editor_wrapper.rs file provides callable functions exported to TypeScript. In web builds, these are autogenerated TS functions provided by wasm-bindgen.
Backend-to-Frontend
The backend queues FrontendMessage objects. These are mapped to JavaScript data structures in messages.ts. The frontend subscribes to these messages to update the UI.
Development Environment Requirements
To build either target locally, developers require a specific toolchain:
- Rust: Latest stable release for the backend.
- Node.js: Latest LTS version for the frontend and build scripts.
- Git: For version control.
The cargo run command serves as a high-level entry point, capable of checking system dependencies and spinning up a dev server at localhost:8080. For slow networks, cargo run release is recommended to reduce the unoptimized binary size, which can exceed 100 MB. Sources: website/content/volunteer/guide/project-setup/_index.md
Summary
Graphite's dual-build strategy allows it to function as a versatile creative suite. The web build provides instant, zero-install access as a PWA, while the desktop build targets professional workflows requiring hardware acceleration and native system integration. Both builds leverage a unified Rust core, ensuring consistency in the procedural node-based logic across all platforms.