Architecture
The Meshtastic Android and Desktop apps follow a modular Kotlin Multiplatform (KMP) architecture with clear layer boundaries. iOS is a compile-only validation target; no iOS app ships.
Layer Overview
βββββββββββββββββββββββββββββββββββββββββββββββ
β androidApp / desktopApp β Platform entry points
βββββββββββββββββββββββββββββββββββββββββββββββ€
β feature/* modules β UI + Business Logic
βββββββββββββββββββββββββββββββββββββββββββββββ€
β core/* modules β Shared infrastructure
βββββββββββββββββββββββββββββββββββββββββββββββ€
β Platform (Android/JVM/iOS) β OS-specific bindings
βββββββββββββββββββββββββββββββββββββββββββββββ
Module Categories
androidApp/ β Android Application
The Android application entry point:
- Activity, Application, and Manifest definitions
- Koin DI module composition (
AppKoinModule) - Flavor-specific bindings (
google/,fdroid/) - Android-only integrations (widgets, services)
desktopApp/ β Desktop JVM Application
The Desktop (Linux/macOS/Windows) entry point:
- Compose Desktop window management
- Desktop-specific DI (
DesktopKoinModule) - Platform stubs for Android-only capabilities
DesktopRadioTransportFactory, which wires up the transports. The transports themselves are shared code incore:network: BLE built oncore:bleβs primitives, TCP, and the jSerialComm-basedSerialTransportincore:networkβsjvmMain
feature/* β Feature Modules
Each feature/ module owns a vertical slice of functionality:
| Module | Responsibility |
|---|---|
feature:intro | Onboarding/welcome flow |
feature:messaging | Messages, channels, contacts, quick chat |
feature:connections | Bluetooth/USB/TCP connection management |
feature:map | Map display, waypoints β shared state, policy and the waypoint editor |
feature:map-maplibre | MapLibre map surfaces β used by the fdroid flavor and Desktop; the google flavor uses Google Maps instead. Tile-source definitions and the custom-source editor are in feature:map, so both renderers share them |
feature:map-terrain | Offline terrain: elevation decode, hillshade shading and contour lines, shared by both map flavors |
feature:coverage | Site Planner coverage computed on the device with kp1812 (ITU-R P.1812) over Mapterhorn terrain, returned as GeoJSON for the mapβs layer list |
feature:node | Node list, node detail, metrics |
feature:settings | All configuration screens |
feature:firmware | Firmware update flow |
feature:docs | In-app documentation browser |
feature:wifi-provision | Wi-Fi provisioning |
feature:widget | Android home screen widgets (an Android library, not KMP) |
feature:discovery | Mesh network discovery |
Feature modules:
- Use the
meshtastic.kmp.featureconvention plugin, exceptfeature:widget, which appliesmeshtastic.android.library - Depend on
coremodules, not on otherfeaturemodules. The two exceptions arefeature:map-maplibreandfeature:coverage, which both build onfeature:mapandfeature:map-terrain - Own their navigation entries and DI registrations
- Contain platform-specific implementations in
androidMain/jvmMain/iosMain
core/* β Core Modules
Shared infrastructure used by all features:
| Module | Responsibility |
|---|---|
core:common | Utilities, extensions, build config |
core:navigation | Routes, deep links, Navigation 3 |
core:ui | Shared Compose components, icons, theme |
core:resources | Shared string resources |
core:model | Domain models |
core:data | Repository implementations, data sources and managers |
core:domain | Use cases / business logic |
core:database | Room KMP database |
core:datastore | DataStore preferences |
core:prefs | App preferences |
core:repository | Repository interfaces |
core:service | Mesh service layer |
core:di | DI utilities |
core:network | HTTP/serial/transport |
core:ble | Bluetooth LE abstractions |
core:barcode | QR / barcode scanning (channel-share QR codes); Android library |
core:nfc | NFC read/write support; Android library |
core:takserver | Embedded TAK server integration |
core:testing | Test utilities |
core:konsist | Konsist architecture/convention tests |
Protobuf models come from the external org.meshtastic:protobufs Maven artifact (pinned in gradle/libs.versions.toml).
Build and test modules
These ship no app code. Theyβre kept out of Dokka and Kover aggregation and kmpSmokeCompile, and scripts/check-module-list.py exempts them.
| Module | Responsibility |
|---|---|
screenshot-tests | Compose Preview screenshot tests, the visual-regression gate |
docs-screenshots | Doc-framed screenshot compositions, generate-only |
store-screenshots | Store-listing screenshots captured from the real app with UiAutomator |
baselineprofile | Baseline Profile generator and startup benchmark for androidApp |
schema-strings | Generates schema_strings.xml from the protobufs field metadata |
core:konsist is exempt from aggregation too.
KMP Source Sets
Each module uses the standard KMP source set hierarchy:
src/
βββ commonMain/ β Shared code (all platforms)
βββ commonTest/ β Shared tests
βββ androidMain/ β Android-specific
βββ jvmMain/ β Desktop JVM-specific
βββ jvmAndroidMain/ β Shared by Android and desktop JVM
βββ iosMain/ β iOS-specific
βββ nativeMain/ β Kotlin/Native code, built for the one iOS target (iosSimulatorArm64)
βββ jvmTest/ β Desktop test host
βββ androidHostTest/ β Android host (JVM) unit tests
βββ androidDeviceTest/ β Instrumented tests (core:database, core:model)
jvmAndroidMain exists only in modules that apply meshtastic.kmp.jvm.android. nativeMain, androidHostTest (modules that call withHostTest) and androidDeviceTest exist only in the modules that need them.
Golden Rules:
- No
android.*imports incommonMain - Platform-specific code goes in appropriate source set
- Prefer interfaces + DI over
expect/actualfor complex behaviors - Use
expect/actualonly for simple declarations
Dependency Injection
The project uses Koin with annotation processing:
@Module,@Single,@Factoryannotations@ComponentScanfor automatic registration- Feature modules export their own
Feature*Moduleclass - App/Desktop compose all modules in their root DI configuration
Radio Control
Features send commands to the node through RadioController (core:repository), a composite of four focused sub-interfaces so callers can depend on just the slice they need:
| Sub-interface | Responsibility |
|---|---|
AdminController | Config, channels, owner, device lifecycle, editSettings { } transactions |
MessagingController | Send packets, reactions, shared contacts |
NodeController | Favorite, ignore, mute, remove nodes |
QueryController | Telemetry, traceroute, position/user-info queries |
RadioControllerImpl (core:service) is the in-process composition root for all targets (Desktop, iOS, single-process Android). It assembles the four sub-controllers via Kotlin interface delegation and adds the cross-cutting concerns (connection state, packet-id, location, device-address switching). Commands are direct suspend calls; admin writes are fire-and-forget because the device is the source of truth (local persistence is an optimistic cache). The layered shape mirrors the meshtastic-sdk AdminApi/TelemetryApi design to ease a future SDK migration.
Service Repository
ServiceRepository is the reactive bridge between the mesh service and all feature/UI layers. It is decomposed into focused provider interfaces following the Interface Segregation Principle:
| Interface | Responsibility |
|---|---|
ConnectionStateProvider | Read-only connectionState, plus connectionLifecycle and connectionEpochs for code that has to correlate state with connection departures and completed handshakes |
TracerouteResponseProvider | Traceroute response state + clear |
NeighborInfoResponseProvider | Neighbor info response state + clear |
ServiceStateWriter | Write-side for handlers (set, emit, clear*) |
ServiceRepository extends all four interfaces β consumers inject the narrowest interface they actually need. For example, ContactsViewModel injects only ConnectionStateProvider rather than the entire ServiceRepository, preventing accidental access to write operations from UI code. RadioController also extends ConnectionStateProvider so VMs that already inject a controller sub-interface can read connection state without a separate dependency.
Navigation
Navigation uses Navigation 3 with typed routes:
- All routes defined in
core/navigation/Routes.kt - Routes are
@Serializabledata classes/objects, and each sealed route interface is registered inMeshtasticNavSavedStateConfig(NavigationConfig.kt) for saved-state restoration - Deep links resolved through
DeepLinkRouter - Each feature registers its own navigation entries
See Navigation & Deep Links for details.