Rethinking Desktop App Architecture: A Bevy-inspired Logic Engine for Tauri/Electron #15151
Ailrid
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone,
I’m a huge fan of Bevy’s design philosophy and am currently authoring a book/deep-dive guide for the Bevy engine.
Currently, I primarily use Electron (mainly because Webview performance on Linux—my primary OS—can be inconsistent, though I vastly prefer Tauri’s lightweight and Rust-first design). While building complex desktop applications, I’ve often felt frustrated by the "Spaghetti State" caused by the mental overhead of Vue’s reactive system and the fragmented nature of IPC management.
To solve this, I’ve been building Virid — a logic engine that introduces Bevy’s ECS and Deterministic Scheduling concepts into the TypeScript/Desktop ecosystem.
🌟 Core Architectural Shifts:
From Reactive to Deterministic (The Tick System):
I’ve abandoned Vue’s ref/watch for core business logic. Instead, Virid employs a Double-Buffered Message Pool and a Logic Tick mechanism. All state changes are dispatched as Messages and processed in the next microtask cycle, ensuring a predictable execution order similar to Bevy’s Schedule.
"Deep Shield" - Emulating Rust's Immutability in TS:
In @virid/vue, I implemented a recursive Proxy-based interceptor. This isn't just a "readonly" hint; it’s a Physical Shield that blocks all unauthorized mutations and method calls (e.g., Array.push) for non-owned components, throwing detailed stack traces for illegal writes. This mimics Rust’s ownership and borrowing constraints at runtime.
IPC Location Transparency:
Inspired by distributed systems and Bevy’s messaging, I abstracted IPC into a unified message stream. Whether a System is running on the Main process or a Worker/Renderer, the Controller remains agnostic. It simply emits a message, and the dispatcher handles the routing.
Zero-Intrusion Undo/Redo:
By treating the entire app state as a collection of versioned Components, I’ve implemented a linear versioning model. This allows for application-wide Undo/Redo functionality without writing a single line of business-specific rollback logic.
💬 Why I'm posting this:
My next milestone is to rewrite the entire core in Rust as a truly "Headless" cross-platform logic framework.
I am particularly curious about the Tauri community's take on Virid:
Could this philosophy be integrated into Tauri as a Plugin (either as a Rust backend core or a web frontend adapter)?
How does Tauri currently handle high-frequency state synchronization between Rust and multiple windows without hitting the "Reactivity Wall"?
Repo/Docs: https://github.com/Ailrid/virid
Beta Was this translation helpful? Give feedback.
All reactions