Mountain/Binary/
mod.rs

1//! # Binary Module
2//!
3//! ## RESPONSIBILITIES
4//!
5//! Main entry point and initialization for the Mountain desktop application.
6//! This module handles application startup, Tauri command registration,
7//! configuration, and lifecycle management.
8//!
9//! ### Core Functions:
10//! - **Application Entry**: Main application entry point
11//! - **Tauri Setup**: Configure Tauri application builder
12//! - **Command Registration**: Register all Tauri commands
13//! - **IPC Bridge**: Set up IPC communication with frontend
14//! - **Service Initialization**: Start Vine and Cocoon services
15//! - **Tray Management**: Configure system tray
16//! - **Lifecycle**: Handle application lifecycle events
17//!
18//! ## Architectural Role
19//!
20//! The Binary module is the **entry point** in Mountain's architecture:
21//!
22//! ```text
23//! main.rs ──► Binary::Main (Entry) ──► Build ──► Register ──► Initialize ──► Services
24//!                                    │            │             │             │
25//!                                    ▼            ▼             ▼             ▼
26//!                                AppLifecycle   Commands    Services    Vine/Cocoon
27//!                                         │            │             │
28//!                                   IPCCommands  IPCBridge   ProcessMgmt
29//! ```
30//!
31//! ### Design Principles:
32//! 1. **Single Entry Point**: One clear entry point for the application
33//! 2. **Lazy Initialization**: Services started only when needed
34//! 3. **Graceful Shutdown**: Clean shutdown of all services
35//! 4. **Error Resilience**: Graceful degradation on failures
36//!
37//! ## Key Components
38//!
39//! - **Main**: Application entry point and orchestration
40//! - **Build**: Tauri builder configuration
41//! - **Register**: Command and service registration
42//! - **Service**: Service initialization (Vine, Cocoon)
43//! - **Initialize**: Application state initialization
44//! - **IPC**: IPC command handlers (14 commands)
45//! - **Tray**: System tray integration
46//! - **Extension**: Extension startup
47//!
48//! ## TODOs
49//! High Priority:
50//! - [x] Atomize Main.rs into submodules
51//! - [ ] Add crash recovery mechanism
52//! - [ ] Implement proper error dialog for startup failures
53//!
54//! Medium Priority:
55//! - [ ] Add startup performance metrics
56//! - [ ] Implement incremental service startup
57//! - [ ] Add service health checks during startup
58//!
59//! Low Priority:
60//! - [ ] Add startup progress indicator
61//! - [ ] Implement startup animation
62//! - [ ] Add startup sound
63
64// --- Main Sub-module ---
65
66/// Main application entry point and orchestration.
67pub mod Main;
68
69// --- Builder Sub-module ---
70
71/// Tauri application builder configuration.
72pub mod Build;
73
74// --- Register Sub-module ---
75
76/// Command and service registration.
77pub mod Register;
78
79// --- Service Sub-module ---
80
81/// Service initialization (Vine, Cocoon, Configuration).
82pub mod Service;
83
84// --- Initialize Sub-module ---
85
86/// Application state initialization.
87pub mod Initialize;
88
89// --- IPC Commands Sub-module ---
90
91/// IPC command handlers (14 commands).
92pub mod IPC;
93
94// --- Tray Sub-module ---
95
96/// System tray integration.
97pub mod Tray;
98
99// --- Extension Sub-module ---
100
101/// Extension startup and management.
102pub mod Extension;
103
104// --- Shutdown Sub-module ---
105
106/// Graceful shutdown handling.
107pub mod Shutdown;
108
109// --- Debug Sub-module ---
110
111/// Debug and trace logging utilities.
112pub mod Debug;
113
114// --- Re-exports from Main sub-module for backward compatibility and
115// convenience ---
116
117use Main::{AppLifecycle, Entry, IPCCommands};
118pub use Entry::Fn as Main;
119pub use AppLifecycle::*;
120// Note: IPCCommands is now a placeholder, commands are in Binary/IPC/*
121// Note: Tray is now a placeholder, commands are in Binary/Tray/*
122
123// --- Convenience re-exports from other sub-modules ---
124pub use Build::{LocalhostPlugin, LoggingPlugin, TauriBuild, WindowBuild};
125pub use Register::{
126	AdvancedFeaturesRegister,
127	CommandRegister,
128	IPCServerRegister,
129	StatusReporterRegister,
130	WindSyncRegister,
131};
132pub use Service::{CocoonStart, ConfigurationInitialize, VineStart};
133pub use Initialize::{CliParse, LogLevel, PortSelector, RuntimeBuild, StateBuild};
134pub use Shutdown::{RuntimeShutdown, SchedulerShutdown};
135
136// --- Tray re-exports from atomic modules ---
137
138pub mod TrayModule {
139	pub use super::Tray::{EnableTray::enable_tray as EnableTray, SwitchTrayIcon::SwitchTrayIcon};
140}