How mihomo-party-org/mihomo-party works
Main Components
• Electron Main Process – Under src/main, this includes configuration files (config/), core modules (factory, manager, various API integrations like mihomoApi and subStoreApi), system-level functionality (src/main/sys), and resolution modules (autoUpdater, backup, tray management, etc.). It orchestrates the backend logic and interacts with the OS.
• Preload Scripts – Located in src/preload, these serve as a secure communication bridge (via IPC) between the main process and the renderer.
• Renderer Process – Under src/renderer, you have multiple layers: the HTML files, the React application (App.tsx, FloatingApp.tsx), routing, components (UI elements ranging from base components to settings and modals), hooks, assets, and utility modules. This layer handles all the UI interactions and presentation.
• Build & Packaging Components – The build directory, electron-builder.yml, and the aur directory (with multiple AUR package configurations) indicate that software packaging/distribution is an essential part of the overall architecture.
• External and Shared Services – Integration points to external APIs (e.g., Mihomo API, SubStore), backup/restore facilities (WebDAV integration), possibly Telegram for updater notifications (visible in scripts/telegram.mjs), and utility modules for configuration and IPC. Shared modules in src/shared support cross-cutting concerns like internationalization and type definitions.
Relationships and Data Flow
• The Electron main process is the core controller that initializes configurations, manages the backend logic, and communicates with external APIs.
• Preload scripts expose selected functionalities safely to the Renderer, allowing UI components to send/receive commands via IPC to the main process.
• The Renderer (React app) takes user actions, presents the UI, and uses hooks and components to interact with the underlying services of the main process.
• External services (like Mihomo APIs and WebDAV) are accessed as needed by either the main process or specialized modules to update configurations, perform backups, or deliver auto-update functionality.
• The packaging and build pipelines (configured in build files, GitHub workflows, and AUR package scripts) are connected to the main development cycle to produce distributable binaries for multiple platforms.
Architectural Patterns & Technologies
• Use of Electron’s dual-process model (Main vs. Renderer) is a core architectural principle.
• Modular design: Separation into config, core functionality, UI components, and utilities offers clear responsibilities.
• IPC communication pattern via preload scripts enforces security while bridging the processes.
• Adoption of React (with TypeScript) ensures clean UI composition and state management.
• Build tools and CI/CD (GitHub workflows, eslint, prettier) enforce code quality and automated packaging.