Tauri Backend Integration
Relevant source files
The following files were used as context for generating this wiki page:
The Tauri Backend Integration provides the foundation for the Horizon desktop application, enabling a secure and performant bridge between the React-based frontend and the Rust-based system logic. It allows the application to leverage native system capabilities, such as local data caching and system tray notifications, while maintaining a lightweight memory footprint of less than 50MB.
This integration is a core component of the Phase P implementation plan, focusing on multi-server profile management and offline synchronization. By utilizing Tauri's command system, the frontend can invoke Rust functions (Commands) to perform operations that require system-level access or heavy computation, which are then executed in the safer, compiled environment of the Rust backend.
Sources: IMPLEMENTATION_PLAN.md:764-770, crates/ui/src/App.tsx:7-10
Architecture and Communication Flow
The integration follows a multi-process architecture where the Core process (Rust) manages system resources and the WebView process (React/TypeScript) handles the user interface. Communication is handled through an inter-process communication (IPC) layer using JSON-serialized messages.
IPC Command Pattern
The frontend communicates with the Rust backend using the invoke API. This allows asynchronous execution of Rust functions from the JavaScript environment.
The diagram shows the standard flow of a frontend request being routed through the Tauri IPC bridge to the Rust backend for processing.
Sources: crates/ui/src/App.tsx:7-10, crates/ui/src-tauri/tauri.conf.json:1-10
Configuration and Build System
The integration is managed through tauri.conf.json and a specific Vite configuration. The project uses bun as the package manager for frontend scripts while the backend is managed by cargo.
| Property | Value/Description | Source |
|---|---|---|
| Product Name | horizon | tauri.conf.json:3 |
| Identifier | com.cyberpath-hq.horizon | tauri.conf.json:5 |
| Dev URL | http://localhost:1420 | tauri.conf.json:8 |
| Frontend Dist | ../dist | tauri.conf.json:10 |
| Minification | esbuild (Release) / false (Debug) | vite.config.ts:50 |
Environment Integration
The build system exposes specific environment variables to the frontend code through the VITE_ and TAURI_ENV_* prefixes.
The flow shows how environment variables are filtered and exposed to the frontend source code for use during runtime.
Sources: crates/ui/vite.config.ts:40-44, crates/ui/package.json:6-11
Key System Components
Frontend Dependencies
The desktop UI relies on React 19 and the Tauri API v2 for native interactions.
- @tauri-apps/api: Core bridge for calling Rust commands.
- @tauri-apps/plugin-opener: Native file/URL opening capabilities.
- Vite: Build tool optimized for Tauri development with HMR support.
Sources: crates/ui/package.json:14-19, crates/ui/vite.config.ts:1-10
Backend Dependencies (Rust)
The backend is structured as a library (ui_lib) and a binary, allowing for modular testing and reuse.
- tauri: Version 2.0 framework core.
- serde / serde_json: Handles data serialization for IPC communication.
- tauri-plugin-opener: Backend support for opening system resources.
Sources: crates/ui/src-tauri/Cargo.toml:13-25
Implementation Roadmap for Desktop Features
The integration is scheduled to expand through several sub-phases as detailed in the project's technical roadmap:
- Phase P-02: Multi-Server Profile Management: Implementation of encrypted server profile storage (URL, credentials).
- Phase P-03: Offline Mode: Implementation of a local SQLite cache using
rusqlitefor data persistence when disconnected from the CMDB server. - Phase P-04: System Tray: Integration of native system tray menus and background notification handling.
- Phase P-06: Desktop Agent Integration: Implementation of local agent management and configuration UI within the desktop shell.
Sources: IMPLEMENTATION_PLAN.md:771-797
Security Configuration
The integration includes security measures to prevent unauthorized access to system resources.
- CSP (Content Security Policy): Defined in
tauri.conf.jsonto control resource loading (currently set to null in development/template). - Encrypted Storage: Planned implementation of profile encryption for local data protection.
- Binary Stripping: Production builds are configured to strip symbols to reduce binary size and hinder reverse engineering.
Sources: crates/ui/src-tauri/tauri.conf.json:19-21, Cargo.toml:161, IMPLEMENTATION_PLAN.md:775
Conclusion
Tauri Backend Integration is the bridge that transforms the Horizon web interface into a high-performance desktop application. By strictly separating UI logic in React from system-level operations in Rust, it ensures security and efficiency. The integration is vital for upcoming features like offline synchronization and native system integration, providing a professional desktop experience for CMDB management.
Sources: IMPLEMENTATION_PLAN.md:764-770, crates/ui/src/App.tsx:7-10