# opendaylight/mdsal architecture

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

- Interactive diagram: https://gitdiagram.com/opendaylight/mdsal
- Repository: https://github.com/opendaylight/mdsal

## Overview

##### Project type and purpose
- This is an open-source, multi-module Java framework (MD-SAL) for model-driven middleware.
- It provides two API “flavours”:
- Binding APIs (code-generated from YANG for compile-time safety)
- DOM APIs (YANG-based document model with runtime flexibility)
- It runs as OSGi bundles (Karaf features) and offers services like data storage (DataBroker), RPC, notifications, replication, entity ownership, singleton services, tracing and YANG-library support.

##### File structure
- Top-level modules map to core layers:
- binding/… (binding API + binding-to-DOM adapters)
- dom/… (DOM API + DOM broker + in-memory datastore + schema OSGi)
- common/… (shared common API types, three-phase commit, exceptions)
- replicate/, entityownership/, singleton-service/, trace/, yanglib/… (pluggable service extensions)
- model/… (YANG model modules)
- features/, karaf/… (Karaf feature descriptors for OSGi packaging)
- Each module has its own pom.xml (Maven reactor build), source, tests, and often module-info.java for Java 9+ modularity.

##### README for additional insights
- Emphasizes YANG as the modeling language and the two API flavours.
- Mentions extensibility, transport/adaptation, and connectors (e.g. RESTCONF).
- Framework is message-bus inspired, with services accessed via service registry.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Layers and Components
    subgraph "Model Layer"
        direction TB
        Yang["YANG Model Repository"]:::model
        TraceYang["Trace Model Yang"]:::model
    end

    subgraph "API Layer"
        direction TB
        BindSPI["mdsal-binding-spi"]:::api
        BindAPI["mdsal-binding-api"]:::api
        BindAdapter["mdsal-binding-dom-adapter"]:::adapter
        DOMSPI["mdsal-dom-spi"]:::api
        DOMAPI["mdsal-dom-api"]:::api
    end

    subgraph "Core Services"
        direction TB
        DOMBroker["mdsal-dom-broker"]:::broker
        SchemaOSGi["mdsal-dom-schema-osgi"]:::broker
        CommonAPI["mdsal-common-api"]:::common
        InMemoryDS["mdsal-dom-inmemory-datastore"]:::datastore
        DSBench["mdsal-dom-inmemory-datastore-benchmark"]:::datastore
    end

    subgraph "Extension Services"
        direction TB
        subgraph "Replication"
            RepCommon["mdsal-replicate-common"]:::extension
            RepNetty["mdsal-replicate-netty"]:::extension
        end
        subgraph "Entity Ownership"
            EOSBind["mdsal-eos-binding-adapter"]:::extension
            EOSAPI["mdsal-eos-binding-api"]:::extension
            EOSCommon["mdsal-eos-common-api"]:::extension
            EOSDOMAPI["mdsal-eos-dom-api"]:::extension
            EOSDOMImpl["mdsal-eos-dom-simple"]:::extension
        end
        subgraph "Cluster Singleton"
            SingletonAPI["mdsal-singleton-api"]:::extension
            SingletonImpl["mdsal-singleton-impl"]:::extension
        end
        subgraph "Tracing"
            TraceAPI["mdsal-trace-api"]:::extension
            TraceCLI["mdsal-trace-cli"]:::extension
            TraceImpl["mdsal-trace-impl"]:::extension
        end
        subgraph "Yang-Library"
            YLibAPI["mdsal-yanglib-api"]:::extension
            YLibRFC["mdsal-yanglib-rfc8525"]:::extension
        end
        NettyRFC["mdsal-rfc8294-netty"]:::external
    end

    subgraph "Runtime Host"
        direction TB
        OSGi["OSGi Container"]:::container
        Karaf["Karaf Features"]:::container
    end

    %% Flows
    Yang --> BindAPI
    TraceYang --> TraceAPI

    BindAPI -->|calls| BindAdapter
    BindSPI --> BindAdapter
    BindAdapter -->|invokes| DOMAPI
    DOMSPI --> DOMAPI

    DOMAPI -->|service lookup| OSGi
    OSGi --> DOMBroker
    DOMBroker -->|orchestrates| InMemoryDS
    CommonAPI --> InMemoryDS
    SchemaOSGi --> DOMBroker

    InMemoryDS -->|benchmarked by| DSBench

    InMemoryDS -->|events| RepCommon
    RepCommon -->|uses| RepNetty
    RepNetty --> NettyRFC

    DOMAPI -->|calls| EOSDOMAPI
    EOSCommon --> EOSDOMAPI
    EOSAPI --> EOSBind
    EOSBind --> EOSDOMImpl

    DOMAPI -->|calls| SingletonAPI
    SingletonAPI --> SingletonImpl

    DOMAPI -->|wrapped by| TraceImpl
    TraceAPI --> TraceImpl
    TraceCLI --> TraceImpl

    DOMAPI -->|queries| YLibAPI
    YLibRFC --> YLibAPI

    Karaf --> OSGi

    %% Click Events
    click Yang "https://github.com/opendaylight/mdsal/tree/master/model/"
    click TraceYang "https://github.com/opendaylight/mdsal/tree/master/trace/mdsal-trace-api/src/main/yang"
    click BindAPI "https://github.com/opendaylight/mdsal/tree/master/binding/mdsal-binding-api"
    click BindAdapter "https://github.com/opendaylight/mdsal/tree/master/binding/mdsal-binding-dom-adapter"
    click BindSPI "https://github.com/opendaylight/mdsal/tree/master/binding/mdsal-binding-spi"
    click DOMAPI "https://github.com/opendaylight/mdsal/tree/master/dom/mdsal-dom-api"
    click DOMSPI "https://github.com/opendaylight/mdsal/tree/master/dom/mdsal-dom-spi"
    click DOMBroker "https://github.com/opendaylight/mdsal/tree/master/dom/mdsal-dom-broker"
    click InMemoryDS "https://github.com/opendaylight/mdsal/tree/master/dom/mdsal-dom-inmemory-datastore"
    click DSBench "https://github.com/opendaylight/mdsal/tree/master/dom/mdsal-dom-inmemory-datastore-benchmark"
    click SchemaOSGi "https://github.com/opendaylight/mdsal/tree/master/dom/mdsal-dom-schema-osgi"
    click CommonAPI "https://github.com/opendaylight/mdsal/tree/master/common/mdsal-common-api"
    click RepCommon "https://github.com/opendaylight/mdsal/tree/master/replicate/mdsal-replicate-common"
    click RepNetty "https://github.com/opendaylight/mdsal/tree/master/replicate/mdsal-replicate-netty"
    click EOSBind "https://github.com/opendaylight/mdsal/tree/master/entityownership/mdsal-eos-binding-adapter"
    click EOSAPI "https://github.com/opendaylight/mdsal/tree/master/entityownership/mdsal-eos-binding-api"
    click EOSCommon "https://github.com/opendaylight/mdsal/tree/master/entityownership/mdsal-eos-common-api"
    click EOSDOMAPI "https://github.com/opendaylight/mdsal/tree/master/entityownership/mdsal-eos-dom-api"
    click EOSDOMImpl "https://github.com/opendaylight/mdsal/tree/master/entityownership/mdsal-eos-dom-simple"
    click SingletonAPI "https://github.com/opendaylight/mdsal/tree/master/singleton-service/mdsal-singleton-api"
    click SingletonImpl "https://github.com/opendaylight/mdsal/tree/master/singleton-service/mdsal-singleton-impl"
    click TraceAPI "https://github.com/opendaylight/mdsal/tree/master/trace/mdsal-trace-api"
    click TraceCLI "https://github.com/opendaylight/mdsal/tree/master/trace/mdsal-trace-cli"
    click TraceImpl "https://github.com/opendaylight/mdsal/tree/master/trace/mdsal-trace-impl"
    click YLibAPI "https://github.com/opendaylight/mdsal/tree/master/yanglib/mdsal-yanglib-api"
    click YLibRFC "https://github.com/opendaylight/mdsal/tree/master/yanglib/mdsal-yanglib-rfc8525"
    click NettyRFC "https://github.com/opendaylight/mdsal/tree/master/netty/mdsal-rfc8294-netty"
    click Karaf "https://github.com/opendaylight/mdsal/tree/master/features/"
    click OSGi "https://github.com/opendaylight/mdsal/tree/master/karaf/"

    %% Styles
    classDef model fill:#f9f,stroke:#333,stroke-width:1px
    classDef api fill:#bbf,stroke:#333,stroke-width:1px
    classDef adapter fill:#bfb,stroke:#333,stroke-width:1px
    classDef broker fill:#fbf,stroke:#333,stroke-width:1px
    classDef datastore fill:#ffb,stroke:#333,stroke-width:1px
    classDef common fill:#ddf,stroke:#333,stroke-width:1px
    classDef extension fill:#ffd,stroke:#333,stroke-width:1px
    classDef container fill:#eef,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5
    classDef external fill:#def,stroke:#333,stroke-width:1px,stroke-dasharray: 2 2
```
