How activitywatch/aw-tauri works
Project Overview and Purpose
• The project blends a web-based frontend (located in the root and (eventually) in the aw-webui folder) with a native Rust backend in the src-tauri folder, leveraging Tauri’s capabilities for desktop integration. It also uses Node.js for frontend dependency management and building.
Analyzing the File Structure
• Key top-level files and directories include:
• .github – Contains CI/CD configuration (workflows for build, lint, release, etc.).
• aw-webui – This directory holds the web UI code, even though it’s noted as “not yet the actual aw-webui code.”
• package.json and package-lock.json – Manage frontend dependencies.
• src-tauri – Contains all the Rust code and configuration for the Tauri backend.
▪ Within src-tauri, you see core Rust files (main.rs, lib.rs, logging.rs, manager.rs) that implement core functionality.
▪ The tauri.conf.json and several build/configuration files (Cargo.toml, build.rs, etc.) configure the runtime and the build for the native layer.
• Other files (Makefile, LICENSE, README.md) indicate standard project documentation/build scripts.
• This directory layout suggests an architecture where the Tauri application acts as a bridge between a modern web-based UI and a native Rust backend incorporating multiple features.
Identifying Major Components
• Tauri Application Container (Central Component):
• WebView/Frontend:
• Represents the web UI (aw-webui) that users interact with, built with Node.js and served inside a WebView provided by Tauri.
• Rust Backend:
• Contains the main executable logic (src-tauri/src/main.rs) and libraries (lib.rs, logging.rs, manager.rs) that implement:
• Module Manager: Handles the startup, management, and state of watcher modules.
• Integration with aw-server-rust: Runs ActivityWatch server logic as part of the main executable.
• Build and Configuration Ecosystem:
• CI/CD configuration under .github, Makefile for build scripts, and the Tauri configuration files (tauri.conf.json, Cargo.toml) that tie everything together.
• External Dependencies and Platforms:
• Node.js (for frontend development and building the web UI).
• Rust/Cargo (for compiling the backend).
• Operating System-specific components (Gtk on Linux, Tao on Windows/macOS, and potential mobile support under development).
Relationships and Interactions
• The "WebView/Frontend" component (representing the user interface from the aw-webui folder).
• Data flow from user interactions in the WebView triggering events in the Rust backend.
• The module manager starting, stopping, or managing watchers.
• Build and update flows from external build tools (Makefile, npx tauri build) into the Tauri Application.
• Relationships to emphasize dependency and flow among components.
Incorporating Architectural Patterns/Design Principles
• That the project uses a hybrid architecture where a web UI is embedded inside a native system wrapper (a typical Tauri design).
• Separation between presentation (web UI) and business logic (Rust backend) which is a variant of the separation-of-concerns principle.
• That modularity is key: the use of a module manager suggests a plug-in or modular design for dynamically handling watcher modules.