Architecture
How Renzora is put together: one Bevy binary, a loadable editor image, two shared images that keep process-global state singular, a layered contract, and two ways for a plugin to reach the engine.
Renzora is a Cargo workspace on Bevy main (0.20-dev), pulled into the repository as bevy/. Almost every feature is its own crate that adds a Bevy Plugin, and every plugin is an ordinary Bevy plugin with full &mut World access. There is no FFI layer anywhere.
One binary
There is one desktop executable, renzora (renzora.exe on Windows), built from the root package renzora_app (src/main.rs). It is the editor, the shipped game and the server at once, and which one it is gets decided at launch, not at compile time.
The editor is a loadable image
The editor is the crate renzora_editor, built as a dylib. At startup the binary looks beside itself for:
| Platform | Editor image |
|---|---|
| Windows | renzora_editor.dll |
| Linux | librenzora_editor.so |
| macOS | librenzora_editor.dylib |
Present: the binary is the editor. Absent: the same binary is the game. Removing the editor from a build is deleting one file, so a game and an editor are never two programs that can drift apart.
The decision is made in main before the App is assembled, because it changes what is added. An image present beside the executable is ignored for --server, --host, --vr and --no-editor launches. When it is used, it is loaded after the engine's runtime plugins, so the editor layers on top of them, and it is never unloaded: the editor registers systems and function pointers into the App, and unmapping the image would leave every one of them dangling. See Building from Source for every launch flag.
crates/renzora_runtime/src/editor_image.rs holds the loader.
Why the editor can be a separate file at all
The editor takes &mut App across a dlopen boundary. That is sound only while both sides agree on what App, World and every component type are, and Rust derives a type's identity from how it was compiled: two independently linked copies of Bevy disagree about what Transform is.
The default dynamic_linking feature of renzora_app makes the two sides agree by putting the shared crates into shared images that the binary, the editor image and every native plugin import:
| Shared image | Holds |
|---|---|
bevy_dylib | Bevy |
renzora_dylib (crates/shared/renzora_dylib) | the contract layers, and under its ui feature the UI framework (renzora_ember) |
The second one matters as much as the first, and it fails quietly when it goes wrong. The contract crates own the translation table, the Console buffers, the HTTP queue and the asset loader; ember owns the theme palette, the stylesheet and the UI font scale. A module that privately links its own copy gets its own set of all of these, and every one of them then fails silently: the whole UI renders raw translation keys (menu.file, common.settings) and nothing is logged, because a missing translation is not an error. So a loadable image must have every shared image in its link graph; renzora_editor depends on renzora_dylib for exactly that side effect. Crates that hold no process-global state may be linked into both sides freely.
renzora_dylib holds no code of its own. It is a separate crate rather than a dylib crate-type on renzora because it depends on renzora, which cannot depend back on it.
Because the binary links these images by name, they must sit beside it: Linux and macOS builds carry an rpath of $ORIGIN / @loader_path, and on Windows they share the folder. That is why a bare cargo run cannot start the engine and cargo renzora stages a dist/ folder.
The lean exporter turns dynamic_linking off to produce a fully static single binary for a shipped game: static Bevy, no shared images, no editor, and plugins compiled in rather than loaded. See Export System.
The web
wasm has no dynamic linking, so the web build keeps the editor as a second bundle instead: renzora_editor_app builds a renzora-editor binary under its wasm feature (required-features = ["wasm"], so a native --workspace build never produces it), and the web runtime is renzora built with --no-default-features --features wasm.
The contract
Engine crates do not depend on each other. They depend on contract crates that hold the types two or more crates must agree on, and the contract is layered the way Bevy is: small subject crates at the bottom, one re-exporting crate on top.
It is split into subjects because Cargo rebuilds every crate downstream of one that changed. While everything lived in one crate, an edit to the HTTP vocabulary rebuilt about 200 crates that never make a request.
On disk it is two folders:
crates/api/holds the contracts, onerenzora_<job>_apicrate per subject. A new layer goes here, named that way, and the workspace'scrates/api/*member glob picks it up. A layer's own proc-macro crate nests inside it (crates/api/renzora_editor_api/macros).crates/shared/holds what hands the contracts out:renzora,renzora_sdk, the shared imagerenzora_dylib, andrenzora_text_mesh(a library ember and text meshes share). None of these is a contract of its own.
| Layer | Holds |
|---|---|
renzora_log_api | The Console: console_info/console_warn/console_error, the clog_*! macros and the buffer the Console panel drains |
renzora_lang_api | The translation table every crate reads: t, t_args, language packs, the active language |
renzora_crash_api | Panics the engine catches on purpose, so the crash reporter can tell a recovered panic from a crash |
renzora_project_api | The open project and the process around it: project.toml, editor preferences, file-change events, the session kind, play mode, the graphics quality tier |
renzora_scene_api | The scene vocabulary: shared components and entity tags, entity ids, the shape registry, the project byte loader |
renzora_viewport_api | Render-target state, viewport slots and settings, render-layer numbers, visualization modes |
renzora_shell_api | The editor chrome's vocabulary: panels, status items, top-bar buttons, key bindings, editor events, undo, create menus, asset and entity actions |
renzora_editor_api | The editor contract: selection, the inspector registry and FieldDef, the *_field! macros and the Inspectable derive, toolbar, spawn and shortcut registries |
renzora_platform_api | The machine and the install: version, toolchain, child processes, plugin inventory and updates, the native plugin! macro |
renzora_diagnostics_api | What the engine reports about itself: profiling, probes, runtime warnings, content problems |
renzora_scripting_api | What a script, a language backend and the engine agree on: ScriptCtx, hooks, ScriptExtension, ScriptBackend |
renzora_asset_api | The asset loading contract: load groups, their progress, scene loads |
renzora_net_api | HTTP request vocabulary, the submission queue and the client contract |
renzora_network_api | The multiplayer contract: replication, RPCs, ownership, session state |
renzora_audio_api | The audio boundary and the mixer backend contract |
renzora_animation_api | .anim clips, property keyframes, skeleton drawing, sprite sheets |
renzora_physics_api | The physics contract |
renzora_particles_api | The particle components a scene holds and a script drives |
renzora_world_api | The world's shared state: environment, sun and similar |
renzora_save_api | Saved games |
renzora_bus_api | Named events and services between plugins that share no Rust types |
renzora_render_api | The rendering contract: GPU capability flags, post effects and the post-process framework |
renzora_solari_api | Solari's settings and diagnostics, and DLSS modes |
renzora_material_api | Materials and the material node vocabulary, above the render layer |
renzora_shader_api | Shader text tools: validation, and turning shader source in any dialect into a Bevy Shader |
crates/shared/renzora re-exports the lowest layers at the paths plugins have always used, and the editor contract under its editor feature (its default features are empty). crates/shared/renzora_sdk sits on top and re-exports every layer under the one name renzora. It is what native plugins and Rust scripts get, through renzora_dylib, so renzora::net keeps working for them whichever layer the module lives in.
The rules that keep it working:
- Engine crates depend on the layers they use, never on
renzora_sdk. Depending on the top re-export brings the rebuild cascade straight back. - Depend on the lowest crate that has the name. A crate with many dependents passes every edit below it on to all of them.
- A layer never depends on
renzoraorrenzora_sdk. That is a dependency cycle waiting to happen. - Any crate that holds a static must be reachable from
renzora_sdk, sorenzora_dylibembeds it exactly once. - Put a type two crates need into the contract rather than having one crate depend on the other: into an existing layer, or a new layer in
crates/api/re-exported fromrenzora_sdk.
renzora keeps its name because it appears in the type path of components saved scenes carry.
How a plugin gets into the engine
There are exactly two kinds of plugin:
| Kind | Lives in | Crate type | Compiled | Ships in |
|---|---|---|---|---|
| In-workspace | crates/ | rlib with a plugin table | with the engine, statically | the engine binary |
| Native | <exe dir>/plugins/<name>/ | dylib | on the installing machine, against the staged SDK | the editor, as source |
An in-workspace plugin is an engine feature. A native plugin is something a user installs from the Marketplace or drops in by hand. There is no third kind: something that ships with the engine is a crate in crates/, and the engine checkout has no plugins/ folder.
In-workspace plugins: a generated list
A crate declares each plugin in its own Cargo.toml:
[[package.metadata.renzora.plugin]]
type = "OitPlugin" # a path from the crate root, e.g. "panel::MyPanelPlugin"
[[package.metadata.renzora.plugin]]
type = "MyToolPlugin"
scope = "Editor" # "Runtime" (the default) or "Editor"
priority = -100 # optional; default 0, lower installs earlier
This is configuration, not code. A generator (cargo renzora sync, manifest_plugins in xtask/src/sync.rs) reads every table and writes two committed files, each an ordinary list of app.add_plugins(...) calls, plus the matching dependency entries:
crates/renzora_runtime/src/plugins.rs: everyRuntimeplugincrates/renzora_editor/src/plugins.rs: everyEditorplugin
So a crate needs no contract dependency just to be a plugin, and dropping a crate with a plugin table into crates/ is the whole job. The generator runs before every cargo renzora build; because its output is committed, a plain cargo build needs no generator run, and CI's sync job (cargo renzora sync --check) fails if regenerating would change anything. That is what stops a stale list from shipping, and a stale list fails silently: the plugin simply never installs.
The parser is strict: an unknown key, an unknown scope or a table without type is an error. Every module on the type path must be pub; a #[cfg(feature = "x")] pub mod y; gate on it is detected and reproduced in the generated list. The type must implement Plugin + Default, and a wrong name or a missing Default is a compile error in the generated plugins.rs, never a silently missing plugin.
See Plugins for writing one.
Scopes: Runtime or Editor, never both
A Runtime plugin runs in the editor's viewport and the shipped game. An Editor plugin runs only when the editor image is loaded. There is no "both" scope. A feature that needs editor tooling on top of runtime behaviour ships two plugins, usually as a lean runtime crate crates/renzora_<name>/ with an editor half nested at crates/renzora_<name>/editor/ (package renzora_<name>_editor), which only the editor image links.
Install order
For a normal launch, main assembles the app in this order:
- Rendering (
add_default_rendering, or the headless setup for--server). renzora_runtime::add_engine_plugins: theEditorSessionmarker, then the foundation (RuntimePlugin,InputPlugin,ScriptingPlugin,PhysicsPlugin, plus viewport stretch and render scale in a game), then the generatedRuntimelist.- The server plugins, for
--serverand--host. - The editor image's generated
Editorlist, in an editor session. - Native plugins from
plugins/, so their systems land where a statically linked plugin's would.
Ordering between plugins should almost always use Bevy's system sets rather than priority.
Native plugins: source, compiled where installed
A native plugin is a directory holding src/lib.rs and a crate-type = ["dylib"] manifest. It exports one symbol, renzora_native_plugin_ctor, written by renzora::plugin!, and links the real Bevy and the real contract through the shared images, so it takes &mut World and sees the same Transform the engine does.
crates/renzora_native_pluginis the loader: one pass overplugins/, rebuilding what is stale and loading the rest. A library is a plugin only if a byte search of the file findsrenzora_native_plugin_ctor, decided before the image is mapped, because mapping and unmapping an image to ask runs its initialisers and destructors and has deadlocked the Windows loader. A loaded image is never unloaded.crates/renzora_plugin_buildcompiles a plugin by invokingrustcdirectly against the staged SDK. A plugin is one crate whose dependencies are already compiled, so there is no graph for cargo to resolve.xtask/src/sdk.rsstages the SDK intodist/<platform>/sdk/on every build, from cargo's JSON build messages rather than a directory scan.
A plugin's stamp is a content hash of the SDK it was built against, so when the engine changes the stamp stops matching and the plugin rebuilds itself. The loader declines to load anything at all in a build without dynamic_linking, because without the shared images a plugin would corrupt the World and there is no runtime check that could tell.
A native plugin may use ordinary third-party crates, but never a crate built on Bevy: that would bring in a second Bevy. Bevy-based functionality belongs in the engine, as a crate. See Native Plugins.
Rust scripts use the same mechanism: each .rs script is compiled into a native plugin by the same driver, against the same SDK, and called once per frame per entity with &mut World.
One Bevy, from this repository
Bevy is bevy/, a git subtree of Bevy's main that only the maintainer updates or patches. Every third-party crate built on Bevy lives in vendor/ and points at bevy/ by path. Nothing built on Bevy may come from crates.io, because Cargo would build a second Bevy beside ours and two Bevys in one program corrupt the World. crates.io supplies everything that is not built on Bevy (serde, wgpu, glam and so on).
cargo renzora check-bevy enforces this before every build and in CI, reading cargo tree and naming the crate that pulled a registry Bevy in. A failure means a dependency needs vendoring, not that the check needs loosening.
Shaders are WESL
Bevy 0.20 replaced its shader preprocessor with WESL, so #import, #ifdef and #{NAME} no longer mean anything to it. New shaders are written as .wesl (import bevy_pbr::...;, @if(FLAG)). Old-dialect text still works by translation: .wgsl files load through a translating loader, and shader text built at run time goes through renzora::shader_source::shader(source, path) rather than Shader::from_wgsl. See Shaders.
Crashes and caught panics
A panic hook is installed once the session kind is known. The editor writes ~/.renzora/crashes/last_crash.txt and shows a native dialog; a shipped game appends to crash.log beside the executable.
In the editor, a panic inside a system, command or observer is not a crash. Bevy catches it and hands it to the world's FallbackErrorHandler, and the editor installs one that logs it to the Console and keeps running, so one broken plugin or script system does not take the editor down. The first failure of each system is logged in full, then the count at 10, 100, 1000 and so on. A shipped game keeps Bevy's default handler, so a panicking system still ends the game and writes crash.log.
Where to go next
- Project Structure: where each of these pieces lives.
- Plugins and Native Plugins: writing both kinds.
- Scenes and Asset Pipeline: how content is saved and loaded.
- Render Pipeline: how a frame is drawn.