How 1zilc/fishing-funds works
Main Components
• Electron Main Process – Found in the “src/main” folder. This contains the core backend logic responsible for creating application windows, initializing auto-updating (autoUpdater.ts), managing the system tray/menubar (menubar.ts, tray.ts), handling system menus (contextMenu.ts), and managing application proxies and child windows.
• Renderer Process – Located in “src/renderer”. This holds all the frontend UI logic built primarily with React (e.g., index.tsx, app.tsx), styling (SCSS modules), and a wide variety of modular UI components (for fund views, charts, stock details, news lists, etc.).
• Preload Scripts – In “src/preload”. They bridge the main and renderer processes providing secure APIs.
• Workers and Utility Services – “src/renderer/workers” (for offloading heavy tasks) and “src/renderer/utils” for additional helpers like HTTP requests, coding, and system hooks.
• State Management – In “src/renderer/store” which employs a Redux-like pattern (multiple “features” folders, “listeners”, etc.) to handle application state and configurations.
• External Data Services – Though not defined as separate microservices, there is a well-organized “src/renderer/services” layer for fetching and processing data from different sources such as “东财”, “蚂蚁基金”, “同花顺” and other APIs.
Component Relationships and Data Flow
• The Electron Main Process initializes the application window(s), loads the preload scripts, and sets up inter-process communication (IPC) channels. It then communicates with the Renderer Process to deliver configuration settings, auto-update notifications, system tray interactions, and proxy settings.
• The Renderer Process (React application) is divided into many functional components and pages. The components (organized within “src/renderer/components”) interact with the state store (“src/renderer/store”) and call service modules (“src/renderer/services”) to fetch data from external APIs.
• Worker threads (“src/renderer/workers”) can be diagrammed as background tasks that help process data (e.g., search or coding-related tasks) independently from the main UI thread.
• The state management interacts with the UI components via listeners to react to changes (cache, sync, configuration updates).
Architectural Patterns & Design Principles
• Separation of Concerns: The main vs. renderer process clearly divides OS-level/system responsibilities from the presentation logic.
• Modular Structure: The project uses modular components, helpers, and services that can be independently managed and tested.
• Event-driven Communication: IPC between main and renderer processes and state listeners (cache.listener.ts, share.listener.ts, etc.) drive data flows.
• Use of a Worker pattern for offloading heavy operations, improving performance on the UI thread.
• The usage of electron-vite indicates a modern development workflow emphasizing fast rebuilds, hot module replacement, and a streamlined bundling process.
Relevant Technologies and Frameworks
• Electron – Core desktop application framework.
• React – The frontend framework for building the UI components.
• Vite (via electron-vite) – For bundling and running the development environment.
• SCSS modules – Styled components for UI theming.
• Redux-like state management – For handling app state.
• Node.js – As the runtime for the main process.
Putting It All Together
• Break the Renderer Process into submodules: UI Components, State Management, Data Services, and Utility/Worker modules.
• A section for external factors – third-party data sources, and how system proxy settings allow connections to these.
• Finally, place configuration and build processes (e.g., electron-vite, CI/CD workflows) on the periphery to emphasize deployment and development aspects.