# corec-dev/corec architecture

> Architecture diagram of the GitHub repository corec-dev/corec, 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/corec-dev/corec
- Repository: https://github.com/corec-dev/corec

## Overview

CoreC is a headless, configuration-driven IIoT collection and control core. Operators load YAML to start an engine that schedules or subscribes to industrial-device reads, processes points through rules, and publishes them through outbound transports; commands travel back through transports to drivers. The README also documents a REST/WebSocket control plane, discovery, buffering, and observability. Those capabilities are represented from documentation and the repository tree; sampled source was incomplete, so uncertain internal wiring is omitted.

Main entry points: [`engine/engine.go`](https://github.com/corec-dev/corec/blob/main/engine/engine.go) (Core engine), [`engine/driver_manager.go`](https://github.com/corec-dev/corec/blob/main/engine/driver_manager.go) (Driver manager), [`engine/processing.go`](https://github.com/corec-dev/corec/blob/main/engine/processing.go) (Point processing), [`transport/all/all.go`](https://github.com/corec-dev/corec/blob/main/transport/all/all.go) (MQTT and HTTP)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Core runtime"]
  node_config["Config loader<br/>[config.go]"]
  node_engine["Core engine<br/>[engine.go]"]
  node_scheduler["Read scheduler<br/>[scheduler.go]"]
  node_databus["Data bus<br/>[databus.go]"]
  node_cache[("Latest-value cache<br/>[cache.go]")]
end

subgraph group_southbound["Device connectivity"]
  node_drivers["Driver manager<br/>[driver_manager.go]"]
  node_driverplugins["Protocol drivers<br/>[all.go]"]
end

subgraph group_routing["Data routing"]
  node_processing["Point processing<br/>[processing.go]"]
  node_rules["Rule engine<br/>[engine.go]"]
  node_transports["Transport manager"]
  node_transportplugins["MQTT and HTTP<br/>[all.go]"]
end

subgraph group_control["Control plane"]
  node_hub["REST and streams<br/>[server.go]"]
  node_command["Command execution<br/>[command_manager.go]"]
  node_discovery["Node discovery<br/>[discovery.go]"]
end

subgraph group_observability["Observability"]
  node_metrics["Metrics and stats<br/>[manager.go]"]
  node_logs["Logging and tracing<br/>[trace.go]"]
end

node_operator(("Operator"))
node_industrial(("Industrial devices"))
node_broker(("MQTT broker"))
node_controller(("API controller"))

node_operator -->|"supplies YAML"| node_config
node_config -->|"starts runtime"| node_engine
node_engine -->|"manages drivers"| node_drivers
node_engine -->|"starts scheduler"| node_scheduler
node_scheduler -->|"schedules reads"| node_drivers
node_drivers -->|"creates drivers"| node_driverplugins
node_driverplugins -->|"reads and writes"| node_industrial
node_drivers -->|"submits points"| node_databus
node_databus -->|"delivers points"| node_processing
node_processing -->|"updates latest values"| node_cache
node_processing -->|"matches points"| node_rules
node_processing -->|"routes points"| node_transports
node_transports -->|"creates transports"| node_transportplugins
node_transportplugins -.->|"publishes and subscribes"| node_broker
node_broker -.->|"delivers commands"| node_transportplugins
node_transportplugins -->|"dispatches commands"| node_command
node_command -->|"writes device values"| node_drivers
node_controller -->|"requests API"| node_hub
node_hub -->|"queries and controls"| node_engine
node_engine -.->|"starts discovery"| node_discovery
node_engine -->|"records statistics"| node_metrics
node_engine -->|"emits telemetry"| node_logs
node_hub -->|"exposes metrics"| node_metrics

click node_config "https://github.com/corec-dev/corec/blob/main/config/config.go"
click node_engine "https://github.com/corec-dev/corec/blob/main/engine/engine.go"
click node_scheduler "https://github.com/corec-dev/corec/blob/main/engine/scheduler.go"
click node_databus "https://github.com/corec-dev/corec/blob/main/engine/databus.go"
click node_cache "https://github.com/corec-dev/corec/blob/main/engine/cache.go"
click node_drivers "https://github.com/corec-dev/corec/blob/main/engine/driver_manager.go"
click node_driverplugins "https://github.com/corec-dev/corec/blob/main/driver/all/all.go"
click node_processing "https://github.com/corec-dev/corec/blob/main/engine/processing.go"
click node_rules "https://github.com/corec-dev/corec/blob/main/rule/engine.go"
click node_transports "https://github.com/corec-dev/corec/blob/main/engine/transport_manager.go"
click node_transportplugins "https://github.com/corec-dev/corec/blob/main/transport/all/all.go"
click node_hub "https://github.com/corec-dev/corec/blob/main/hub/route/server.go"
click node_command "https://github.com/corec-dev/corec/blob/main/engine/command_manager.go"
click node_discovery "https://github.com/corec-dev/corec/blob/main/engine/discovery.go"
click node_metrics "https://github.com/corec-dev/corec/blob/main/engine/statistic/manager.go"
click node_logs "https://github.com/corec-dev/corec/blob/main/common/trace/trace.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_config,node_engine,node_scheduler,node_databus,node_cache toneBlue
class node_drivers,node_driverplugins toneAmber
class node_processing,node_rules,node_transports,node_transportplugins,node_controller toneMint
class node_hub,node_command,node_discovery toneRose
class node_metrics,node_logs,node_operator,node_industrial,node_broker toneIndigo
```

## Components

### Core runtime

- [Config loader](https://github.com/corec-dev/corec/blob/main/config/config.go): `config/config.go`
- [Core engine](https://github.com/corec-dev/corec/blob/main/engine/engine.go): `engine/engine.go`
- [Read scheduler](https://github.com/corec-dev/corec/blob/main/engine/scheduler.go): `engine/scheduler.go`
- [Data bus](https://github.com/corec-dev/corec/blob/main/engine/databus.go): `engine/databus.go`
- [Latest-value cache](https://github.com/corec-dev/corec/blob/main/engine/cache.go): `engine/cache.go`

### Device connectivity

- [Driver manager](https://github.com/corec-dev/corec/blob/main/engine/driver_manager.go): `engine/driver_manager.go`
- [Protocol drivers](https://github.com/corec-dev/corec/blob/main/driver/all/all.go): `driver/all/all.go`

### Data routing

- [Point processing](https://github.com/corec-dev/corec/blob/main/engine/processing.go): `engine/processing.go`
- [Rule engine](https://github.com/corec-dev/corec/blob/main/rule/engine.go): `rule/engine.go`
- [Transport manager](https://github.com/corec-dev/corec/blob/main/engine/transport_manager.go): `engine/transport_manager.go`
- [MQTT and HTTP](https://github.com/corec-dev/corec/blob/main/transport/all/all.go): `transport/all/all.go`

### Control plane

- [REST and streams](https://github.com/corec-dev/corec/blob/main/hub/route/server.go): `hub/route/server.go`
- [Command execution](https://github.com/corec-dev/corec/blob/main/engine/command_manager.go): `engine/command_manager.go`
- [Node discovery](https://github.com/corec-dev/corec/blob/main/engine/discovery.go): `engine/discovery.go`

### Observability

- [Metrics and stats](https://github.com/corec-dev/corec/blob/main/engine/statistic/manager.go): `engine/statistic/manager.go`
- [Logging and tracing](https://github.com/corec-dev/corec/blob/main/common/trace/trace.go): `common/trace/trace.go`

### Other components

- **Operator**
- **Industrial devices**
- **MQTT broker**
- **API controller**

## Connections

- Operator → Config loader: supplies YAML
- Config loader → Core engine: starts runtime
- Core engine → Driver manager: manages drivers
- Core engine → Read scheduler: starts scheduler
- Read scheduler → Driver manager: schedules reads
- Driver manager → Protocol drivers: creates drivers
- Protocol drivers → Industrial devices: reads and writes
- Driver manager → Data bus: submits points
- Data bus → Point processing: delivers points
- Point processing → Latest-value cache: updates latest values
- Point processing → Rule engine: matches points
- Point processing → Transport manager: routes points
- Transport manager → MQTT and HTTP: creates transports
- MQTT and HTTP → MQTT broker: publishes and subscribes
- MQTT broker → MQTT and HTTP: delivers commands
- MQTT and HTTP → Command execution: dispatches commands
- Command execution → Driver manager: writes device values
- API controller → REST and streams: requests API
- REST and streams → Core engine: queries and controls
- Core engine → Node discovery: starts discovery
- Core engine → Metrics and stats: records statistics
- Core engine → Logging and tracing: emits telemetry
- REST and streams → Metrics and stats: exposes metrics
