How fearlessgeekmedia/geekdown works
Project Type and Purpose
• GeekDown is a desktop Markdown editor built with Electron.
• It uses Milkdown (with Crepe), W3.css for styling, and Electron as the host environment.
• The goal is a cross-platform (Linux, macOS, Windows) Markdown editor with live preview and basic file operations.
Main Architectural Components
a. Electron Main Process
• Entry point: main.js
• Responsibilities: application lifecycle, window creation, IPC listeners for file operations.
b. Preload Script
• File: preload.js
• Purpose: expose a secure, limited API (via contextBridge) to the renderer for file I/O and OS interactions.
c. Renderer Process (UI Layer)
• HTML/CSS: index.html, w3.css
• JavaScript modules handling UI actions and Markdown rendering:
• index.ts (primary renderer bootstrap)
• Feature scripts: newfile.js, openfile.js, savefile.js, closefile.js, exportfile.js, image-upload.js, fontsettings.js, hotkeys.js, togglemode.js
• Markdown engine: Milkdown + Crepe plugin + upload plugin
d. Build & Dev Tooling
• Vite for bundling/rendering in dev mode (vite.config.js)
• NPM scripts and dependencies defined in package.json (electron:dev, electron:build)
• Electron Builder for packaging (output in electron-dist)
Relationships and Data Flows
• Renderer → Preload: invokes exposed APIs (e.g., openFile, saveFile)
• Preload → Main: relays IPC calls to perform file system operations
• Main → Renderer: sends back file contents or error messages
• Renderer UI: user enters Markdown → Milkdown parser/render engine produces HTML → displayed in preview pane
• Build pipeline: Vite serves hot-reload content to renderer in dev mode; on build, Electron Builder packages the app
Architectural Patterns & Design Principles
• Separation of concerns:
• Main process handles OS-level tasks (file system, window management)
• Renderer strictly handles presentation and user interactions
• Preload layer as a secure boundary
• Modular UI: each feature (new/open/save/export/toggle) lives in its own JS file
• Plugin-based Markdown engine: Milkdown core + Crepe plugin + upload plugin