Architecture
The Meshtastic Android, Desktop and web 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 / webApp β Platform entry points
βββββββββββββββββββββββββββββββββββββββββββββββ€
β feature/* modules β UI + Business Logic
βββββββββββββββββββββββββββββββββββββββββββββββ€
β core/* modules β Shared infrastructure
βββββββββββββββββββββββββββββββββββββββββββββββ€
β Platform (Android/JVM/wasm/iOS) β OS-specific bindings
βββββββββββββββββββββββββββββββββββββββββββββββ
Module Categories
androidApp/ β Android Application
The Android application entry point:
- Activity, Application, and Manifest definitions
- The Metro
AndroidAppGraph, one@DependencyGraphthat aggregates everyAppScopecontribution - 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 (
DesktopAppGraph) - Platform stubs for Android-only capabilities
webApp/ β Web Application
The browser (Kotlin/Wasm) entry point, opt-in with -Pmeshtastic.web=true; see webApp/README.md:
ComposeViewportintoindex.htmlβswebAppelement, with a service worker (sw.js) for notifications and offline reloads and a PWA manifest- Web-specific DI (
WebAppGraph, which aggregates the sameAppScopecontributions asDesktopAppGraph) - The Room database on SQLiteβs OPFS SAH pool, held by one tab at a time
WebRadioLinksincore:dataβswasmJsMain: BLE through Kable over Web Bluetooth, Web Serial, and WebSocket; no raw TCP
appShell/ β Shared Main Screen
The screen the Android, desktop and web hosts all show:
MeshtasticMainScreen: the app shell, navigation suite andMeshtasticNavDisplayoversharedNavGraph, which registers every featureβs graphs- A host passes only what is its own: visible tabs, window insets, a fallback for an unknown key
mapGraphis anexpectwith an empty web actual, since the map has no web target
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/WebSocket 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:xr | Android XR spatial shell: Full Space and an orbiter on a headset (an Android library, not KMP; google flavor only) |
feature:discovery | Mesh network discovery |
Feature modules:
- Use the
meshtastic.kmp.featureconvention plugin, exceptfeature:widgetandfeature:xr, which applymeshtastic.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, andwasmJsMainwhere the module has a web target
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; each platformβs RadioLinks, which build the selected radioβs SDK client |
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, MQTT and LAN discovery |
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
βββ wasmJsMain/ β Browser-specific
βββ nonWebMain/ β Shared by every target except wasmJs (`nonWebTest/` holds its tests)
βββ nonAndroidMain/ β Shared by every target except Android
βββ 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. wasmJsMain, nonWebMain and nonAndroidMain exist only in modules that apply meshtastic.kmp.web, and the wasmJs target itself is registered only with -Pmeshtastic.web=true (webApp/README.md).
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 Metro (Kotlin compiler plugin, applied through meshtastic.metro) with AppScope aggregation:
@ContributesBinding,@ContributesToand@ContributesIntoMapregister a class or binding container from any module; there are no per-module DI classes to include- Each app entry point (
androidApp,desktopApp,webApp) declares one@DependencyGraph(AppScope::class)in a platform source set, and the graph picks up every contribution on its classpath - ViewModels are contributed with
@ViewModelKeyand built throughmetrox-viewmodel;MeshtasticDiRootprovides the factory at each composition root - Composables get dependencies through ViewModels. Android framework classes (
Service,BroadcastReceiver, Glance widgets) and composition-root glue reach the graph throughgraphAccessor<T>(), whereTis an@ContributesTo(AppScope::class)accessor interface declared in the same module and source set
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 on the active sessionβs meshtastic-sdk client, whose AdminApi/TelemetryApi layering the controllers mirror. An acknowledged local admin write reaches the appβs repositories through the SDK session events (ConfigChanged, ChannelsChanged, NodeChanged); the device remains the source of truth and reports its full config on every connection.
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 |
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.