How yonatanmgr/mathberet works
Main Components
• Electron Main Process: Represented in the “src/main” directory, including files like app.ts, appWindow.ts, and Onboarding.js. This component handles the lifecycle of the application, window management, and communicates with the renderer via IPC.
• Renderer Process: Found in “src/renderer” – the heart of the user interface built with React. Include UI components such as CommandBar, FilesSidebar, Header, MathSidebar, Page components, and various modals. This layer renders the dynamic notebook interface.
• Common Utilities: In “src/common”, these helper modules (keybindings, i18n, shortcuts) are shared across the main and renderer processes.
• Miscellaneous/Window Components: Under “misc/window”, components specifically focus on customizing the window appearance (title bar, window controls) and window-related IPC interactions, further refining the Electron window management.
• Build & Configuration Tools: The “tools” directory holds webpack and electron-forge configurations, and files like package.json, tsconfig.json, and various config files at the project root provide build/test/deployment settings.
Relationships and Interactions
• The Main Process should be drawn on one side to show its role in creating and managing application windows. It communicates with the Renderer Process via Electron’s IPC (as apparent from files like titlebarIPC.ts and appPreload.tsx).
• The Renderer Process, built with React, is responsible for displaying the block-based editor interface, handling drag-and-drop, and integrating with various plugins (like MathLive, Mafs, tldraw, and react-grid-layout).
• The Common Utilities are used by both these processes to maintain consistency in internationalization (i18next), shortcuts, and keybindings.
• The Build & Configuration Tools indicate external tooling that compiles, bundles, and packages the application (using webpack, Electron Forge, etc.)
Architectural Patterns and Key Technologies
• Component-based UI design: Evident from the richly organized “src/renderer/components” folder. Emphasize how loosely-coupled components (like the CommandBar, FilesSidebar, and Page blocks) interact.
• Separation between Main and Renderer processes: A classic Electron pattern with a clear boundary managed by IPC.
• Build and Deployment Pipeline: Configuration files in “tools/webpack” and “tools/forge” show how the app’s code is bundled and packaged for distribution.