How ipfs/ipfs-desktop works
Main components
a. Electron Main Process
b. Electron Renderer Processes (UI)
c. IPFS Daemon (Kubo)
d. IPFS Web UI (embedded in Renderer)
e. OS Integration (Tray/Menu, Auto-launch, Protocol Handlers)
f. Local Storage & Config (Store, Log files, Kubo repo)
g. External Services (IPFS network, update server, analytics)
Relationships & data flows
• The Renderer (UI) communicates with the Main process via IPC (src/common/ipc-main-events.js).
• The Main process uses js-ipfsd-ctl to spawn and manage the Kubo daemon (src/daemon/\*).
• Main ↔ Daemon: control messages (start/stop/migrate/gc), and HTTP API calls for file imports, pins, peer info.
• Main creates a BrowserWindow that loads IPFS Web UI (src/webui/\* and assets downloaded via ipfs-or-gateway).
• Renderer for Files/Peers/Explore screens makes IPC calls to Main, which proxies requests to the daemon’s HTTP API or local store.
• Tray/Menu module (src/tray.js, src/app-menu.js) connects to Main to expose quick actions (import, screenshot, “Open Web UI”).
• Auto-updater module (src/auto-updater/\*) in Main checks GitHub/Snapcraft/chocolatey update endpoints and applies updates via electron-builder config.
• Analytics (src/analytics/\*) in Main batches events to remote telemetry endpoints.
• i18n loader (src/i18n.js) injects localized JSON from assets/locales into both Main and Renderer.
• Configuration store (src/common/store.js) persists user settings to disk; Kubo repo path is read from store or env var.
• On import or screenshot: Renderer triggers Main to call Kubo’s /api/v0/add, then returns CIDs back to Renderer for display and clipboard.
Architectural patterns & design principles
• MVC-like separation between UI (Renderer) and business logic/OS-level features (Main).
• Modular organization under src/: common utilities, dialogs, daemon, tray, webui, metrics.
• Use of Electron IPC as the API layer between UI and native functionality.
• Process isolation: Kubo runs as a separate child process; Web UI runs in a sandboxed BrowserWindow.
• Auto-update and packaging managed declaratively via electron-builder (electron-builder.yml).
Final checklist
• Clear component labels matching folder/module names (e.g., “Tray (src/tray.js)”).
• With relevant file paths or modules for quick reference.