How ganeshrvel/openmtp works
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: index.jsx App shell · FileExplorerRepository.js Explorer repo · IpcEventHandler.js IPC events · bootHelper.js Boot helper
Components 25
Electron main
OS integration, lifecycle, IPC, and desktop shell control
- App entry · Starts the desktop app and wires startup behavior
app/index.js - Dev main · Development-time Electron main entry
app/main.dev.js - Menu · Builds the application menu and top-level actions
app/menu.js - Boot helper · Boot, window, and platform lifecycle coordination
app/helpers/bootHelper.js - Window helper · Creates and manages app windows and their behavior
app/helpers/windowHelper.js - IPC events · 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 · Maps app routes to pages and code-split screens
app/routing/index.js - App shell · Top-level renderer shell and titlebar/layout composition
app/containers/App/index.jsx - Home page · Main browsing and transfer workspace
app/containers/HomePage/index.jsx - Settings · User settings dialog and profile controls
app/containers/Settings/index.jsx - Onboarding · First-run and feature discovery screens
app/containers/Onboarding/index.jsx - Error boundary · Captures failures and generates error reports
app/containers/ErrorBoundary/index.jsx - Redux store · Application state and dynamic reducer injection
app/store/configureStore/index.js
File transfer domain
File browsing, source selection, and transfer orchestration
- Explorer controller · Coordinates file-explorer actions and repository access
app/data/file-explorer/controllers/FileExplorerController.js - Explorer repo · Selects the active data source for file browsing and transfer
app/data/file-explorer/repositories/FileExplorerRepository.js - Kalam source · Modern MTP path backed by the Kalam native engine
app/data/file-explorer/data-sources/FileExplorerKalamDataSource.js - Legacy source · Compatibility path for older macOS or device cases
app/data/file-explorer/data-sources/FileExplorerLegacyDataSource.js - Local source · 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 · JavaScript bridge to the native Kalam transfer engine
ffi/kalam/src/Kalam.js - Kalam native · Go-based MTP transfer and device operations
ffi/kalam/native/kalam.go - Storage · App settings and profile persistence
app/classes/Storage.js - Updates · Release metadata, download, and update progress flow
app/classes/AppUpdate.js - Analytics · Google Analytics and Mixpanel reporting
app/services/analytics/index.js - Sentry · Crash and error reporting integration
app/services/sentry/index.js
Other components
- MTP device · Connected Android or MTP target
Connections 24
- 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