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 @DependencyGraph that aggregates every AppScope contribution
  • 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:

  • ComposeViewport into index.html’s webApp element, with a service worker (sw.js) for notifications and offline reloads and a PWA manifest
  • Web-specific DI (WebAppGraph, which aggregates the same AppScope contributions as DesktopAppGraph)
  • The Room database on SQLite’s OPFS SAH pool, held by one tab at a time
  • WebRadioLinks in core:data’s wasmJsMain: 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 and MeshtasticNavDisplay over sharedNavGraph, which registers every feature’s graphs
  • A host passes only what is its own: visible tabs, window insets, a fallback for an unknown key
  • mapGraph is an expect with 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.feature convention plugin, except feature:widget and feature:xr, which apply meshtastic.android.library
  • Depend on core modules, not on other feature modules. The two exceptions are feature:map-maplibre and feature:coverage, which both build on feature:map and feature:map-terrain
  • Own their navigation entries and DI registrations
  • Contain platform-specific implementations in androidMain/jvmMain/iosMain, and wasmJsMain where 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 in commonMain
  • Platform-specific code goes in appropriate source set
  • Prefer interfaces + DI over expect/actual for complex behaviors
  • Use expect/actual only for simple declarations

Dependency Injection

The project uses Metro (Kotlin compiler plugin, applied through meshtastic.metro) with AppScope aggregation:

  • @ContributesBinding, @ContributesTo and @ContributesIntoMap register 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 @ViewModelKey and built through metrox-viewmodel; MeshtasticDiRoot provides 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 through graphAccessor<T>(), where T is 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 uses Navigation 3 with typed routes:

  • All routes defined in core/navigation/Routes.kt
  • Routes are @Serializable data classes/objects, and each sealed route interface is registered in MeshtasticNavSavedStateConfig (NavigationConfig.kt) for saved-state restoration
  • Deep links resolved through DeepLinkRouter
  • Each feature registers its own navigation entries

See Navigation & Deep Links for details.