# rdkcentral/bartoncore architecture

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

- Interactive diagram: https://gitdiagram.com/rdkcentral/bartoncore
- Repository: https://github.com/rdkcentral/bartoncore

## Overview

BartonCore is a local IoT device-management library with a unified device/resource model and pluggable protocol support. A client initializes and starts the service, then uses its API for discovery, commissioning, configuration, device control, and events. Protocol drivers and subsystems cover Matter, Zigbee, Thread, and ONVIF; persistence and eventing support the service internally. The README documents these product capabilities, but sampled source is limited, so unverified subsystem connections are dashed rather than presented as established calls.

Main entry points: [`core/src/deviceService.c`](https://github.com/rdkcentral/bartoncore/blob/main/core/src/deviceService.c) (Device service), [`core/src/deviceDriverManager.c`](https://github.com/rdkcentral/bartoncore/blob/main/core/src/deviceDriverManager.c) (Driver manager), [`api/c/src/barton-core-client.c`](https://github.com/rdkcentral/bartoncore/blob/main/api/c/src/barton-core-client.c) (Client implementation), [`core/deviceDrivers/matter/MatterDeviceDriver.cpp`](https://github.com/rdkcentral/bartoncore/blob/main/core/deviceDrivers/matter/MatterDeviceDriver.cpp) (Matter drivers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Client API"]
  node_public_api["Client API"]
  node_client_impl["Client implementation"]
  node_params["Initialization params"]
end

subgraph group_core["Device Service"]
  node_service["Device service<br/>[deviceService.c]"]
  node_service_api["Service operations<br/>[deviceService.h]"]
  node_discovery["Discovery filters"]
  node_device_model["Device model<br/>[icDevice.c]"]
  node_driver_manager["Driver manager"]
  node_descriptors["Device descriptors<br/>[parser.c]"]
end

subgraph group_protocols["Protocols and Drivers"]
  node_matter["Matter subsystem"]
  node_matter_drivers["Matter drivers"]
  node_sbmd["Spec-based drivers"]
  node_zigbee["Zigbee subsystem<br/>[zigbeeSubsystem.c]"]
  node_zigbee_drivers["Zigbee drivers"]
  node_thread["Thread subsystem"]
  node_onvif["ONVIF driver"]
end

subgraph group_state["State and Events"]
  node_database[("JSON database<br/>[jsonDatabase.c]")]
  node_matter_storage["Matter persistence"]
  node_storage_monitor["Storage monitor"]
  node_event_producer["Event producer"]
  node_storage_event["Storage event"]
end

node_client(("Barton client"))
node_external_storage[("Platform storage")]

node_client -->|"uses"| node_public_api
node_public_api -->|"implemented by"| node_client_impl
node_client_impl -->|"calls"| node_service_api
node_client_impl -->|"accepts"| node_params
node_service_api -.->|"declares operations"| node_service
node_service -.->|"dispatches drivers"| node_driver_manager
node_service -.->|"filters discovery"| node_discovery
node_service -.->|"manages devices"| node_device_model
node_driver_manager -.->|"registers drivers"| node_matter_drivers
node_driver_manager -.->|"registers drivers"| node_zigbee_drivers
node_matter_drivers -.->|"uses subsystem"| node_matter
node_matter_drivers -.->|"supports spec drivers"| node_sbmd
node_zigbee_drivers -.->|"uses subsystem"| node_zigbee
node_thread -.->|"integrates with"| node_service
node_onvif -.->|"pluggable driver"| node_driver_manager
node_service -.->|"persists device data"| node_database
node_matter_storage -->|"reads and writes"| node_external_storage
node_storage_monitor -->|"sends change event"| node_event_producer
node_event_producer -.->|"publishes event"| node_storage_event
node_descriptors -.->|"describes devices"| node_device_model

click node_public_api "https://github.com/rdkcentral/bartoncore/blob/main/api/c/public/barton-core-client.h"
click node_client_impl "https://github.com/rdkcentral/bartoncore/blob/main/api/c/src/barton-core-client.c"
click node_params "https://github.com/rdkcentral/bartoncore/blob/main/api/c/public/barton-core-initialize-params-container.h"
click node_service "https://github.com/rdkcentral/bartoncore/blob/main/core/src/deviceService.c"
click node_service_api "https://github.com/rdkcentral/bartoncore/blob/main/api/c/public/private/deviceService.h"
click node_discovery "https://github.com/rdkcentral/bartoncore/blob/main/core/src/deviceDiscoveryFilters.c"
click node_device_model "https://github.com/rdkcentral/bartoncore/blob/main/core/src/device/icDevice.c"
click node_driver_manager "https://github.com/rdkcentral/bartoncore/blob/main/core/src/deviceDriverManager.c"
click node_descriptors "https://github.com/rdkcentral/bartoncore/blob/main/libs/device/descriptors/c/src/parser.c"
click node_matter "https://github.com/rdkcentral/bartoncore/blob/main/core/src/subsystems/matter/matterSubsystem.cpp"
click node_matter_drivers "https://github.com/rdkcentral/bartoncore/blob/main/core/deviceDrivers/matter/MatterDeviceDriver.cpp"
click node_sbmd "https://github.com/rdkcentral/bartoncore/blob/main/core/deviceDrivers/matter/sbmd/mquickjs/SbmdHandlerInvoker.cpp"
click node_zigbee "https://github.com/rdkcentral/bartoncore/blob/main/core/src/subsystems/zigbee/zigbeeSubsystem.c"
click node_zigbee_drivers "https://github.com/rdkcentral/bartoncore/blob/main/core/deviceDrivers/zigbee/zigbeeLightControllerDeviceDriver.c"
click node_thread "https://github.com/rdkcentral/bartoncore/blob/main/core/src/subsystems/thread/threadSubsystem.cpp"
click node_onvif "https://github.com/rdkcentral/bartoncore/blob/main/core/deviceDrivers/onvif/OnvifSoapClient.cpp"
click node_database "https://github.com/rdkcentral/bartoncore/blob/main/core/src/database/jsonDatabase.c"
click node_matter_storage "https://github.com/rdkcentral/bartoncore/blob/main/core/src/subsystems/matter/PersistentStorageDelegate.cpp"
click node_storage_monitor "https://github.com/rdkcentral/bartoncore/blob/main/core/src/deviceStorageMonitor.c"
click node_event_producer "https://github.com/rdkcentral/bartoncore/blob/main/core/src/event/deviceEventProducer.h"
click node_storage_event "https://github.com/rdkcentral/bartoncore/blob/main/api/c/src/events/barton-core-storage-changed-event.c"

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_public_api,node_client_impl,node_params,node_client toneBlue
class node_service,node_service_api,node_discovery,node_device_model,node_driver_manager,node_descriptors,node_external_storage toneAmber
class node_matter,node_matter_drivers,node_sbmd,node_zigbee,node_zigbee_drivers,node_thread,node_onvif toneMint
class node_database,node_matter_storage,node_storage_monitor,node_event_producer,node_storage_event toneRose
```

## Components

### Client API

- [Client API](https://github.com/rdkcentral/bartoncore/blob/main/api/c/public/barton-core-client.h): `api/c/public/barton-core-client.h`
- [Client implementation](https://github.com/rdkcentral/bartoncore/blob/main/api/c/src/barton-core-client.c): `api/c/src/barton-core-client.c`
- [Initialization params](https://github.com/rdkcentral/bartoncore/blob/main/api/c/public/barton-core-initialize-params-container.h): `api/c/public/barton-core-initialize-params-container.h`

### Device Service

- [Device service](https://github.com/rdkcentral/bartoncore/blob/main/core/src/deviceService.c): `core/src/deviceService.c`
- [Service operations](https://github.com/rdkcentral/bartoncore/blob/main/api/c/public/private/deviceService.h): `api/c/public/private/deviceService.h`
- [Discovery filters](https://github.com/rdkcentral/bartoncore/blob/main/core/src/deviceDiscoveryFilters.c): `core/src/deviceDiscoveryFilters.c`
- [Device model](https://github.com/rdkcentral/bartoncore/blob/main/core/src/device/icDevice.c): `core/src/device/icDevice.c`
- [Driver manager](https://github.com/rdkcentral/bartoncore/blob/main/core/src/deviceDriverManager.c): `core/src/deviceDriverManager.c`
- [Device descriptors](https://github.com/rdkcentral/bartoncore/blob/main/libs/device/descriptors/c/src/parser.c): `libs/device/descriptors/c/src/parser.c`

### Protocols and Drivers

- [Matter subsystem](https://github.com/rdkcentral/bartoncore/blob/main/core/src/subsystems/matter/matterSubsystem.cpp): `core/src/subsystems/matter/matterSubsystem.cpp`
- [Matter drivers](https://github.com/rdkcentral/bartoncore/blob/main/core/deviceDrivers/matter/MatterDeviceDriver.cpp): `core/deviceDrivers/matter/MatterDeviceDriver.cpp`
- [Spec-based drivers](https://github.com/rdkcentral/bartoncore/blob/main/core/deviceDrivers/matter/sbmd/mquickjs/SbmdHandlerInvoker.cpp): `core/deviceDrivers/matter/sbmd/mquickjs/SbmdHandlerInvoker.cpp`
- [Zigbee subsystem](https://github.com/rdkcentral/bartoncore/blob/main/core/src/subsystems/zigbee/zigbeeSubsystem.c): `core/src/subsystems/zigbee/zigbeeSubsystem.c`
- [Zigbee drivers](https://github.com/rdkcentral/bartoncore/blob/main/core/deviceDrivers/zigbee/zigbeeLightControllerDeviceDriver.c): `core/deviceDrivers/zigbee/zigbeeLightControllerDeviceDriver.c`
- [Thread subsystem](https://github.com/rdkcentral/bartoncore/blob/main/core/src/subsystems/thread/threadSubsystem.cpp): `core/src/subsystems/thread/threadSubsystem.cpp`
- [ONVIF driver](https://github.com/rdkcentral/bartoncore/blob/main/core/deviceDrivers/onvif/OnvifSoapClient.cpp): `core/deviceDrivers/onvif/OnvifSoapClient.cpp`

### State and Events

- [JSON database](https://github.com/rdkcentral/bartoncore/blob/main/core/src/database/jsonDatabase.c): `core/src/database/jsonDatabase.c`
- [Matter persistence](https://github.com/rdkcentral/bartoncore/blob/main/core/src/subsystems/matter/PersistentStorageDelegate.cpp): `core/src/subsystems/matter/PersistentStorageDelegate.cpp`
- [Storage monitor](https://github.com/rdkcentral/bartoncore/blob/main/core/src/deviceStorageMonitor.c): `core/src/deviceStorageMonitor.c`
- [Event producer](https://github.com/rdkcentral/bartoncore/blob/main/core/src/event/deviceEventProducer.h): `core/src/event/deviceEventProducer.h`
- [Storage event](https://github.com/rdkcentral/bartoncore/blob/main/api/c/src/events/barton-core-storage-changed-event.c): `api/c/src/events/barton-core-storage-changed-event.c`

### Other components

- **Barton client**
- **Platform storage**

## Connections

- Barton client → Client API: uses
- Client API → Client implementation: implemented by (evidence: `api/c/src/barton-core-client.c`)
- Client implementation → Service operations: calls (evidence: `api/c/src/barton-core-client.c`)
- Client implementation → Initialization params: accepts (evidence: `api/c/src/barton-core-client.c`)
- Service operations → Device service: declares operations
- Device service → Driver manager: dispatches drivers
- Device service → Discovery filters: filters discovery
- Device service → Device model: manages devices
- Driver manager → Matter drivers: registers drivers
- Driver manager → Zigbee drivers: registers drivers
- Matter drivers → Matter subsystem: uses subsystem
- Matter drivers → Spec-based drivers: supports spec drivers
- Zigbee drivers → Zigbee subsystem: uses subsystem
- Thread subsystem → Device service: integrates with
- ONVIF driver → Driver manager: pluggable driver
- Device service → JSON database: persists device data
- Matter persistence → Platform storage: reads and writes (evidence: `core/src/subsystems/matter/PersistentStorageDelegate.cpp`)
- Storage monitor → Event producer: sends change event (evidence: `core/src/deviceStorageMonitor.c`)
- Event producer → Storage event: publishes event
- Device descriptors → Device model: describes devices
