Mountain/Binary/Main/mod.rs
1//! # Main Module (Binary)
2//!
3//! ## RESPONSIBILITIES
4//!
5//! Main application orchestration providing entry point, command handlers,
6//! lifecycle management, and tray integration for the Mountain desktop
7//! application.
8//!
9//! This module serves as the primary entry point for the application and
10//! coordinates all initialization, execution, and shutdown operations.
11//!
12//! ## ARCHITECTURAL ROLE
13//!
14//! The Main module is the **orchestration layer** in Mountain's architecture:
15//!
16//! ```text
17//! main.rs ──► Binary::Main (Entry::Fn)
18//! │
19//! ├─► Entry::Fn() (Main entry point)
20//! ├─► IPCCommands (Tauri command handlers)
21//! ├─► AppLifecycle (Setup and initialization)
22//! └─► Tray (System tray icon management)
23//! ```
24//!
25//! ## KEY COMPONENTS
26//!
27//! - **Entry** (`Entry::Fn`): Main application entry point exported as
28//! `Binary::Main::Fn()`
29//! - **IPCCommands**: All Tauri command handlers for frontend-backend
30//! communication
31//! - Workbench configuration commands
32//! - IPC messaging commands
33//! - Wind desktop configuration commands
34//! - Configuration management commands
35//! - Status reporting commands
36//! - Performance monitoring commands
37//! - Collaboration commands
38//! - Document sync commands
39//! - **AppLifecycle**: Application lifecycle management and setup
40//! - **Tray**: System tray icon switching based on theme
41//!
42//! ## EXPORTS
43//!
44//! - `pub use Entry::Fn as Main`: Main entry point
45//! - All IPC command functions are exported from IPCCommands
46//! - `AppLifecycleSetup`: Application setup function from AppLifecycle
47//! - `SwitchTrayIcon`: Tray icon switching command from Tray
48//!
49//! ## ERROR HANDLING
50//!
51//! - Entry point panics on fatal errors (Tokio runtime, Tauri build)
52//! - IPC commands return `Result<serde_json::Value, String>`
53//! - Lifecycle setup returns `Result<(), Box<dyn std::error::Error>>`
54//! - Non-critical failures are logged but don't prevent operation
55//!
56//! ## LOGGING
57//!
58//! Comprehensive logging throughout with checkpoints at key stages.
59//! Logs use standardized prefixes: `[Boot]`, `[Lifecycle]`, `[IPC]`, `[UI]`.
60//!
61//! ## PERFORMANCE CONSIDERATIONS
62//!
63//! - Async initialization spawned after main setup
64//! - Compile-time resource embedding for tray icons
65//! - Minimal allocation overhead with efficient error handling
66//!
67//! ## TODO
68//! - [ ] Add comprehensive error recovery mechanism
69//! - [ ] Implement startup progress indicator
70//! - [ ] Add graceful degradation for service failures
71//! - [ ] Implement performance metrics collection
72
73/// Main application entry point and orchestration.
74///
75/// Contains the `Fn()` function which is the primary entry point for the
76/// Mountain
77// desktop application. This function creates the Tokio runtime, initializes
78// application state, sets up the Tauri builder, and runs the application.
79pub mod Entry;
80
81/// IPC command handlers.
82///
83/// Contains all Tauri command handlers that provide the frontend-backend
84/// communication bridge. Commands include workbench configuration, IPC
85/// messaging,
86// Wind desktop integration, configuration management, status reporting,
87// performance monitoring, collaboration, and document synchronization.
88pub mod IPCCommands;
89
90/// Application lifecycle management.
91///
92/// Contains the `AppLifecycleSetup()` function which handles all initialization
93// during the Tauri setup hook, including tray initialization, command
94// registration, IPC server setup, window creation, environment configuration,
95// and async service initialization.
96pub mod AppLifecycle;
97
98/// System tray commands.
99///
100/// Contains the `SwitchTrayIcon()` Tauri command for switching the system tray
101// icon based on the current theme (light/dark mode).
102pub mod Tray;
103
104// --- Re-exports ---
105
106/// Main application entry point.
107///
108/// Exported as `Binary::Main::Fn()` and can be called from main.rs
109/// to start the Mountain desktop application.
110pub use Entry::Fn as Main;