Skip to main content

Mountain/Binary/
mod.rs

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