# ganeshrvel/openmtp architecture

> Architecture diagram of the GitHub repository ganeshrvel/openmtp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ganeshrvel/openmtp
- Repository: https://github.com/ganeshrvel/openmtp

## Overview

1. **What this repo is**
   - OpenMTP is a macOS Electron desktop app for transferring files to Android/MTP devices over USB.
   - The architecture is split into an Electron **main process** for OS/device integration and a React **renderer process** for the UI.

2. **Top-level runtime boundary**
   - `app/index.js`, `main.dev.js`, `menu.js`, `helpers/`, and `services/ipc-events/` belong to the Electron-side control plane.
   - `app/containers/`, `app/components/`, `app/routing/`, and `app/store/` make up the renderer-side application shell.

3. **UI shell and navigation**
   - The app is organized around routed screens: **Home/File Explorer**, **Settings**, **Onboarding**, **Update**, **Help/FAQ**, **Keyboard Shortcuts**, **Privacy Policy**, **Report Bugs**, and an **Error Boundary**.
   - Most screens are code-split with `Loadable.js`, so non-core pages are loaded on demand.

4. **State management**
   - Redux is the central state layer, with feature-specific `actions.js`, `reducers.js`, and `selectors.js`.
   - The store supports dynamic reducer injection (`store/reducers/withReducer.js`), which matches the code-splitting model used by the UI.

5. **Primary product flow: file browsing and transfer**
   - The main user journey is in `containers/HomePage`, which composes the file explorer, sidebar, toolbar, breadcrumb, and table/list/grid renderers.
   - This screen is the UI for browsing both the local Mac filesystem and the connected device filesystem, selecting items, and initiating copy/move/rename/delete style operations.

6. **File explorer domain layer**
   - Under `app/data/file-explorer/`, a `FileExplorerController` coordinates a `FileExplorerRepository`, which in turn switches between multiple data sources.
   - The repository/data-source split is the key boundary for device access: UI actions do not talk to the kernel directly; they go through this domain layer.

7. **MTP backend variants**
   - There are three file-explorer data sources: **Kalam**, **Legacy**, and **Local**.
   - **Kalam** is the new MTP kernel path for modern macOS/devices.
   - **Legacy** exists as a compatibility fallback for older macOS/device cases.
   - **Local** models the Mac side of the split-pane explorer.

8. **Native kernel boundary**
   - The modern transfer engine lives in `ffi/kalam/`, with Go native code under `ffi/kalam/native/` and a JS bridge in `ffi/kalam/src/Kalam.js`.
   - Built native artifacts are bundled under `build/mac/bin/...`, including platform/arch-specific binaries and libraries.
   - This is the most important non-UI boundary in the repo: JavaScript coordinates the app, while the native/Go layer performs high-performance MTP operations.

9. **OS integration and lifecycle**
   - The main process handles app boot, windows, menus, titlebar behavior, permissions, and platform-specific helpers.
   - Helper modules such as `windowHelper`, `createWindows`, `bootHelper`, `titlebarDoubleClick`, `remoteWindowHelpers`, and `deviceInfo` indicate that window management and macOS behavior are treated as first-class concerns.

10. **Persistence and configuration**
   - App settings/profile data are persisted through `classes/Storage.js` plus `helpers/storageHelper.js` and `helpers/settings.js`.
   - Runtime configuration comes from `config/env/*`, `app/constants/*`, and `app/templates/*`, which provide environment-aware paths, feature constants, menus, onboarding content, and page templates.

11. **Cross-cutting services**
   - Error reporting is handled with Sentry, including a dedicated error boundary and report-generation UI.
   - Analytics integrations exist for Google Analytics and Mixpanel.
   - IPC event types/handlers provide the bridge between renderer actions and main-process capabilities.

12. **Update and release path**
   - App update functionality is a dedicated subsystem (`classes/AppUpdate.js`, `containers/AppUpdatePage/`) driven by release metadata and update progress UI.
   - The repository also includes packaging/signing/notarization infrastructure, plus CI/CD scripts and Electron Builder config, showing that release engineering is part of the architecture rather than an afterthought.

13. **Styling and shared UI primitives**
   - Shared UI building blocks live in `app/components/` such as dialogs, snackbars, breadcrumbs, and loading indicators.
   - Styling is mixed between JSS-style JS modules and SCSS, with a global style layer under `app/styles/`.

14. **Diagram takeaway**
   - A good architecture diagram should show: **Renderer UI → Redux/domain/controller layer → IPC/main process → native Kalam/legacy MTP backend → Android/MTP device**, with side paths for **storage**, **updates**, **analytics/error reporting**, and **macOS window/permission management**.

Main entry points: [`app/containers/App/index.jsx`](https://github.com/ganeshrvel/openmtp/blob/master/app/containers/App/index.jsx) (App shell), [`app/data/file-explorer/repositories/FileExplorerRepository.js`](https://github.com/ganeshrvel/openmtp/blob/master/app/data/file-explorer/repositories/FileExplorerRepository.js) (Explorer repo), [`app/services/ipc-events/IpcEventHandler.js`](https://github.com/ganeshrvel/openmtp/blob/master/app/services/ipc-events/IpcEventHandler.js) (IPC events), [`app/helpers/bootHelper.js`](https://github.com/ganeshrvel/openmtp/blob/master/app/helpers/bootHelper.js) (Boot helper)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime_main["Electron main"]
  node_app_index["App entry<br/>electron bootstrap<br/>[index.js]"]
  node_main_dev["Dev main<br/>electron dev entry<br/>[main.dev.js]"]
  node_menu["Menu<br/>[menu.js]"]
  node_helpers_boot["Boot helper<br/>startup helper<br/>[bootHelper.js]"]
  node_helpers_window["Window helper<br/>[windowHelper.js]"]
  node_ipc_events["IPC events<br/>ipc bridge<br/>[IpcEventHandler.js]"]
end

subgraph group_runtime_renderer["Renderer UI"]
  node_routing["Routing<br/>route map<br/>[index.js]"]
  node_app_shell["App shell<br/>root container<br/>[index.jsx]"]
  node_home_page["Home page<br/>file explorer UI<br/>[index.jsx]"]
  node_settings_page["Settings<br/>preferences UI<br/>[index.jsx]"]
  node_onboarding_page["Onboarding<br/>intro UI<br/>[index.jsx]"]
  node_error_boundary["Error boundary<br/>error UI<br/>[index.jsx]"]
  node_redux_store["Redux store<br/>state container<br/>[index.js]"]
end

subgraph group_domain_transfer["File transfer domain"]
  node_file_controller["Explorer controller<br/>domain controller"]
  node_file_repo["Explorer repo<br/>domain repository"]
  node_kalam_ds["Kalam source<br/>mtp data source"]
  node_legacy_ds["Legacy source<br/>mtp fallback"]
  node_local_ds["Local source<br/>local filesystem"]
end

subgraph group_native_release["Native and release"]
  node_kalam_bridge["Kalam bridge<br/>ffi bridge<br/>[Kalam.js]"]
  node_kalam_native["Kalam native<br/>go native engine<br/>[kalam.go]"]
  node_storage["Storage<br/>persistence<br/>[Storage.js]"]
  node_update_system["Updates<br/>update subsystem<br/>[AppUpdate.js]"]
  node_analytics["Analytics<br/>telemetry<br/>[index.js]"]
  node_sentry["Sentry<br/>error reporting<br/>[index.js]"]
end

node_device[("MTP device<br/>android device")]

node_app_index -->|"boot"| node_helpers_boot
node_app_index -->|"menu"| node_menu
node_main_dev -->|"dev boot"| node_helpers_boot
node_helpers_boot -->|"create"| node_helpers_window
node_helpers_window -->|"wire IPC"| node_ipc_events
node_menu -->|"dispatch"| node_ipc_events
node_routing -->|"mount"| node_app_shell
node_app_shell -->|"open"| node_home_page
node_app_shell -->|"open"| node_settings_page
node_app_shell -->|"open"| node_onboarding_page
node_app_shell -->|"guard"| node_error_boundary
node_app_shell -->|"state"| node_redux_store
node_home_page -->|"browse"| node_file_controller
node_settings_page -->|"persist"| node_storage
node_file_controller -->|"coordinate"| node_file_repo
node_file_repo -->|"use"| node_kalam_ds
node_file_repo -->|"fallback"| node_legacy_ds
node_file_repo -->|"use"| node_local_ds
node_kalam_ds -->|"ffi"| node_kalam_bridge
node_kalam_bridge -->|"invoke"| node_kalam_native
node_kalam_native -->|"transfer"| node_device
node_update_system -->|"notify"| node_ipc_events
node_analytics -->|"track"| node_ipc_events
node_sentry -->|"report"| node_error_boundary

click node_app_index "https://github.com/ganeshrvel/openmtp/blob/master/app/index.js"
click node_main_dev "https://github.com/ganeshrvel/openmtp/blob/master/app/main.dev.js"
click node_menu "https://github.com/ganeshrvel/openmtp/blob/master/app/menu.js"
click node_helpers_boot "https://github.com/ganeshrvel/openmtp/blob/master/app/helpers/bootHelper.js"
click node_helpers_window "https://github.com/ganeshrvel/openmtp/blob/master/app/helpers/windowHelper.js"
click node_ipc_events "https://github.com/ganeshrvel/openmtp/blob/master/app/services/ipc-events/IpcEventHandler.js"
click node_routing "https://github.com/ganeshrvel/openmtp/blob/master/app/routing/index.js"
click node_app_shell "https://github.com/ganeshrvel/openmtp/blob/master/app/containers/App/index.jsx"
click node_home_page "https://github.com/ganeshrvel/openmtp/blob/master/app/containers/HomePage/index.jsx"
click node_settings_page "https://github.com/ganeshrvel/openmtp/blob/master/app/containers/Settings/index.jsx"
click node_onboarding_page "https://github.com/ganeshrvel/openmtp/blob/master/app/containers/Onboarding/index.jsx"
click node_error_boundary "https://github.com/ganeshrvel/openmtp/blob/master/app/containers/ErrorBoundary/index.jsx"
click node_redux_store "https://github.com/ganeshrvel/openmtp/blob/master/app/store/configureStore/index.js"
click node_file_controller "https://github.com/ganeshrvel/openmtp/blob/master/app/data/file-explorer/controllers/FileExplorerController.js"
click node_file_repo "https://github.com/ganeshrvel/openmtp/blob/master/app/data/file-explorer/repositories/FileExplorerRepository.js"
click node_kalam_ds "https://github.com/ganeshrvel/openmtp/blob/master/app/data/file-explorer/data-sources/FileExplorerKalamDataSource.js"
click node_legacy_ds "https://github.com/ganeshrvel/openmtp/blob/master/app/data/file-explorer/data-sources/FileExplorerLegacyDataSource.js"
click node_local_ds "https://github.com/ganeshrvel/openmtp/blob/master/app/data/file-explorer/data-sources/FileExplorerLocalDataSource.js"
click node_kalam_bridge "https://github.com/ganeshrvel/openmtp/blob/master/ffi/kalam/src/Kalam.js"
click node_kalam_native "https://github.com/ganeshrvel/openmtp/blob/master/ffi/kalam/native/kalam.go"
click node_storage "https://github.com/ganeshrvel/openmtp/blob/master/app/classes/Storage.js"
click node_update_system "https://github.com/ganeshrvel/openmtp/blob/master/app/classes/AppUpdate.js"
click node_analytics "https://github.com/ganeshrvel/openmtp/blob/master/app/services/analytics/index.js"
click node_sentry "https://github.com/ganeshrvel/openmtp/blob/master/app/services/sentry/index.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app_index,node_main_dev,node_menu,node_helpers_boot,node_helpers_window,node_ipc_events toneBlue
class node_routing,node_app_shell,node_home_page,node_settings_page,node_onboarding_page,node_error_boundary,node_redux_store toneAmber
class node_file_controller,node_file_repo,node_kalam_ds,node_legacy_ds,node_local_ds toneMint
class node_kalam_bridge,node_kalam_native,node_storage,node_update_system,node_analytics,node_sentry toneRose
class node_device toneNeutral
```

## Components

### Electron main

OS integration, lifecycle, IPC, and desktop shell control

- [App entry](https://github.com/ganeshrvel/openmtp/blob/master/app/index.js): electron bootstrap · Starts the desktop app and wires startup behavior · `app/index.js`
- [Dev main](https://github.com/ganeshrvel/openmtp/blob/master/app/main.dev.js): electron dev entry · Development-time Electron main entry · `app/main.dev.js`
- [Menu](https://github.com/ganeshrvel/openmtp/blob/master/app/menu.js): app menu · Builds the application menu and top-level actions · `app/menu.js`
- [Boot helper](https://github.com/ganeshrvel/openmtp/blob/master/app/helpers/bootHelper.js): startup helper · Boot, window, and platform lifecycle coordination · `app/helpers/bootHelper.js`
- [Window helper](https://github.com/ganeshrvel/openmtp/blob/master/app/helpers/windowHelper.js): window helper · Creates and manages app windows and their behavior · `app/helpers/windowHelper.js`
- [IPC events](https://github.com/ganeshrvel/openmtp/blob/master/app/services/ipc-events/IpcEventHandler.js): ipc bridge · Event types and handlers between renderer and main process · `app/services/ipc-events/IpcEventHandler.js`

### Renderer UI

React screens, routed views, and shared presentation

- [Routing](https://github.com/ganeshrvel/openmtp/blob/master/app/routing/index.js): route map · Maps app routes to pages and code-split screens · `app/routing/index.js`
- [App shell](https://github.com/ganeshrvel/openmtp/blob/master/app/containers/App/index.jsx): root container · Top-level renderer shell and titlebar/layout composition · `app/containers/App/index.jsx`
- [Home page](https://github.com/ganeshrvel/openmtp/blob/master/app/containers/HomePage/index.jsx): file explorer UI · Main browsing and transfer workspace · `app/containers/HomePage/index.jsx`
- [Settings](https://github.com/ganeshrvel/openmtp/blob/master/app/containers/Settings/index.jsx): preferences UI · User settings dialog and profile controls · `app/containers/Settings/index.jsx`
- [Onboarding](https://github.com/ganeshrvel/openmtp/blob/master/app/containers/Onboarding/index.jsx): intro UI · First-run and feature discovery screens · `app/containers/Onboarding/index.jsx`
- [Error boundary](https://github.com/ganeshrvel/openmtp/blob/master/app/containers/ErrorBoundary/index.jsx): error UI · Captures failures and generates error reports · `app/containers/ErrorBoundary/index.jsx`
- [Redux store](https://github.com/ganeshrvel/openmtp/blob/master/app/store/configureStore/index.js): state container · Application state and dynamic reducer injection · `app/store/configureStore/index.js`

### File transfer domain

File browsing, source selection, and transfer orchestration

- [Explorer controller](https://github.com/ganeshrvel/openmtp/blob/master/app/data/file-explorer/controllers/FileExplorerController.js): domain controller · Coordinates file-explorer actions and repository access · `app/data/file-explorer/controllers/FileExplorerController.js`
- [Explorer repo](https://github.com/ganeshrvel/openmtp/blob/master/app/data/file-explorer/repositories/FileExplorerRepository.js): domain repository · Selects the active data source for file browsing and transfer · `app/data/file-explorer/repositories/FileExplorerRepository.js`
- [Kalam source](https://github.com/ganeshrvel/openmtp/blob/master/app/data/file-explorer/data-sources/FileExplorerKalamDataSource.js): mtp data source · Modern MTP path backed by the Kalam native engine · `app/data/file-explorer/data-sources/FileExplorerKalamDataSource.js`
- [Legacy source](https://github.com/ganeshrvel/openmtp/blob/master/app/data/file-explorer/data-sources/FileExplorerLegacyDataSource.js): mtp fallback · Compatibility path for older macOS or device cases · `app/data/file-explorer/data-sources/FileExplorerLegacyDataSource.js`
- [Local source](https://github.com/ganeshrvel/openmtp/blob/master/app/data/file-explorer/data-sources/FileExplorerLocalDataSource.js): local filesystem · Mac-side filesystem model for the split-pane explorer · `app/data/file-explorer/data-sources/FileExplorerLocalDataSource.js`

### Native and release

Native Kalam engine, persistence, analytics, updates, and packaging

- [Kalam bridge](https://github.com/ganeshrvel/openmtp/blob/master/ffi/kalam/src/Kalam.js): ffi bridge · JavaScript bridge to the native Kalam transfer engine · `ffi/kalam/src/Kalam.js`
- [Kalam native](https://github.com/ganeshrvel/openmtp/blob/master/ffi/kalam/native/kalam.go): go native engine · Go-based MTP transfer and device operations · `ffi/kalam/native/kalam.go`
- [Storage](https://github.com/ganeshrvel/openmtp/blob/master/app/classes/Storage.js): persistence · App settings and profile persistence · `app/classes/Storage.js`
- [Updates](https://github.com/ganeshrvel/openmtp/blob/master/app/classes/AppUpdate.js): update subsystem · Release metadata, download, and update progress flow · `app/classes/AppUpdate.js`
- [Analytics](https://github.com/ganeshrvel/openmtp/blob/master/app/services/analytics/index.js): telemetry · Google Analytics and Mixpanel reporting · `app/services/analytics/index.js`
- [Sentry](https://github.com/ganeshrvel/openmtp/blob/master/app/services/sentry/index.js): error reporting · Crash and error reporting integration · `app/services/sentry/index.js`

### Other components

- **MTP device**: android device · Connected Android or MTP target

## Connections

- App entry → Boot helper: boot · Initial startup flow
- App entry → Menu: menu · Builds the desktop menu
- Dev main → Boot helper: dev boot · Development startup path
- Boot helper → Window helper: create · Opens and manages windows
- Window helper → IPC events: wire IPC · Connects window lifecycle to renderer communication
- Menu → IPC events: dispatch · Menu actions emit app events
- Routing → App shell: mount · Routes render into the shell
- App shell → Home page: open · Primary file explorer screen
- App shell → Settings: open · Preferences screen
- App shell → Onboarding: open · First-run and feature pages
- App shell → Error boundary: guard · Catches renderer failures
- App shell → Redux store: state · Renderer state orchestration
- Home page → Explorer controller: browse · File explorer actions flow into the domain layer
- Settings → Storage: persist · Stores user preferences
- Explorer controller → Explorer repo: coordinate · Controller delegates source selection and operations
- Explorer repo → Kalam source: use · Modern MTP data source
- Explorer repo → Legacy source: fallback · Compatibility data source
- Explorer repo → Local source: use · Local Mac filesystem source
- Kalam source → Kalam bridge: ffi · JS calls into the native bridge
- Kalam bridge → Kalam native: invoke · Bridge forwards transfer operations to Go native code
- Kalam native → MTP device: transfer · Performs high-performance MTP device operations
- Updates → IPC events: notify · Update flow surfaces via app events
- Analytics → IPC events: track · Telemetry and usage events are emitted from app actions
- Sentry → Error boundary: report · Error UI feeds reporting workflow
