How edrlab/thorium-reader works
Based on both the file tree and the README, Thorium Reader is a desktop application built with Electron, using a multi-process architecture (one Node.js main process and multiple renderer processes) and a clear Model–View–Controller (MVC) pattern implemented via Redux (for state management) and Redux-saga (for side effects). The application also uses React for rendering the views, and the integration between the main and renderer processes is achieved using Electron’s IPC/RPC mechanisms.
Main Components
• Main Process (Electron back-end):
– This is the central node.js process (“src/main”) containing the core business logic.
– It includes modules for handling CLI commands, database access, PDF handling, network operations, and redux state/sagas.
• Renderer Processes:
– Library Window: A renderer (in “src/renderer/library”) that provides the library interface where users see the catalog, settings, and dialogs.
– Reader Window(s): One or more renderer processes (in “src/renderer/reader”) responsible for displaying the reading interface.
• Shared/Utility Components:
– Common Code Layer: Located in “src/common”, includes shared API definitions, models, IPC handlers, and Redux actions/reducers.
– External modules: These include proxy handling, various helper utilities (e.g., for HTTP requests, file system operations, etc.), and integration with third-party libraries like i18next.
Architectural Layers and Their Relationships
• At the top level, show the Electron “Host” environment with the Main Process.
• Under the Main Process, include subcomponents such as:
– Router/DI and Application services (files in src/main/di.ts, src/main/event.ts, etc.)
– Database access module (src/main/db)
– API endpoint implementations (inside src/main/redux/sagas/api)
– Tools and utilities (located in src/main/tools, src/main/network, etc.)
– Library Window (with its own Redux store, React components, and IPC integration)
– Reader Window(s) (again with Redux, React view components, and distinct renderers for reading content)
– Model: Redux state and reducers
– Controller: Redux-saga middleware handling asynchronous processes
– View: React components (built as class components, as noted in the README)
API Concept and IPC Communication
• Separate Redux actions and reducers for the various domains (catalog, reader, publication, etc.) that illustrate the flow from action initiation to state updates.
Design Patterns & Technologies
• MVC pattern in each renderer:
– Models (Redux state), Controllers (Redux-saga), and Views (React UI).
• Labels for significant technologies:
– Electron (Main Process)
– React + Redux + Saga (Renderer Processes)
– TypeScript (the entire codebase)
– IPC mechanisms and API endpoints linking processes
Detail Over Breadth
• While the file tree is extensive, focus on capturing the major architectural elements. It is best not to include every single folder/file, but rather to abstract them into logical components.