# nordicsemiconductor/nrf5-sdk-for-mesh architecture

> Architecture diagram of the GitHub repository nordicsemiconductor/nrf5-sdk-for-mesh, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nordicsemiconductor/nrf5-sdk-for-mesh
- Repository: https://github.com/nordicsemiconductor/nrf5-sdk-for-mesh

## Overview

This project is Nordic Semiconductor’s nRF5 SDK for Mesh – their complete implementation of a Bluetooth mesh stack for nRF5 Series devices. The repository is very modular and layered, with separate directories for build configuration (CMake), examples, core mesh functionality (in the “mesh” folder), model implementations (in “models”), external libraries (such as SoftDevice, uECC, Segger RTT, and App Timer in “external”), and various supporting scripts and tools.

- Build and Configuration Layer:
– Components like the “CMake” and “tools” directories that set up the build environment and toolchain.
- External Dependencies:
– Group directories such as “external” (which includes softdevice binaries, micro-ecc, and RTT) and note how these provide hardware abstractions, security (cryptographic functions), and timer/RTT support.
- Core Bluetooth Mesh Stack:
– The “mesh” directory contains the source code, unit tests, and implementation of the mesh stack.
– Include sub-modules such as the Access Layer (mesh/access), Bearer (mesh/bearer), Friendship (mesh/friend), GATT Proxy (mesh/gatt), Provisioning (mesh/prov), DFU (mesh/dfu), Serial (mesh/serial), and the Mesh Stack core (mesh/stack).
- Model Layer:
– The “models” directory holds model definitions (foundations, health, generic models, light control, sensor, scene, vendor, etc.) that implement the behavior of mesh nodes.
- Application and Examples:
– The “examples” directory contains many demonstration apps (like light on/off, dimming, provisioning, DFU, etc.) that use the mesh stack.
– The “bin” directory holds prebuilt binaries for each example.
- Supporting Scripts and Documentation:
– “doc” and “scripts” provide documentation, Doxygen configuration, and support tools like the Interactive PyACI that aid in debugging and configuration.

##### Component Interactions and Relationships
– From the Examples (user application layer) down to the Mesh Stack core.

##### Design Patterns and Principles
- Modularization: Each folder (e.g., mesh, models, external) represents a cohesive module with well-defined interfaces.
- Separation of Concerns: The layered separation distinguishes between system configuration/build, core network protocol layers, application models, and development tools.
- Reusability and Abstraction: External libraries are abstracted (e.g., SoftDevice for BLE, micro-ecc for cryptography) so that the mesh stack and examples work independently from hardware details.
- Inter-module Communication: The artificial “data-flow” across modules such as provisioning events, mesh control messages, and DFU commands should be depicted.

##### Relevant Technologies and Frameworks
- CMake Toolchain: Illustrate that the build system uses CMake (with many cmake modules) to configure and build the whole project.
- Cryptography with uECC: Show that the mesh security relies on the micro-ecc library.
- Serial Communication: Indicate support for serial provisioning and control interfaces.
- Provisioning & DFU: These are specialized subsystems embedded in the mesh stack, so include them as separate modules that handle secure onboarding and firmware updates.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Build and Configuration Layer
    subgraph "Build and Configuration Layer"
        cmake["CMake"]:::build
        tools["Build Tools"]:::build
    end

    %% External Dependencies
    subgraph "External Dependencies"
        external["External Libraries"]:::external
    end

    %% Core Bluetooth Mesh Stack
    subgraph "Core Bluetooth Mesh Stack"
        access["Mesh Access"]:::mesh
        bearer["Mesh Bearer"]:::mesh
        friend["Mesh Friendship"]:::mesh
        gatt["Mesh GATT Proxy"]:::mesh
        prov["Mesh Provisioning"]:::mesh
        dfu["Mesh DFU"]:::mesh
        serial["Mesh Serial"]:::mesh
        core["Mesh Core"]:::mesh
        test["Mesh Testing"]:::mesh
    end

    %% Model Layer
    subgraph "Model Layer"
        models["Core Models"]:::model
    end

    %% Application and Examples
    subgraph "Application and Examples"
        examples["Example Applications"]:::app
        bin["Prebuilt Binaries"]:::app
    end

    %% Supporting Scripts and Documentation
    subgraph "Supporting Scripts and Documentation"
        doc["Documentation & Guides"]:::support
        scripts["Support Scripts & Tools"]:::support
    end

    %% Connections between layers
    cmake -->|"build"| core
    tools -->|"build"| core
    core -->|"uses"| external

    access -->|"communicates"| core
    bearer -->|"communicates"| core
    friend -->|"communicates"| core
    gatt -->|"communicates"| core
    prov -->|"communicates"| core
    dfu -->|"communicates"| core
    serial -->|"communicates"| core
    test -->|"validates"| core

    core <-->|"interfaces"| models
    examples -->|"utilizes"| core
    bin -->|"packages"| examples
    scripts -->|"aids"| core
    doc -->|"documents"| core

    %% Styles
    classDef build fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef external fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef mesh fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef model fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef app fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
    classDef support fill:#e2e3e5,stroke:#6c757d,stroke-width:2px;

    %% Click Events
    click cmake "https://github.com/nordicsemiconductor/nrf5-sdk-for-mesh/tree/master//CMake"
    click tools "https://github.com/nordicsemiconductor/nrf5-sdk-for-mesh/tree/master//tools"
    click external "https://github.com/nordicsemiconductor/nrf5-sdk-for-mesh/tree/master//external"
    click access "https://github.com/nordicsemiconductor/nrf5-sdk-for-mesh/tree/master//mesh/access"
    click bearer "https://github.com/nordicsemiconductor/nrf5-sdk-for-mesh/tree/master//mesh/bearer"
    click friend "https://github.com/nordicsemiconductor/nrf5-sdk-for-mesh/tree/master//mesh/friend"
    click gatt "https://github.com/nordicsemiconductor/nrf5-sdk-for-mesh/tree/master//mesh/gatt"
    click prov "https://github.com/nordicsemiconductor/nrf5-sdk-for-mesh/tree/master//mesh/prov"
    click dfu "https://github.com/nordicsemiconductor/nrf5-sdk-for-mesh/tree/master//mesh/dfu"
    click serial "https://github.com/nordicsemiconductor/nrf5-sdk-for-mesh/tree/master//mesh/serial"
    click core "https://github.com/nordicsemiconductor/nrf5-sdk-for-mesh/tree/master//mesh/core"
    click test "https://github.com/nordicsemiconductor/nrf5-sdk-for-mesh/tree/master//mesh/test"
    click models "https://github.com/nordicsemiconductor/nrf5-sdk-for-mesh/tree/master//models"
    click examples "https://github.com/nordicsemiconductor/nrf5-sdk-for-mesh/tree/master//examples"
    click bin "https://github.com/nordicsemiconductor/nrf5-sdk-for-mesh/tree/master//bin"
    click doc "https://github.com/nordicsemiconductor/nrf5-sdk-for-mesh/tree/master//doc"
    click scripts "https://github.com/nordicsemiconductor/nrf5-sdk-for-mesh/tree/master//scripts"
```
