# maltegrosse/go-modemmanager architecture

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

- Interactive diagram: https://gitdiagram.com/maltegrosse/go-modemmanager
- Repository: https://github.com/maltegrosse/go-modemmanager

## Overview

**1) What this repository is**
This is a Go library that provides D-Bus bindings for the Linux **ModemManager** service. It is not an application; it is an API layer that lets Go code inspect and control modems through the system D-Bus rather than talking to the modem hardware directly.

**2) Main architectural boundary**
The key boundary is between:
- **Consumers of this Go package**: your application code
- **The external ModemManager daemon on the system D-Bus**
- **The modem hardware and transport modes underneath ModemManager** (QMI, AT, etc.)

This repo mainly models the D-Bus API exposed by ModemManager and forwards method calls and property access across that boundary.

**3) Central entry point**
`ModemManager.go` is the top-level root of the API. It represents the ModemManager service itself and is the likely starting point for discovering modems and working with the service-wide interface.

**4) Object model: one file per D-Bus interface**
The repository is organized around ModemManager’s D-Bus interfaces, with a Go file per major interface:
- `Modem.go`
- `ModemSimple.go`
- `Modem3gpp.go`
- `ModemCdma.go`
- `ModemMessaging.go`
- `ModemLocation.go`
- `ModemSignal.go`
- `ModemFirmware.go`
- `ModemUssd.go`
- `ModemVoice.go`
- `ModemOma.go`
- `ModemTime.go`
- `Sim.go`
- `Bearer.go`
- `Sms.go`
- `Call.go`

This structure strongly mirrors the underlying D-Bus API, so the package architecture is interface-centric rather than layered around business logic.

**5) How data flows through the library**
The typical flow is:
1. Client code discovers a modem or related object through the ModemManager service
2. The code wraps that D-Bus object in the relevant Go type
3. Methods and property accessors on that wrapper translate Go calls into D-Bus requests
4. Replies, errors, and signals are converted back into Go values and enums

So the repo acts as a translation layer between typed Go code and untyped/loosely typed D-Bus messages.

**6) Modem-related subsystems**
The package splits modem functionality into functional subsystems:
- **Connectivity and bearer management**: `Modem.go`, `Bearer.go`, `ModemSimple.go`
- **Cellular network registration and 3GPP/CDMA behavior**: `Modem3gpp.go`, `ModemCdma.go`
- **Messaging and voice**: `ModemMessaging.go`, `Sms.go`, `Call.go`, `ModemVoice.go`
- **Location and time**: `ModemLocation.go`, `ModemTime.go`
- **Radio state and signal quality**: `ModemSignal.go`
- **Firmware and provisioning**: `ModemFirmware.go`, `Sim.go`
- **USSD and OMA**: `ModemUssd.go`, `ModemOma.go`

This separation is important for architecture diagrams because each subsystem maps to a distinct part of the ModemManager API and can be used independently.

**7) Type safety and protocol modeling**
`enums.go` plus the many `*_string.go` files define the package’s typed constants and string representations for ModemManager enums and error values. These files cover:
- modem state and reasons
- registration states
- signal and access technologies
- SMS, call, bearer, firmware, SIM, OMA, and error enums

This is a significant design point: the library tries to preserve ModemManager semantics in Go types instead of passing raw integers everywhere.

**8) Shared plumbing**
`utils.go` and the common `Call.go`/wrapper patterns likely hold reusable helpers for D-Bus interaction, type conversion, and signal/event handling. The repository appears to centralize repeated D-Bus marshaling logic so the per-interface files stay focused on interface-specific operations.

**9) Examples and usage shape**
The `examples/` directory contains small programs like:
- `check_interfaces.go`
- `test_listener.go`
- `test_run.go`

These examples suggest the package supports both:
- synchronous API usage for querying/modifying modem state
- listener-style consumption of D-Bus signals/events

That implies the library is intended for long-running system software, service daemons, or CLI tools that need live modem state.

**10) External dependencies and operating assumptions**
The README makes the operational context clear:
- It targets the **system D-Bus**
- It depends on the **ModemManager** daemon being installed and running
- It was tested against **ModemManager 1.12.8** and Go 1.13
- Real-world behavior depends on modem mode and capabilities: QMI vs AT, plus per-device feature support

So the architecture is not just “Go package internals”; it is a thin typed client layered over a specific Linux service and modem stack.

**11) Repository infrastructure**
`.github/workflows/go.yml` indicates CI is focused on Go build/test validation. There is no sign of a separate backend, database, or service deployment model here; the repo’s “runtime” is whatever Go program imports it, running on a Linux host with D-Bus access.

**12) How to draw the architecture**
A good diagram would show:
- a **Go application** using this package
- the **go-modemmanager library** as the adapter layer
- the **system D-Bus**
- the **ModemManager daemon**
- and below that, the **modem hardware / radio stack**

Inside the library box, group the interface wrappers by domain: core manager, modem/bearer, SIM/SMS/call, registration/network, location/time, signal, firmware, and USSD/OMA. That reflects the repo’s actual structure accurately.

Main entry points: [`Modem.go`](https://github.com/maltegrosse/go-modemmanager/blob/master/Modem.go) (Modem core), [`ModemManager.go`](https://github.com/maltegrosse/go-modemmanager/blob/master/ModemManager.go) (Manager root), [`ModemMessaging.go`](https://github.com/maltegrosse/go-modemmanager/blob/master/ModemMessaging.go) (Messaging), [`ModemVoice.go`](https://github.com/maltegrosse/go-modemmanager/blob/master/ModemVoice.go) (Voice)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_library["Library API"]
  node_node_lib["go-modemmanager<br/>dbus client library"]
  node_node_mgr["Manager root<br/>service wrapper<br/>[ModemManager.go]"]
  node_node_modem["Modem core<br/>device wrapper<br/>[Modem.go]"]
  node_node_simple["Simple control<br/>shortcut API<br/>[ModemSimple.go]"]
  node_node_conn["Connectivity<br/>bearer API<br/>[Bearer.go]"]
  node_node_net["Network reg<br/>3GPP/CDMA API<br/>[Modem3gpp.go]"]
  node_node_cdma["CDMA mode<br/>CDMA API<br/>[ModemCdma.go]"]
  node_node_msg["Messaging<br/>[ModemMessaging.go]"]
  node_node_sms["SMS object<br/>sms wrapper<br/>[Sms.go]"]
  node_node_voice["Voice<br/>[ModemVoice.go]"]
  node_node_call["Call object<br/>call wrapper<br/>[Call.go]"]
  node_node_loc["Location<br/>[ModemLocation.go]"]
  node_node_time["Time sync<br/>time API<br/>[ModemTime.go]"]
  node_node_signal["Signal<br/>radio metrics<br/>[ModemSignal.go]"]
  node_node_fw["Firmware<br/>[ModemFirmware.go]"]
  node_node_sim["SIM<br/>[Sim.go]"]
  node_node_ussd["USSD<br/>[ModemUssd.go]"]
  node_node_oma["OMA<br/>[ModemOma.go]"]
  node_node_utils["Helpers<br/>plumbing<br/>[utils.go]"]
end

subgraph group_group_types["Type Modeling"]
  node_node_signaltypes["Enums<br/>type model<br/>[enums.go]"]
  node_node_stringtypes["String maps<br/>enum strings"]
end

subgraph group_group_runtime["External Runtime"]
  node_node_app["Go app<br/>consumer"]
  node_node_dbus[("System D-Bus")]
  node_node_mmdaemon["ModemManager<br/>daemon"]
  node_node_hw{{"Modem stack<br/>hardware/runtime"}}
end

subgraph group_group_examples["Examples"]
  node_node_examples["Examples<br/>sample programs"]
end

node_node_app -->|"imports"| node_node_lib
node_node_examples -->|"demonstrate"| node_node_lib
node_node_lib -->|"speaks over"| node_node_dbus
node_node_dbus -->|"routes to"| node_node_mmdaemon
node_node_mmdaemon -->|"controls"| node_node_hw
node_node_lib -->|"exposes"| node_node_mgr
node_node_mgr -->|"discovers"| node_node_modem
node_node_modem -->|"offers"| node_node_simple
node_node_modem -->|"manages"| node_node_conn
node_node_modem -->|"reports"| node_node_net
node_node_modem -->|"specializes"| node_node_cdma
node_node_modem -->|"exposes"| node_node_msg
node_node_msg -->|"wraps"| node_node_sms
node_node_modem -->|"exposes"| node_node_voice
node_node_voice -->|"wraps"| node_node_call
node_node_modem -->|"exposes"| node_node_sim
node_node_modem -->|"exposes"| node_node_loc
node_node_modem -->|"exposes"| node_node_time
node_node_modem -->|"monitors"| node_node_signal
node_node_modem -->|"exposes"| node_node_fw
node_node_modem -->|"exposes"| node_node_ussd
node_node_modem -->|"exposes"| node_node_oma
node_node_lib -->|"models"| node_node_signaltypes
node_node_signaltypes -->|"stringifies"| node_node_stringtypes
node_node_lib -->|"shares"| node_node_utils
node_node_utils -->|"supports"| node_node_mgr

click node_node_mgr "https://github.com/maltegrosse/go-modemmanager/blob/master/ModemManager.go"
click node_node_modem "https://github.com/maltegrosse/go-modemmanager/blob/master/Modem.go"
click node_node_simple "https://github.com/maltegrosse/go-modemmanager/blob/master/ModemSimple.go"
click node_node_conn "https://github.com/maltegrosse/go-modemmanager/blob/master/Bearer.go"
click node_node_net "https://github.com/maltegrosse/go-modemmanager/blob/master/Modem3gpp.go"
click node_node_cdma "https://github.com/maltegrosse/go-modemmanager/blob/master/ModemCdma.go"
click node_node_msg "https://github.com/maltegrosse/go-modemmanager/blob/master/ModemMessaging.go"
click node_node_sms "https://github.com/maltegrosse/go-modemmanager/blob/master/Sms.go"
click node_node_voice "https://github.com/maltegrosse/go-modemmanager/blob/master/ModemVoice.go"
click node_node_call "https://github.com/maltegrosse/go-modemmanager/blob/master/Call.go"
click node_node_loc "https://github.com/maltegrosse/go-modemmanager/blob/master/ModemLocation.go"
click node_node_time "https://github.com/maltegrosse/go-modemmanager/blob/master/ModemTime.go"
click node_node_signal "https://github.com/maltegrosse/go-modemmanager/blob/master/ModemSignal.go"
click node_node_fw "https://github.com/maltegrosse/go-modemmanager/blob/master/ModemFirmware.go"
click node_node_sim "https://github.com/maltegrosse/go-modemmanager/blob/master/Sim.go"
click node_node_ussd "https://github.com/maltegrosse/go-modemmanager/blob/master/ModemUssd.go"
click node_node_oma "https://github.com/maltegrosse/go-modemmanager/blob/master/ModemOma.go"
click node_node_signaltypes "https://github.com/maltegrosse/go-modemmanager/blob/master/enums.go"
click node_node_utils "https://github.com/maltegrosse/go-modemmanager/blob/master/utils.go"
click node_node_examples "https://github.com/maltegrosse/go-modemmanager/tree/master/examples"

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_node_lib,node_node_mgr,node_node_modem,node_node_simple,node_node_conn,node_node_net,node_node_cdma,node_node_msg,node_node_sms,node_node_voice,node_node_call,node_node_loc,node_node_time,node_node_signal,node_node_fw,node_node_sim,node_node_ussd,node_node_oma,node_node_utils toneBlue
class node_node_signaltypes,node_node_stringtypes toneAmber
class node_node_app,node_node_dbus,node_node_mmdaemon,node_node_hw toneMint
class node_node_examples toneRose
```

## Components

### Library API

Typed Go wrappers around ModemManager D-Bus interfaces.

- **go-modemmanager**: dbus client library · This repository's typed client layer over the ModemManager D-Bus API.
- [Manager root](https://github.com/maltegrosse/go-modemmanager/blob/master/ModemManager.go): service wrapper · Top-level ModemManager entry point for discovering and coordinating modem objects. · `ModemManager.go`
- [Modem core](https://github.com/maltegrosse/go-modemmanager/blob/master/Modem.go): device wrapper · Primary modem object for state, capabilities, ports, power, and object access. · `Modem.go`
- [Simple control](https://github.com/maltegrosse/go-modemmanager/blob/master/ModemSimple.go): shortcut API · Convenience modem operations that bundle common setup and actions. · `ModemSimple.go`
- [Connectivity](https://github.com/maltegrosse/go-modemmanager/blob/master/Bearer.go): bearer API · Bearer creation and connection-related types and methods. · `Bearer.go`
- [Network reg](https://github.com/maltegrosse/go-modemmanager/blob/master/Modem3gpp.go): 3GPP/CDMA API · Network registration, operator, subscription, and attachment behavior. · `Modem3gpp.go`
- [CDMA mode](https://github.com/maltegrosse/go-modemmanager/blob/master/ModemCdma.go): CDMA API · CDMA-specific activation and registration support. · `ModemCdma.go`
- [Messaging](https://github.com/maltegrosse/go-modemmanager/blob/master/ModemMessaging.go): sms/messaging API · SMS and messaging transport exposed by ModemManager. · `ModemMessaging.go`
- [SMS object](https://github.com/maltegrosse/go-modemmanager/blob/master/Sms.go): sms wrapper · Individual SMS message wrapper and state handling. · `Sms.go`
- [Voice](https://github.com/maltegrosse/go-modemmanager/blob/master/ModemVoice.go): voice API · Voice-call capabilities and call control on the modem. · `ModemVoice.go`
- [Call object](https://github.com/maltegrosse/go-modemmanager/blob/master/Call.go): call wrapper · Individual call representation and state transitions. · `Call.go`
- [Location](https://github.com/maltegrosse/go-modemmanager/blob/master/ModemLocation.go): location API · Positioning and assistance-data access for supported modems. · `ModemLocation.go`
- [Time sync](https://github.com/maltegrosse/go-modemmanager/blob/master/ModemTime.go): time API · Modem time and network time related accessors. · `ModemTime.go`
- [Signal](https://github.com/maltegrosse/go-modemmanager/blob/master/ModemSignal.go): radio metrics · Signal quality and radio-property monitoring. · `ModemSignal.go`
- [Firmware](https://github.com/maltegrosse/go-modemmanager/blob/master/ModemFirmware.go): firmware API · Firmware image and update support exposed by the modem. · `ModemFirmware.go`
- [SIM](https://github.com/maltegrosse/go-modemmanager/blob/master/Sim.go): sim wrapper · SIM card and provisioning access. · `Sim.go`
- [USSD](https://github.com/maltegrosse/go-modemmanager/blob/master/ModemUssd.go): ussd API · USSD session handling and network service codes. · `ModemUssd.go`
- [OMA](https://github.com/maltegrosse/go-modemmanager/blob/master/ModemOma.go): oma API · OMA device management and session control. · `ModemOma.go`
- [Helpers](https://github.com/maltegrosse/go-modemmanager/blob/master/utils.go): plumbing · Shared D-Bus marshaling, conversion, and helper routines used by wrappers. · `utils.go`

### Type Modeling

Enum and string helpers that preserve ModemManager semantics in Go.

- [Enums](https://github.com/maltegrosse/go-modemmanager/blob/master/enums.go): type model · Strongly typed constants for modem state, registration, SMS, call, bearer, and error domains. · `enums.go`
- **String maps**: enum strings · Generated stringer-style helpers for ModemManager enum values and errors.

### External Runtime

System dependencies the library talks to at runtime.

- **Go app**: consumer · Any Go program that imports this library and drives modem operations.
- **System D-Bus**: bus · Runtime IPC channel used to reach ModemManager.
- **ModemManager**: daemon · External system service providing modem control and state over D-Bus.
- **Modem stack**: hardware/runtime · Underlying modem hardware and transport modes such as QMI or AT.

### Examples

Small programs showing query and signal-listener usage.

- [Examples](https://github.com/maltegrosse/go-modemmanager/tree/master/examples): sample programs · Usage examples for interface discovery, listeners, and running the library. · `examples`

## Connections

- Go app → go-modemmanager: imports · Client code uses the library as its modem API.
- Examples → go-modemmanager: demonstrate · Examples show how to consume the package.
- go-modemmanager → System D-Bus: speaks over · All service calls go through the system bus.
- System D-Bus → ModemManager: routes to · D-Bus forwards requests to the ModemManager service.
- ModemManager → Modem stack: controls · ModemManager mediates access to the actual modem and radio stack.
- go-modemmanager → Manager root: exposes · Root service wrapper for discovery and global service operations.
- Manager root → Modem core: discovers · Manager yields modem objects and related interfaces.
- Modem core → Simple control: offers · Convenience API for common modem actions.
- Modem core → Connectivity: manages · Core modem state leads into bearer and connection control.
- Modem core → Network reg: reports · Registration and network access state are modeled here.
- Modem core → CDMA mode: specializes · CDMA-specific modem interface.
- Modem core → Messaging: exposes · Messaging interface hangs off the modem object.
- Messaging → SMS object: wraps · SMS objects are created and tracked through messaging.
- Modem core → Voice: exposes · Voice capabilities and call operations.
- Voice → Call object: wraps · Calls are represented as dedicated objects.
- Modem core → SIM: exposes · SIM/provisioning state is available from the modem path.
- Modem core → Location: exposes · Location and assistance-data support.
- Modem core → Time sync: exposes · Network and modem time accessors.
- Modem core → Signal: monitors · Radio-signal quality and metrics.
- Modem core → Firmware: exposes · Firmware update and image management.
- Modem core → USSD: exposes · USSD session control.
- Modem core → OMA: exposes · OMA session and device-management support.
- go-modemmanager → Enums: models · Typed enums define the package's protocol vocabulary.
- Enums → String maps: stringifies · Generated helpers convert enums and error codes to readable text.
- go-modemmanager → Helpers: shares · Common marshaling and conversion logic is reused across wrappers.
- Helpers → Manager root: supports · Shared plumbing underpins the interface wrappers.
