How tessera-ui/tessera works
1. This is a Rust monorepo organized around a cross-platform UI framework called Tessera, plus a set of companion crates and tools. The main architectural split is between runtime/rendering, reusable UI components, state/routing, platform integration, and build/CLI tooling.
2. The core runtime lives in tessera-ui. It is the central execution boundary for apps: declarative component functions are turned into a component tree, laid out, converted into a render graph/scene, and then rendered through a GPU-backed renderer. This crate also owns input and session state such as focus, keyboard, IME, cursor, scroll, timing, profiling, and test support.
3. tessera-macros provides the procedural macro entry point used by application code. Its role is to transform user-authored component functions into the form the runtime can execute, so the app author writes declarative UI while the macro bridges that to tessera-ui’s execution model.
4. tessera-components is the reusable widget layer. It contains higher-level primitives such as buttons, text, layout containers, navigation, dialogs, text fields, sliders, scrollables, and glass/material-style controls. It also includes shader-backed rendering pipelines under src/pipelines, so many components are not just layout wrappers but own their own rendering behavior.
5. tessera-foundation is the low-level support layer beneath components. It defines core concepts such as alignment, gestures, shapes, and modifier semantics/layout/interaction. This crate is the shared vocabulary for layout and interaction across the UI stack.
6. The rendering path is split between the generic renderer in tessera-ui and specialized GPU work in tessera-components. tessera-ui provides the main render engine and render passes, while components contribute specialized draw/compute pipelines and WGSL shaders for effects like blur, shadows, image/vector rendering, progress arcs, and custom glass visuals. The architecture is clearly GPU-first and designed for custom visual effects.
7. tessera-shard is a separate application state/navigation subsystem. It provides handle-based state storage, async support, and a router with destinations/controllers/home state. Conceptually, it sits above the UI runtime as an application-level state and navigation layer rather than a rendering layer.
8. tessera-platform encapsulates host-platform features that are not part of the pure UI runtime, such as clipboard and window-related integration. It also contains an Android plugin surface, which makes it the boundary where Tessera reaches into platform-specific native services.
9. tessera-build is the build-time integration crate. It appears to support embedding backend assets and selecting platform backends, including Android-specific backend logic. This is the bridge between Rust source, generated artifacts, and native platform packaging.
10. Mobile support is handled by tessera-mobile and the higher-level cargo-tessera CLI. tessera-mobile contains project/config parsers, target detection, device/emulator management, platform-specific logic for Android and Apple, and template generation for app/platform scaffolding. cargo-tessera exposes user-facing commands like new, build, dev, check, web, android, plugin, and profiling, acting as the workflow front end for the whole workspace.
11. The repository is template-driven for generated apps and platform projects. Under cargo-tessera/templates and tessera-mobile/templates, the repo stores skeletons for basic/blank apps, plugins, Android Studio projects, and Xcode projects. The generated example tree shows the result of this pipeline: a Rust app plus generated Android and web outputs, demonstrating how source code is turned into deployable platform artifacts.
12. The example crate is both a demo and an integration test of the architecture. Its src/pages/* modules show how app code is organized around pages and custom shaders, while the generated gen/ directories show the platform-specific wrappers Tessera produces for web and Android.
13. External technology choices materially shape the architecture: wgpu for rendering, winit for window/event handling, and glyphon for text. On mobile, the repo integrates with Android Gradle/NDK and Apple tooling such as Xcode, simulators/devicectl, and ios-deploy. Those platform toolchains are not incidental; they are part of the deployment boundary of the framework.
14. A useful diagram of this repo should therefore show three main planes: application code and macros at the top; shared UI/runtime/component/state crates in the middle; and platform/build/CLI/template tooling around the edges that generates, packages, and launches platform-specific projects.
Main entry points: tessera-ui UI runtime · example Example app · tessera-components Components · cargo-tessera cargo-tessera
Components 18
App layer
Application code, declarative UI entry points, and generated app scaffolds.
- Example app · Reference application showing pages, custom shaders, and generated platform outputs.
example
Core UI stack
Shared foundation, runtime execution, component widgets, and app-state/navigation.
- Macros · Transforms declarative component functions into runtime-ready entry points.
tessera-macros - UI runtime · Executes component trees, manages app context, and orchestrates runtime state.
tessera-ui - Tree builder · Builds component trees and constraints before layout and rendering.
tessera-ui/src/build_tree.rs - Layout · Computes constraints, layout, and render-scene preparation.
tessera-ui/src/layout.rs - Renderer · Owns render graph, render passes, scenes, and GPU-backed drawing.
tessera-ui/src/renderer.rs - Session state · Focus, keyboard, IME, cursor, scroll, timing, profiling, and testing support.
tessera-ui/src/context.rs - Foundation · Shared alignment, gesture, shape, and modifier semantics for the UI stack.
tessera-foundation - Components · Reusable UI widgets, controls, and specialized visual components.
tessera-components - Widgets · Buttons, text fields, dialogs, navigation, sliders, scrollables, and layout primitives.
tessera-components/src/lib.rs - Pipelines · Component-owned GPU pipelines and WGSL shaders for blur, shadow, image, text, glass, and effects.
tessera-components/src/pipelines.rs - Shard · Handle-based state storage, async support, and router/navigation state.
tessera-shard
Tooling and platform
Build-time, CLI, and host-platform integration for desktop/mobile packaging and launch.
- Platform · Clipboard, window, and Android plugin surface for native host features.
tessera-platform - Build bridge · Embeds backend assets and selects platform backend logic, including Android-specific build support.
tessera-build - cargo-tessera · User-facing commands for new, build, dev, check, web, android, plugin, and profiling workflows.
cargo-tessera - Mobile tooling · Project parsing, target detection, device/emulator management, platform logic, and template generation.
tessera-mobile
Generated outputs
Example app outputs and template sources used to scaffold new projects and platform wrappers.
- Templates · App and platform skeletons used to generate Rust, Android, and Xcode project structures.
cargo-tessera/templates - Generated app · Example-generated Android and web outputs showing the packaging pipeline in action.
example/gen
Connections 23
- Example app → Macros: uses macros · App code is authored declaratively and bridged through procedural macros.
- Example app → UI runtime: runs on · The app executes inside the Tessera runtime boundary.
- Example app → Components: uses widgets · Pages compose reusable widgets and component-level effects.
- Example app → Shard: uses state · App-level navigation and state management can sit above the UI runtime.
- Macros → UI runtime: expands for · Macro output is shaped for the runtime execution model.
- UI runtime → Tree builder: builds · Component functions are turned into a component tree.
- Tree builder → Layout: feeds · Tree structure is laid out and constrained.
- Layout → Renderer: emits scene · Layout results are converted into render graphs and scenes.
- UI runtime → Session state: owns state · Runtime manages focus, keyboard, IME, cursor, scroll, timing, and profiling.
- UI runtime → Foundation: depends on · Runtime shares foundational layout and interaction semantics.
- Components → Foundation: builds on · Widgets and modifiers use the shared foundation vocabulary.
- Components → Widgets: contains · High-level controls and layout primitives live here.
- Components → Pipelines: contains · Specialized rendering pipelines are part of the component layer.
- Widgets → Pipelines: drives visuals · Many widgets rely on shader-backed drawing and effects.
- Shard → UI runtime: sits above · State and routing coordinate app behavior without owning rendering.
- Platform → UI runtime: integrates with · Host clipboard and window services connect into the runtime boundary.
- Build bridge → Platform: packages · Build logic helps produce platform-specific bundles and backends.
- cargo-tessera → Mobile tooling: invokes · The CLI fronts mobile/project workflows and platform commands.
- cargo-tessera → Build bridge: orchestrates · Build and packaging commands rely on the build bridge.
- cargo-tessera → Templates: generates · New project commands scaffold from repository templates.
- Mobile tooling → Templates: renders · Mobile tooling expands app and platform templates into projects.
- Generated app → Mobile tooling: result of · The generated example tree demonstrates the mobile/project generation pipeline.
- Generated app → Platform: includes · Generated outputs include platform wrappers and native integration surfaces.