How purocean/yn works
Main Components
• Main Process (Backend):
– Located in the src/main directory.
– Responsible for core functions such as application startup, window management, app menus, protocol handling, security (encryption for files), and various utilities.
– Contains modules for configuration (config.ts, constant.ts, envs.ts), inter-process communication (jsonrpc.ts), and integration with external services (e.g., file server, pandoc conversion, PlantUML conversion, etc., found under src/main/server).
– Handles extension management (extension.ts) with mechanisms for plug-in support.
• Renderer Process (Frontend):
– Located in the src/renderer directory.
– The UI is built using Vue components (Files with .vue) and managed by Vite (vite.config.mts and vite-env.d.ts), integrating the Monaco editor for Markdown editing.
– Organized into components (e.g., Editor.vue, Previewer.vue, Toolbar/ActionBar.vue), services (for document, export, markdown, repository, etc.), and utilities.
– Contains tests and plugin-related modules (under src/renderer/plugins) that extend functionality via custom and built-in plug-ins.
– Implements rich user interactions such as synchronized scrolling, embedded media support, live preview, and integrated terminal.
• External Tools & Services:
– Integration with pandoc for multi-format export.
– OpenAI integration for auto-completion and a plug-in system for further extensibility.
– File-based storage (local Markdown files are used to persist document data).
Relationships and Interactions
• The Main and Renderer Processes communicate via Electron’s IPC channels (likely using jsonrpc implementations as seen in src/main/jsonrpc.ts and related modules).
• The Main Process initiates app-level services (e.g., auto-updater, window management, command execution) and forwards events/commands to the Renderer Process.
• Renderer components (Vue components) react to user actions and invoke services (located in src/renderer/services) which may then reach back to the Main Process.
• Plug-in architecture: Custom plug-ins are loaded from the plugin directories. They interact with core parts of the editor (both in the Renderer and possibly via main processes) to extend functionality.
• External converters and integrations (pandoc, PlantUML scripts in build and scripts directories) operate as standalone utilities that are invoked by the system as needed.
Architectural Patterns and Design Principles
• Separation of Concerns: Clear separation is maintained between the Electron main process (application lifecycle and OS interactions) and the renderer process (UI and interactive components).
• Modularity and Extensibility: The plug-in system is designed so that extended functionality is nearly “plug-and-play.” This is visible from the dedicated plugins directory and the core extensibility files in both main and renderer areas.
• Component-based UI: Vue components in the renderer process, coupled with a set of services and contexts (like i18n and theming), employ a component-based design.
• Use of IPC for decoupling: Communication between critical modules uses “jsonrpc,” ensuring services remain decoupled and maintainable.
• Integrations with external services: Reliance on external converters and tools (e.g., pandoc, PlantUML) is explicitly part of the architecture.
Relevant Technologies and Frameworks
• Electron – for creating cross-platform desktop applications.
• Vue.js – for rendering the user interface.
• Vite – for module bundling and development environment.
• Monaco Editor – providing a coding experience resembling VSCode.
• Pandoc, PlantUML, Drawio, among others – for document conversion and embedded multimedia support.
• Node.js – underpins the entire development stack, with various scripts for asset management and testing (jest.config.js, ESLint config files).
• Within “Main Process”, include sub-components such as:
• App Startup (app.ts, startup.ts)
• IPC & Configuration (jsonrpc.ts, config.ts)
• Server Modules (found in src/main/server)
• Extension & Plugin Bootstrappers (extension.ts)
• Within “Renderer Process”, include groups for:
• UI Components (from src/renderer/components)
• Service Layers (document, editor, theme, etc.)
• Plugin Management (from src/renderer/plugins)
• Testing and Utilities (tests, support, utils)
• Critical data storage (local Markdown files, encryption workflows) that is central to the application’s functioning.