# tsntools/opencnc architecture

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

- Interactive diagram: https://gitdiagram.com/tsntools/opencnc
- Repository: https://github.com/tsntools/opencnc

## Overview

OpenCNC is a TSN network-control system: operators define device models, topology and streams; services then configure devices, discover topology and monitor resources. The tree shows distinct configuration, monitoring, topology-discovery and TSN allocation/notification domains, alongside a GUI and shared state/management code. The README is empty, and excerpts are partial; several service-to-service relationships are therefore represented only as unverified dashed links or omitted. The GUI's stream API is shown, but its server-side destination is not established by the available evidence.

Main entry points: [`gui_service/frontend/src/App.tsx`](https://github.com/tsntools/opencnc/blob/main/gui_service/frontend/src/App.tsx) (OpenCNC GUI), [`monitor_service/pkg/engine/engine.go`](https://github.com/tsntools/opencnc/blob/main/monitor_service/pkg/engine/engine.go) (Monitoring engine), [`main_service/pkg/event-handler/handler.go`](https://github.com/tsntools/opencnc/blob/main/main_service/pkg/event-handler/handler.go) (Event handling), [`gui_service/frontend/src/streamsScreen.tsx`](https://github.com/tsntools/opencnc/blob/main/gui_service/frontend/src/streamsScreen.tsx) (Stream editor)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_operator["Operator interface"]
  node_gui["OpenCNC GUI<br/>[App.tsx]"]
  node_gui_screens["Operator screens<br/>[screens.tsx]"]
  node_gui_streams["Stream editor<br/>[streamsScreen.tsx]"]
  node_gui_api["GUI API client<br/>[api.ts]"]
  node_gui_components["UI components<br/>[components.tsx]"]
  node_gui_data["UI sample data<br/>[data.ts]"]
  node_gui_backend["GUI application service<br/>[service.go]"]
  node_gui_http["GUI HTTP transport<br/>[handler.go]"]
end

subgraph group_configuration["Device configuration"]
  node_config_service["Configuration API<br/>[service.go]"]
  node_config_engine["Configuration transactions<br/>[engine.go]"]
  node_protocol_backend["Device protocol backend<br/>[netconf_backend.go]"]
  node_config_plugins["Device model plugins<br/>[vlan_2021.go]"]
end

subgraph group_network["Topology and state"]
  node_nni["Management interface<br/>[server.go]"]
  node_store[("Shared configuration store<br/>[topology_store.go]")]
  node_topology_discovery["Topology discovery<br/>[dicovery.go]"]
  node_topology_server["Topology service<br/>[server.go]"]
  node_observability["Observability client<br/>[client.go]"]
end

subgraph group_monitoring["Monitoring"]
  node_monitor_engine["Monitoring engine<br/>[engine.go]"]
  node_resource_monitor["Resource monitor<br/>[resourcemonitor.go]"]
  node_collectors["Device collectors"]
  node_monitor_service_api["Monitoring API<br/>[service.go]"]
end

subgraph group_tsn["TSN orchestration"]
  node_main_events["Event handling<br/>[handler.go]"]
  node_uni["UNI endpoints<br/>[grpc_server.go]"]
  node_tsn_admission["Stream admission<br/>[admissionCheck.go]"]
  node_tsn_allocation["Resource allocation<br/>[rae.go]"]
  node_tsn_optimizer["Path optimization"]
  node_tsn_notify["TSN notifications"]
end

node_operator(("Network operator"))

node_operator -.->|"uses"| node_gui
node_gui -->|"selects screens"| node_gui_screens
node_gui -->|"renders"| node_gui_components
node_gui -->|"loads navigation"| node_gui_data
node_gui -->|"renders streams"| node_gui_streams
node_gui_streams -->|"loads and mutates"| node_gui_api
node_gui_streams -->|"renders"| node_gui_components
node_gui_screens -->|"renders"| node_gui_components
node_gui -.->|"calls API"| node_gui_http
node_gui_http -.->|"delegates"| node_gui_backend
node_nni -->|"stores topology"| node_store
node_topology_discovery -.->|"reports discovery"| node_topology_server
node_config_service -.->|"dispatches config"| node_config_engine
node_config_engine -->|"creates backend"| node_protocol_backend
node_protocol_backend -.->|"uses mappings"| node_config_plugins
node_config_engine -.->|"persists config"| node_store
node_uni -.->|"dispatches requests"| node_main_events
node_main_events -.->|"requests admission"| node_tsn_admission
node_tsn_admission -.->|"checks path"| node_tsn_optimizer
node_tsn_admission -.->|"allocates resources"| node_tsn_allocation
node_tsn_notify -.->|"reports events"| node_main_events
node_monitor_engine -->|"creates monitor"| node_resource_monitor
node_resource_monitor -->|"adds collectors"| node_collectors
node_monitor_service_api -.->|"dispatches monitoring"| node_monitor_engine
node_monitor_engine -->|"records events"| node_observability
node_monitor_engine -.->|"requests reconfiguration"| node_main_events

click node_gui "https://github.com/tsntools/opencnc/blob/main/gui_service/frontend/src/App.tsx"
click node_gui_screens "https://github.com/tsntools/opencnc/blob/main/gui_service/frontend/src/screens.tsx"
click node_gui_streams "https://github.com/tsntools/opencnc/blob/main/gui_service/frontend/src/streamsScreen.tsx"
click node_gui_api "https://github.com/tsntools/opencnc/blob/main/gui_service/frontend/src/api.ts"
click node_gui_components "https://github.com/tsntools/opencnc/blob/main/gui_service/frontend/src/components.tsx"
click node_gui_data "https://github.com/tsntools/opencnc/blob/main/gui_service/frontend/src/data.ts"
click node_gui_backend "https://github.com/tsntools/opencnc/blob/main/gui_service/internal/app/service.go"
click node_gui_http "https://github.com/tsntools/opencnc/blob/main/gui_service/internal/transport/http/handler.go"
click node_nni "https://github.com/tsntools/opencnc/blob/main/main_service/pkg/nni/server.go"
click node_store "https://github.com/tsntools/opencnc/blob/main/common/store-wrapper/topology_store.go"
click node_topology_discovery "https://github.com/tsntools/opencnc/blob/main/topology_service/pkg/discovery/dicovery.go"
click node_topology_server "https://github.com/tsntools/opencnc/blob/main/topology_service/pkg/server/server.go"
click node_config_service "https://github.com/tsntools/opencnc/blob/main/config_service/grpc_server/service.go"
click node_config_engine "https://github.com/tsntools/opencnc/blob/main/config_service/pkg/engine/engine.go"
click node_protocol_backend "https://github.com/tsntools/opencnc/blob/main/config_service/pkg/protocolbackends/netconf/netconf_backend.go"
click node_config_plugins "https://github.com/tsntools/opencnc/blob/main/config_service/pkg/plugins/netconf/vlan_2021.go"
click node_main_events "https://github.com/tsntools/opencnc/blob/main/main_service/pkg/event-handler/handler.go"
click node_uni "https://github.com/tsntools/opencnc/blob/main/main_service/pkg/uni/grpc_server.go"
click node_tsn_admission "https://github.com/tsntools/opencnc/blob/main/tsn_service/pkg/admission_control/admissionCheck.go"
click node_tsn_allocation "https://github.com/tsntools/opencnc/blob/main/tsn_service/pkg/resource_allocation_entity/rae.go"
click node_tsn_optimizer "https://github.com/tsntools/opencnc/blob/main/tsn_service/pkg/internalOptimizer/internalOptimizer.go"
click node_tsn_notify "https://github.com/tsntools/opencnc/blob/main/tsn_service/pkg/notificationHandler/notificationHandler.go"
click node_monitor_engine "https://github.com/tsntools/opencnc/blob/main/monitor_service/pkg/engine/engine.go"
click node_resource_monitor "https://github.com/tsntools/opencnc/blob/main/monitor_service/pkg/monitors/resourcemonitor.go"
click node_collectors "https://github.com/tsntools/opencnc/blob/main/monitor_service/pkg/collectors/netconf_collector.go"
click node_monitor_service_api "https://github.com/tsntools/opencnc/blob/main/monitor_service/structures/grpc_server/service.go"
click node_observability "https://github.com/tsntools/opencnc/blob/main/common/observability/client.go"

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_gui,node_gui_screens,node_gui_streams,node_gui_api,node_gui_components,node_gui_data,node_gui_backend,node_gui_http toneBlue
class node_config_service,node_config_engine,node_protocol_backend,node_config_plugins toneAmber
class node_nni,node_store,node_topology_discovery,node_topology_server,node_observability toneMint
class node_monitor_engine,node_resource_monitor,node_collectors,node_monitor_service_api toneRose
class node_main_events,node_uni,node_tsn_admission,node_tsn_allocation,node_tsn_optimizer,node_tsn_notify,node_operator toneIndigo
```

## Components

### Operator interface

- [OpenCNC GUI](https://github.com/tsntools/opencnc/blob/main/gui_service/frontend/src/App.tsx): `gui_service/frontend/src/App.tsx`
- [Operator screens](https://github.com/tsntools/opencnc/blob/main/gui_service/frontend/src/screens.tsx): `gui_service/frontend/src/screens.tsx`
- [Stream editor](https://github.com/tsntools/opencnc/blob/main/gui_service/frontend/src/streamsScreen.tsx): `gui_service/frontend/src/streamsScreen.tsx`
- [GUI API client](https://github.com/tsntools/opencnc/blob/main/gui_service/frontend/src/api.ts): `gui_service/frontend/src/api.ts`
- [UI components](https://github.com/tsntools/opencnc/blob/main/gui_service/frontend/src/components.tsx): `gui_service/frontend/src/components.tsx`
- [UI sample data](https://github.com/tsntools/opencnc/blob/main/gui_service/frontend/src/data.ts): `gui_service/frontend/src/data.ts`
- [GUI application service](https://github.com/tsntools/opencnc/blob/main/gui_service/internal/app/service.go): `gui_service/internal/app/service.go`
- [GUI HTTP transport](https://github.com/tsntools/opencnc/blob/main/gui_service/internal/transport/http/handler.go): `gui_service/internal/transport/http/handler.go`

### Device configuration

- [Configuration API](https://github.com/tsntools/opencnc/blob/main/config_service/grpc_server/service.go): `config_service/grpc_server/service.go`
- [Configuration transactions](https://github.com/tsntools/opencnc/blob/main/config_service/pkg/engine/engine.go): `config_service/pkg/engine/engine.go`
- [Device protocol backend](https://github.com/tsntools/opencnc/blob/main/config_service/pkg/protocolbackends/netconf/netconf_backend.go): `config_service/pkg/protocolbackends/netconf/netconf_backend.go`
- [Device model plugins](https://github.com/tsntools/opencnc/blob/main/config_service/pkg/plugins/netconf/vlan_2021.go): `config_service/pkg/plugins/netconf/vlan_2021.go`

### Topology and state

- [Management interface](https://github.com/tsntools/opencnc/blob/main/main_service/pkg/nni/server.go): `main_service/pkg/nni/server.go`
- [Shared configuration store](https://github.com/tsntools/opencnc/blob/main/common/store-wrapper/topology_store.go): `common/store-wrapper/topology_store.go`
- [Topology discovery](https://github.com/tsntools/opencnc/blob/main/topology_service/pkg/discovery/dicovery.go): `topology_service/pkg/discovery/dicovery.go`
- [Topology service](https://github.com/tsntools/opencnc/blob/main/topology_service/pkg/server/server.go): `topology_service/pkg/server/server.go`
- [Observability client](https://github.com/tsntools/opencnc/blob/main/common/observability/client.go): `common/observability/client.go`

### Monitoring

- [Monitoring engine](https://github.com/tsntools/opencnc/blob/main/monitor_service/pkg/engine/engine.go): `monitor_service/pkg/engine/engine.go`
- [Resource monitor](https://github.com/tsntools/opencnc/blob/main/monitor_service/pkg/monitors/resourcemonitor.go): `monitor_service/pkg/monitors/resourcemonitor.go`
- [Device collectors](https://github.com/tsntools/opencnc/blob/main/monitor_service/pkg/collectors/netconf_collector.go): `monitor_service/pkg/collectors/netconf_collector.go`
- [Monitoring API](https://github.com/tsntools/opencnc/blob/main/monitor_service/structures/grpc_server/service.go): `monitor_service/structures/grpc_server/service.go`

### TSN orchestration

- [Event handling](https://github.com/tsntools/opencnc/blob/main/main_service/pkg/event-handler/handler.go): `main_service/pkg/event-handler/handler.go`
- [UNI endpoints](https://github.com/tsntools/opencnc/blob/main/main_service/pkg/uni/grpc_server.go): `main_service/pkg/uni/grpc_server.go`
- [Stream admission](https://github.com/tsntools/opencnc/blob/main/tsn_service/pkg/admission_control/admissionCheck.go): `tsn_service/pkg/admission_control/admissionCheck.go`
- [Resource allocation](https://github.com/tsntools/opencnc/blob/main/tsn_service/pkg/resource_allocation_entity/rae.go): `tsn_service/pkg/resource_allocation_entity/rae.go`
- [Path optimization](https://github.com/tsntools/opencnc/blob/main/tsn_service/pkg/internalOptimizer/internalOptimizer.go): `tsn_service/pkg/internalOptimizer/internalOptimizer.go`
- [TSN notifications](https://github.com/tsntools/opencnc/blob/main/tsn_service/pkg/notificationHandler/notificationHandler.go): `tsn_service/pkg/notificationHandler/notificationHandler.go`

### Other components

- **Network operator**

## Connections

- Network operator → OpenCNC GUI: uses
- OpenCNC GUI → Operator screens: selects screens (evidence: `gui_service/frontend/src/App.tsx`)
- OpenCNC GUI → UI components: renders (evidence: `gui_service/frontend/src/App.tsx`)
- OpenCNC GUI → UI sample data: loads navigation (evidence: `gui_service/frontend/src/App.tsx`)
- OpenCNC GUI → Stream editor: renders streams (evidence: `gui_service/frontend/src/App.tsx`)
- Stream editor → GUI API client: loads and mutates (evidence: `gui_service/frontend/src/streamsScreen.tsx`)
- Stream editor → UI components: renders (evidence: `gui_service/frontend/src/streamsScreen.tsx`)
- Operator screens → UI components: renders (evidence: `gui_service/frontend/src/screens.tsx`)
- OpenCNC GUI → GUI HTTP transport: calls API
- GUI HTTP transport → GUI application service: delegates
- Management interface → Shared configuration store: stores topology (evidence: `main_service/pkg/nni/server.go`)
- Topology discovery → Topology service: reports discovery
- Configuration API → Configuration transactions: dispatches config
- Configuration transactions → Device protocol backend: creates backend (evidence: `config_service/pkg/engine/engine.go`)
- Device protocol backend → Device model plugins: uses mappings
- Configuration transactions → Shared configuration store: persists config
- UNI endpoints → Event handling: dispatches requests
- Event handling → Stream admission: requests admission
- Stream admission → Path optimization: checks path
- Stream admission → Resource allocation: allocates resources
- TSN notifications → Event handling: reports events
- Monitoring engine → Resource monitor: creates monitor (evidence: `monitor_service/pkg/engine/engine.go`)
- Resource monitor → Device collectors: adds collectors
- Monitoring API → Monitoring engine: dispatches monitoring
- Monitoring engine → Observability client: records events (evidence: `monitor_service/pkg/engine/engine.go`)
- Monitoring engine → Event handling: requests reconfiguration
