# nordicsemiconductor/android-nrf-connect-device-manager architecture

> Architecture diagram of the GitHub repository nordicsemiconductor/android-nrf-connect-device-manager, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nordicsemiconductor/android-nrf-connect-device-manager
- Repository: https://github.com/nordicsemiconductor/android-nrf-connect-device-manager

## Overview

##### Main Components
- Core Library (mcumgr-core): This module holds the transport-independent implementation of the McuManager protocol. It contains the basic framework, common utilities, managers (such as DefaultManager, ImageManager, BasicManager, StatsManager, CrashManager, SettingsManager, LogManager, FsManager, ShellManager), and response classes.
- BLE Transport Module (mcumgr-ble): A dedicated module that implements BLE transport using Nordic’s Android-BLE-Library. It builds on the core to provide Bluetooth-specific communication with the devices.
- Sample Application (sample): A demo application that uses the library – it not only demonstrates how to consume the API but also incorporates dependency injection (with Dagger 2), UI fragments, activities, and supporting resources.
- Build and Deployment Infrastructure: The root also includes Gradle build files, Fastlane scripts, GitHub workflows, and other infrastructure assets, which are important for continuous integration and deployment.

##### Relationships and Interactions
- The FirmwareUpgradeManager (part of the core) orchestrates the firmware upgrade process, interacting with the transport to send commands to the device.
- The BLE module provides the concrete implementation for the McuMgrTransport interface. Represent this as an implementation detail that “plugs into” the core library.
- The external dependency on the Nordic BLE library and any other significant frameworks (e.g., for dependency injection and asynchronous task management) can be drawn as external systems or libraries that interact with your BLE module or sample app.

##### Architectural Patterns
- Layered/Modular Architecture: The separation between transport-agnostic core functionality (protocol and managers) and the specific BLE transport module is a clear case of modular design.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core Library Module
    subgraph "mcumgr-core"
        Core["mcumgr-core Module"]:::core
        subgraph "Manager Layer"
            ManagerLayer["Managers (DefaultManager, ImageManager, BasicManager, StatsManager, CrashManager, SettingsManager, LogManager, FsManager, ShellManager)"]:::core
        end
        Firmware["FirmwareUpgradeManager"]:::core
    end

    %% BLE Transport Module
    subgraph "mcumgr-ble"
        BleTrans["BLE Transport Implementation"]:::ble
    end

    %% Sample Application
    subgraph "Sample App"
        Sample["Sample Application"]:::sample
        AppSrc["Sample App Source"]:::sample
        Dagger["Dependency Injection (Dagger2 Components)"]:::sample
    end

    %% CI/CD Infrastructure
    subgraph "CI/CD Infrastructure"
        Workflows["GitHub Workflows"]:::infra
        Fastlane["Fastlane Scripts"]:::infra
        GradleFiles["Gradle Build Files"]:::infra
    end

    %% External Dependencies
    subgraph "External Libraries"
        AndroidBle["Android-BLE-Library"]:::external
        DaggerLib["Dagger2 Library"]:::external
        GradleLib["Gradle"]:::external
    end

    %% Relationships between components
    Sample -->|"uses"| Core
    Sample -->|"uses"| BleTrans
    AppSrc -->|"part of"| Sample
    Dagger -->|"provides DI for"| Sample
    Firmware -->|"orchestrates upgrade via"| BleTrans
    ManagerLayer -->|"contains"| Firmware

    %% External integrations
    AndroidBle -->|"supports"| BleTrans
    DaggerLib -->|"injects"| Dagger
    GradleLib -->|"builds"| GradleFiles

    %% Click Events
    click Core "https://github.com/nordicsemiconductor/android-nrf-connect-device-manager/tree/main/mcumgr-core/"
    click ManagerLayer "https://github.com/nordicsemiconductor/android-nrf-connect-device-manager/tree/main/mcumgr-core/src/main/java/io/runtime/mcumgr/managers/"
    click Firmware "https://github.com/nordicsemiconductor/android-nrf-connect-device-manager/blob/main/mcumgr-core/src/main/java/io/runtime/mcumgr/dfu/mcuboot/FirmwareUpgradeManager.java"
    click BleTrans "https://github.com/nordicsemiconductor/android-nrf-connect-device-manager/blob/main/mcumgr-ble/src/main/java/io/runtime/mcumgr/ble/McuMgrBleTransport.java"
    click Sample "https://github.com/nordicsemiconductor/android-nrf-connect-device-manager/tree/main/sample/"
    click AppSrc "https://github.com/nordicsemiconductor/android-nrf-connect-device-manager/tree/main/sample/src/main/java/io/runtime/mcumgr/sample/"
    click Dagger "https://github.com/nordicsemiconductor/android-nrf-connect-device-manager/tree/main/sample/src/main/java/io/runtime/mcumgr/sample/di/"
    click Workflows "https://github.com/nordicsemiconductor/android-nrf-connect-device-manager/tree/main/.github/workflows/"
    click Fastlane "https://github.com/nordicsemiconductor/android-nrf-connect-device-manager/tree/main/fastlane/"
    click GradleFiles "https://github.com/nordicsemiconductor/android-nrf-connect-device-manager/blob/main/build.gradle"

    %% Styling for color coding
    classDef core fill:#f9e79f,stroke:#af7ac5,stroke-width:2px;
    classDef ble fill:#aed6f1,stroke:#2874a6,stroke-width:2px;
    classDef sample fill:#a9dfbf,stroke:#229954,stroke-width:2px;
    classDef infra fill:#f5cba7,stroke:#dc7633,stroke-width:2px;
    classDef external fill:#d2b4de,stroke:#7d3c98,stroke-width:2px;
```
