# cesnet/netopeer2 architecture

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

- Interactive diagram: https://gitdiagram.com/cesnet/netopeer2
- Repository: https://github.com/cesnet/netopeer2

## Overview

Netopeer2 is a NETCONF server backed by sysrepo, with a companion interactive CLI. The main workflow is a client connecting over NETCONF, issuing configuration or operational requests, and receiving replies or subscribed notifications; server handlers use sysrepo for datastore access. The README documents SSH/TLS listen and call-home modes, NACM, URL transfers, monitoring, NMDA, confirmed commit, and notification subscriptions. Some feature paths are represented by their enclosing source files based on the tree and README; excerpts do not show every runtime call.

Main entry points: [`src/netconf.c`](https://github.com/cesnet/netopeer2/blob/master/src/netconf.c) (RPC handling), [`src/main.c`](https://github.com/cesnet/netopeer2/blob/master/src/main.c) (Server entry), [`src/common.c`](https://github.com/cesnet/netopeer2/blob/master/src/common.c) (Shared operations), [`src/netconf_subscribed_notifications.c`](https://github.com/cesnet/netopeer2/blob/master/src/netconf_subscribed_notifications.c) (Subscriptions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_server["Server runtime"]
  node_server_main["Server entry<br/>[main.c]"]
  node_netconf["RPC handling<br/>[netconf.c]"]
  node_common["Shared operations<br/>[common.c]"]
end

subgraph group_features["NETCONF features"]
  node_confirmed["Confirmed commit"]
  node_monitoring["Session monitoring"]
  node_nmda["NMDA operations<br/>[netconf_nmda.c]"]
  node_subscriptions["Subscriptions"]
  node_server_yang["Server schemas"]
end

subgraph group_client["CLI client"]
  node_cli_main["CLI entry<br/>[main.c]"]
  node_cli_commands["CLI commands<br/>[commands.c]"]
  node_cli_config["CLI configuration<br/>[configuration.c]"]
  node_cli_yang["CLI schema"]
end

subgraph group_integrations["External services"]
  node_sysrepo[("Sysrepo datastore")]
  node_libnetconf["libnetconf2 transport"]
  node_libyang["libyang schemas"]
  node_url_services["URL services"]
  node_ssh_tls["SSH / TLS"]
end

node_operator(("Operator"))
node_netconf_client(("NETCONF client"))

node_operator -->|"enters commands"| node_cli_main
node_cli_main -->|"dispatches commands"| node_cli_commands
node_cli_main -->|"loads settings"| node_cli_config
node_cli_commands -->|"creates client RPCs"| node_libnetconf
node_libnetconf -->|"connects to"| node_netconf_client
node_netconf_client -->|"sends NETCONF"| node_server_main
node_server_main -->|"initializes transport"| node_libnetconf
node_libnetconf -.->|"secures sessions"| node_ssh_tls
node_server_main -->|"dispatches requests"| node_netconf
node_netconf -->|"uses operations"| node_common
node_netconf -->|"reads and writes data"| node_sysrepo
node_netconf -->|"validates data"| node_libyang
node_netconf -->|"handles commit requests"| node_confirmed
node_netconf -->|"serves monitoring"| node_monitoring
node_netconf -->|"handles NMDA requests"| node_nmda
node_netconf -->|"handles subscriptions"| node_subscriptions
node_subscriptions -->|"registers datastore events"| node_sysrepo
node_subscriptions -->|"sends notifications"| node_libnetconf
node_confirmed -->|"manages commit state"| node_sysrepo
node_monitoring -->|"reads session data"| node_sysrepo
node_nmda -->|"accesses datastores"| node_sysrepo
node_common -->|"accesses configuration"| node_sysrepo
node_common -.->|"transfers URL data"| node_url_services
node_server_yang -->|"defines data models"| node_libyang
node_cli_yang -->|"defines CLI settings"| node_cli_config

click node_cli_main "https://github.com/cesnet/netopeer2/blob/master/cli/main.c"
click node_cli_commands "https://github.com/cesnet/netopeer2/blob/master/cli/commands.c"
click node_cli_config "https://github.com/cesnet/netopeer2/blob/master/cli/configuration.c"
click node_server_main "https://github.com/cesnet/netopeer2/blob/master/src/main.c"
click node_netconf "https://github.com/cesnet/netopeer2/blob/master/src/netconf.c"
click node_common "https://github.com/cesnet/netopeer2/blob/master/src/common.c"
click node_confirmed "https://github.com/cesnet/netopeer2/blob/master/src/netconf_confirmed_commit.c"
click node_monitoring "https://github.com/cesnet/netopeer2/blob/master/src/netconf_monitoring.c"
click node_nmda "https://github.com/cesnet/netopeer2/blob/master/src/netconf_nmda.c"
click node_subscriptions "https://github.com/cesnet/netopeer2/blob/master/src/netconf_subscribed_notifications.c"
click node_server_yang "https://github.com/cesnet/netopeer2/tree/master/modules"
click node_cli_yang "https://github.com/cesnet/netopeer2/blob/master/cli/netopeer2_cli_yang.h"

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_server_main,node_netconf,node_common,node_netconf_client toneBlue
class node_confirmed,node_monitoring,node_nmda,node_subscriptions,node_server_yang toneAmber
class node_cli_main,node_cli_commands,node_cli_config,node_cli_yang toneMint
class node_sysrepo,node_libnetconf,node_libyang,node_url_services,node_ssh_tls toneRose
class node_operator toneIndigo
```

## Components

### Server runtime

- [Server entry](https://github.com/cesnet/netopeer2/blob/master/src/main.c): `src/main.c`
- [RPC handling](https://github.com/cesnet/netopeer2/blob/master/src/netconf.c): `src/netconf.c`
- [Shared operations](https://github.com/cesnet/netopeer2/blob/master/src/common.c): `src/common.c`

### NETCONF features

- [Confirmed commit](https://github.com/cesnet/netopeer2/blob/master/src/netconf_confirmed_commit.c): `src/netconf_confirmed_commit.c`
- [Session monitoring](https://github.com/cesnet/netopeer2/blob/master/src/netconf_monitoring.c): `src/netconf_monitoring.c`
- [NMDA operations](https://github.com/cesnet/netopeer2/blob/master/src/netconf_nmda.c): `src/netconf_nmda.c`
- [Subscriptions](https://github.com/cesnet/netopeer2/blob/master/src/netconf_subscribed_notifications.c): `src/netconf_subscribed_notifications.c`
- [Server schemas](https://github.com/cesnet/netopeer2/tree/master/modules): `modules`

### CLI client

- [CLI entry](https://github.com/cesnet/netopeer2/blob/master/cli/main.c): `cli/main.c`
- [CLI commands](https://github.com/cesnet/netopeer2/blob/master/cli/commands.c): `cli/commands.c`
- [CLI configuration](https://github.com/cesnet/netopeer2/blob/master/cli/configuration.c): `cli/configuration.c`
- [CLI schema](https://github.com/cesnet/netopeer2/blob/master/cli/netopeer2_cli_yang.h): `cli/netopeer2_cli_yang.h`

### External services

- **Sysrepo datastore**
- **libnetconf2 transport**
- **libyang schemas**
- **URL services**
- **SSH / TLS**

### Other components

- **Operator**
- **NETCONF client**

## Connections

- Operator → CLI entry: enters commands
- CLI entry → CLI commands: dispatches commands
- CLI entry → CLI configuration: loads settings
- CLI commands → libnetconf2 transport: creates client RPCs
- libnetconf2 transport → NETCONF client: connects to
- NETCONF client → Server entry: sends NETCONF
- Server entry → libnetconf2 transport: initializes transport
- libnetconf2 transport → SSH / TLS: secures sessions
- Server entry → RPC handling: dispatches requests
- RPC handling → Shared operations: uses operations
- RPC handling → Sysrepo datastore: reads and writes data
- RPC handling → libyang schemas: validates data
- RPC handling → Confirmed commit: handles commit requests
- RPC handling → Session monitoring: serves monitoring
- RPC handling → NMDA operations: handles NMDA requests
- RPC handling → Subscriptions: handles subscriptions
- Subscriptions → Sysrepo datastore: registers datastore events
- Subscriptions → libnetconf2 transport: sends notifications
- Confirmed commit → Sysrepo datastore: manages commit state
- Session monitoring → Sysrepo datastore: reads session data
- NMDA operations → Sysrepo datastore: accesses datastores
- Shared operations → Sysrepo datastore: accesses configuration
- Shared operations → URL services: transfers URL data
- Server schemas → libyang schemas: defines data models
- CLI schema → CLI configuration: defines CLI settings
