# linux-mobile-broadband/modemmanager architecture

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

- Interactive diagram: https://gitdiagram.com/linux-mobile-broadband/modemmanager
- Repository: https://github.com/linux-mobile-broadband/modemmanager

## Overview

##### Main Components

a. Core System Components:
- DBus System Bus (central communication hub)
- ModemManager Daemon (main service)
- Plugin Manager
- Device Manager
- Port Manager

b. Interface Layers:
- DBus API Layer
- libmm-glib Library (client API)
- Hardware Abstraction Layer

c. Plugin System:
- Generic Plugins
- Vendor-specific Plugins (Huawei, Nokia, Sierra, etc.)
- Protocol-specific Handlers (AT, QCDM, QMI, MBIM)

##### Component Relationships

**[Hardware Layer]**
- ↑↓
**[Port Management]**
- ↑↓
**[Plugin System] ←→ [Protocol Handlers]**
- ↑↓
**[Core Daemon] ←→ [Device Management]**
- ↑↓
**[DBus Interface]**
- ↑↓
**[Client Applications]**

##### Specific Implementation Details

Key architectural elements:
- GInterface implementations for different modem features
- Protocol-specific handlers (AT, QCDM, QMI, MBIM)
- Port detection and management system
- Event handling system
- Plugin loading and management system

##### Key Processes to Highlight

a. Device Detection Flow:
**[udev] → [ModemManager] → [Plugin Detection] → [Port Setup] → [Interface Export]**

b. Command Flow:
**[Client] → [DBus] → [ModemManager] → [Plugin] → [Protocol Handler] → [Hardware]**

##### Additional Elements

- Annotations for key interfaces (MMIfaceModem3gpp, MMIfaceModemCdma)
- Security boundaries (system bus, user space)

##### Implementation Notes

- Relationship between libmm-glib and the daemon
- Where plugin extensibility points exist
- Critical security boundaries
- How different protocols (AT, QMI, MBIM) are handled

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Hardware
        HW[Hardware Modems]:::hardware
    end

    subgraph PortManagement
        PM[Port Manager]:::core
        click PM "https://github.com/linux-mobile-broadband/ModemManager/blob/main/src/mm-port.c"
    end

    subgraph PluginSystem
        PF[Plugin Framework]:::plugin
        click PF "https://github.com/linux-mobile-broadband/ModemManager/blob/main/src/plugins/mm-plugin-common.h"
        PLM[Plugin Manager]:::plugin
        click PLM "https://github.com/linux-mobile-broadband/ModemManager/blob/main/src/mm-plugin-manager.c"

        subgraph ProtocolHandlers
            AT[AT Handler]:::protocol
            click AT "https://github.com/linux-mobile-broadband/ModemManager/blob/main/src/mm-port-serial-at.c"
            QCDM[QCDM Handler]:::protocol
            click QCDM "https://github.com/linux-mobile-broadband/ModemManager/blob/main/src/mm-port-serial-qcdm.c"
            QMI[QMI Handler]:::protocol
            MBIM[MBIM Handler]:::protocol
        end
    end

    subgraph CoreSystem
        MMD[ModemManager Daemon]:::core
        click MMD "https://github.com/linux-mobile-broadband/ModemManager/blob/main/src/main.c"
        DM[Device Manager]:::core
        click DM "https://github.com/linux-mobile-broadband/ModemManager/blob/main/src/mm-device.c"
        HAL[Hardware Abstraction Layer]:::core
        click HAL "https://github.com/linux-mobile-broadband/ModemManager/blob/main/src/mm-iface-modem.h"

        subgraph Interfaces
            M3GPP[3GPP Interface]:::interface
            click M3GPP "https://github.com/linux-mobile-broadband/ModemManager/blob/main/src/mm-iface-modem-3gpp.c"
            MCDMA[CDMA Interface]:::interface
            click MCDMA "https://github.com/linux-mobile-broadband/ModemManager/blob/main/src/mm-iface-modem-cdma.c"
            MLOC[Location Interface]:::interface
            click MLOC "https://github.com/linux-mobile-broadband/ModemManager/blob/main/src/mm-iface-modem-location.c"
            MMSG[Messaging Interface]:::interface
            click MMSG "https://github.com/linux-mobile-broadband/ModemManager/blob/main/src/mm-iface-modem-messaging.c"
        end

        subgraph BaseClasses
            BM[Base Modem]:::base
            click BM "https://github.com/linux-mobile-broadband/ModemManager/blob/main/src/mm-base-modem.c"
            BB[Base Bearer]:::base
            click BB "https://github.com/linux-mobile-broadband/ModemManager/blob/main/src/mm-base-bearer.c"
            BS[Base SIM]:::base
            click BS "https://github.com/linux-mobile-broadband/ModemManager/blob/main/src/mm-base-sim.c"
        end
    end

    subgraph CommunicationLayer
        DBUS[DBus Interface]:::communication
        click DBUS "https://github.com/linux-mobile-broadband/ModemManager/blob/main/introspection/org.freedesktop.ModemManager1.xml"
        MMGLIB[libmm-glib]:::communication
        click MMGLIB "https://github.com/linux-mobile-broadband/ModemManager/blob/main/libmm-glib/libmm-glib.h"
    end

    subgraph ClientLayer
        CA[Client Applications]:::client
    end

    %% Relationships
    HW <--> PM
    PM <--> PF
    PF <--> PLM
    PF <--> ProtocolHandlers
    PLM <--> MMD
    MMD <--> DM
    DM <--> HAL
    HAL <--> Interfaces
    HAL <--> BaseClasses
    MMD <--> DBUS
    DBUS <--> MMGLIB
    MMGLIB <--> CA

    %% Styles
    classDef core fill:#4a90e2,stroke:#2171c7,color:white
    classDef plugin fill:#f5a623,stroke:#d4840f,color:white
    classDef protocol fill:#7ed321,stroke:#5fb30b,color:white
    classDef interface fill:#9013fe,stroke:#7201d1,color:white
    classDef base fill:#50e3c2,stroke:#29c39d,color:white
    classDef communication fill:#4a4a4a,stroke:#2d2d2d,color:white
    classDef client fill:#bd10e0,stroke:#9b0dba,color:white
    classDef hardware fill:#d0d0d0,stroke:#9a9a9a,color:black

    %% Legend
    subgraph Legend
        L1[Core Components]:::core
        L2[Plugin System]:::plugin
        L3[Protocol Handlers]:::protocol
        L4[Interfaces]:::interface
        L5[Base Classes]:::base
        L6[Communication]:::communication
        L7[Client Layer]:::client
        L8[Hardware]:::hardware
    end
```
