Tauri Backend & Capabilities
Relevant source files
The following files were used as context for generating this wiki page:
The Vata application utilizes Tauri 2 as its core desktop shell, providing a secure and performant Rust-based backend for a React-based frontend. The backend is responsible for managing the native windowing system, handling Inter-Process Communication (IPC), managing SQLite database connections via plugins, and executing high-performance tasks such as image processing and file system operations.
Tauri's architecture follows a multi-process model where the "Core" process (Rust) manages system-level resources and "Webview" processes (React/Vite) handle the user interface. This separation ensures that the frontend has restricted access to the host system, only interacting with native capabilities through a strictly defined IPC bridge and permission system.
Sources: README.md:19-30, CLAUDE.md:43-50
Architecture and Core Components
The backend is built using Rust (edition 2021) and the Tauri framework. The application entry point is defined in the src-tauri/src/main.rs (implicitly called via the binary definition), while the primary logic and plugin registrations reside in the library crate.
Backend Execution Flow
The following diagram illustrates the initialization and execution flow of the Tauri backend from startup to running the main loop.
Plugins and Native Capabilities
Vata leverages several official and third-party Tauri plugins to extend the frontend's capabilities while maintaining security through the tauri.conf.json configuration.
| Plugin | Functionality | Usage in Vata |
|---|---|---|
tauri-plugin-sql | SQLite Database Access | Managing system.db and individual tree .db files. |
tauri-plugin-fs | File System Operations | Reading/writing GEDCOM files and managing media directories. |
tauri-plugin-dialog | Native OS Dialogs | File picking for GEDCOM imports and exports. |
tauri-plugin-store | Key-Value Persistence | Storing lightweight application settings. |
tauri-plugin-mcp-bridge | Debugging/MCP Bridge | Interacting with the app via MCP tools in debug builds. |
Sources: src-tauri/src/lib.rs:137-156, src-tauri/Cargo.toml:22-30, package.json:52-55
SQLite Management
The sql plugin is configured to preload sqlite:system.db. The application follows a "Two-Database Design":
- System DB: Stores app-level metadata such as the tree list and settings.
- Tree DB: Stores genealogical data for a specific family tree, opened on demand when a user selects a tree.
Sources: src-tauri/tauri.conf.json:34-36, CLAUDE.md:54-65
IPC Commands and Menu Integration
The backend exposes specific native functions to the frontend via the invoke system and manages the system menu, which communicates back to the frontend through event emission.
Native Rust Commands
The application implements specific performance-critical logic in Rust that is exposed to the TypeScript frontend:
generate_thumbnail: Takes a source image path, a destination path, and a maximum width. It decodes the image using theimagecrate and saves a resized thumbnail to disk.set_close_tree_enabled: Manages the state of the "Close Tree" menu item, allowing the React frontend to enable or disable native menu options based on the current routing context (picker vs. in-tree).
System Menu and Events
Vata implements a custom application menu that modifies standard behaviors. Notably, it replaces the standard "Close Window" shortcut (Cmd/Ctrl+W) with a "Close Tree" action.
- Identifier:
close-tree - Event:
menu:close-tree - Behavior: When the menu item is clicked or the shortcut is pressed, the backend emits the
menu:close-treeevent. The React "tree shell" route listens for this event to perform clean-up (closing the DB) and navigating back to the home picker.
Sources: src-tauri/src/lib.rs:5-12, src-tauri/src/lib.rs:43-123, CLAUDE.md:46-52
Build and Security Configuration
The tauri.conf.json file defines the window properties, security headers, and build scripts.
| Configuration Key | Value / Description |
|---|---|
identifier | app.vata.genealogy |
windows.title | Vata - Genealogy |
windows.width/height | 1280x800 (Minimum: 900x600) |
security.csp | Restricted to self, asset:, and data: for images. |
beforeDevCommand | pnpm dev |
beforeBuildCommand | pnpm build |
Sources: src-tauri/tauri.conf.json:4-32
Summary
The Tauri backend in Vata provides a robust foundation for a local-first genealogy application. By offloading image processing and complex file system management to Rust while leveraging specialized plugins for SQLite and native dialogs, the architecture ensures high performance and a native user experience. The integrated menu system and IPC bridge allow for seamless coordination between the system shell and the React frontend state.