# serhmarch/modbustools architecture

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

- Interactive diagram: https://gitdiagram.com/serhmarch/modbustools
- Repository: https://github.com/serhmarch/modbustools

## Overview

1. This repository is a Qt/C++ monorepo for two desktop applications: a Modbus client simulator and a Modbus server/simulator. The `src/core` tree holds the shared platform code, while `src/client` and `src/server` add app-specific behavior, UI, project types, and runtime logic.

2. The architecture is split into three main layers:
   - shared core libraries and GUI widgets in `src/core`
   - client-specific UI/runtime/project code in `src/client`
   - server-specific UI/runtime/project/script code in `src/server`
   This separation is important for diagramming because most screens, models, and runtime objects are app-local, but they reuse common project and UI abstractions from `core`.

3. The shared `core` subsystem provides common infrastructure: application shell, file/project management, plugin manager, runtime threading, SDK helpers, and reusable GUI components like project trees, dataview widgets, log view, help browser, settings dialogs, and address widgets. It is the foundation both apps build on.

4. Both applications use a common domain model centered on projects. The shared project layer defines the core entities `Project`, `Port`, `Device`, `DataView`, and `Builder`/DOM parsing. The client extends this with client-specific dataview behavior, while the server extends it with device references, simulation actions, and script modules.

5. The client app is organized around communication with remote Modbus devices. Its GUI includes project editing, dataview browsing, message sending, byte sending, scanning, and statistics. These features are backed by client runtime classes that turn project definitions into active port/device/message execution.

6. The client runtime boundary is fairly clear: project configuration is translated into runnable ports and devices, then executed through runtime threads. The `send message`, `send bytes`, and `scanner` tools act as side channels that inject requests into the same communication layer while sharing logging and statistics with normal traffic.

7. The server app is organized around emulating Modbus devices and their memory. Its GUI includes project editing, device management, dataview editing, script editors, script module management, simulation actions, and statistics. The server runtime converts the project into runnable ports, devices, scripts, and simulation tasks.

8. The server has an additional execution plane for Python scripting. Each device can have `Init`, `Loop`, and `Final` scripts, plus script modules embedded in the project. The `src/server/python` code and resource files provide the Python integration layer, while runtime classes isolate script execution from the main UI and Modbus I/O loop.

9. Data flow in both apps follows the same general pattern: project files are loaded into the DOM/project model, edited through GUI models/delegates, then compiled into runtime objects by builder classes. At runtime, port-level transports handle Modbus communication, device-level logic applies memory/dataview rules, and UI widgets observe logs, stats, and data state.

10. The protocol scope is broad and materially shapes the architecture: the tools support Modbus TCP, UDP, RTU, ASCII, and RTU/ASCII over TCP/UDP, with many function codes including read/write register/coil operations, diagnostics, file record access, device ID, FIFO queue, and more. This is why the UI has specialized send/scanner dialogs and why the server includes simulation and scripting hooks.

11. External dependencies and packaging are also part of the architecture. The project targets Qt 5.8+ and is based on the external `ModbusLib` library, included as a submodule. Build definitions exist for CMake and Qt `.pro`/`.pri` files, with Docker and GitHub Actions used for containerized image publishing.

12. The repository also includes examples and documentation as first-class artifacts: sample client projects, server scripts, Doxygen docs, screenshots, and troubleshooting notes. These are not runtime subsystems, but they reinforce the intended usage model and are useful for understanding how project, device, port, and script objects are expected to interact.

Main entry points: [`src/server/project`](https://github.com/serhmarch/modbustools/tree/main/src/server/project) (Server project), [`src/core/project`](https://github.com/serhmarch/modbustools/tree/main/src/core/project) (Project model), [`src/server/gui`](https://github.com/serhmarch/modbustools/tree/main/src/server/gui) (Server UI), [`src/client/project`](https://github.com/serhmarch/modbustools/tree/main/src/client/project) (Client project)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_core["Core"]
  node_node_core_shell["Core shell<br/>shared infra"]
  node_node_core_project["Project model<br/>domain model"]
  node_node_core_runtime["Runtime core<br/>execution"]
  node_node_core_gui_project["Project UI<br/>gui boundary"]
  node_node_core_gui_dataview["Dataview UI<br/>gui boundary"]
  node_node_core_gui_misc["Core widgets<br/>gui boundary"]
  node_node_core_sdk["SDK<br/>support library"]
end

subgraph group_group_client["Client"]
  node_node_client_ui["Client UI<br/>application shell"]
  node_node_client_project["Client project<br/>domain extension"]
  node_node_client_runtime["Client runtime<br/>execution"]
  node_node_client_dataview["Client dataview<br/>ui module"]
  node_node_client_tools["Client tools<br/>ui module"]
  node_node_client_projectui["Client project UI<br/>ui module"]
end

subgraph group_group_server["Server"]
  node_node_server_ui["Server UI<br/>application shell"]
  node_node_server_project["Server project<br/>domain extension"]
  node_node_server_runtime["Server runtime<br/>execution"]
  node_node_server_dataview["Server dataview<br/>ui module"]
  node_node_server_device["Device UI<br/>ui module"]
  node_node_server_scripts["Script UI<br/>ui module"]
  node_node_server_actions["Sim actions<br/>ui module"]
end

subgraph group_group_repo["Repo"]
  node_node_repo_build["Build & packaging<br/>repo tooling<br/>[CMakeLists.txt]"]
  node_node_repo_docs["Docs & examples<br/>repo assets"]
  node_node_modbuslib["ModbusLib<br/>external dependency"]
end

node_node_core_shell -->|"manages"| node_node_core_project
node_node_core_shell -->|"orchestrates"| node_node_core_runtime
node_node_core_project -->|"uses"| node_node_core_sdk
node_node_core_gui_project -->|"edits"| node_node_core_project
node_node_core_gui_dataview -->|"edits"| node_node_core_project
node_node_core_gui_misc -.->|"observes"| node_node_core_project
node_node_core_gui_misc -.->|"monitors"| node_node_core_runtime
node_node_client_project -->|"extends"| node_node_core_project
node_node_client_ui -->|"hosts"| node_node_client_projectui
node_node_client_ui -->|"hosts"| node_node_client_dataview
node_node_client_ui -->|"hosts"| node_node_client_tools
node_node_client_projectui -->|"edits"| node_node_client_project
node_node_client_dataview -->|"binds"| node_node_client_project
node_node_client_tools -->|"injects"| node_node_client_runtime
node_node_client_runtime -->|"builds on"| node_node_core_runtime
node_node_client_runtime -->|"compiles"| node_node_client_project
node_node_server_project -->|"extends"| node_node_core_project
node_node_server_ui -->|"hosts"| node_node_server_project
node_node_server_ui -->|"hosts"| node_node_server_dataview
node_node_server_ui -->|"hosts"| node_node_server_device
node_node_server_ui -->|"hosts"| node_node_server_scripts
node_node_server_ui -->|"hosts"| node_node_server_actions
node_node_server_dataview -->|"binds"| node_node_server_project
node_node_server_device -->|"edits"| node_node_server_project
node_node_server_scripts -->|"edits"| node_node_server_project
node_node_server_actions -->|"edits"| node_node_server_project
node_node_server_runtime -->|"builds on"| node_node_core_runtime
node_node_server_runtime -->|"compiles"| node_node_server_project
node_node_server_runtime -->|"uses"| node_node_modbuslib
node_node_client_runtime -->|"uses"| node_node_modbuslib
node_node_repo_build -.->|"builds"| node_node_core_shell
node_node_repo_build -.->|"builds"| node_node_client_ui
node_node_repo_build -.->|"builds"| node_node_server_ui
node_node_repo_docs -.->|"documents"| node_node_client_project
node_node_repo_docs -.->|"documents"| node_node_server_project

click node_node_core_shell "https://github.com/serhmarch/modbustools/tree/main/src/core/core"
click node_node_core_project "https://github.com/serhmarch/modbustools/tree/main/src/core/project"
click node_node_core_runtime "https://github.com/serhmarch/modbustools/tree/main/src/core/runtime"
click node_node_core_gui_project "https://github.com/serhmarch/modbustools/tree/main/src/core/gui/project"
click node_node_core_gui_dataview "https://github.com/serhmarch/modbustools/tree/main/src/core/gui/dataview"
click node_node_core_gui_misc "https://github.com/serhmarch/modbustools/tree/main/src/core/gui"
click node_node_core_sdk "https://github.com/serhmarch/modbustools/tree/main/src/core/sdk"
click node_node_client_ui "https://github.com/serhmarch/modbustools/tree/main/src/client/gui"
click node_node_client_project "https://github.com/serhmarch/modbustools/tree/main/src/client/project"
click node_node_client_runtime "https://github.com/serhmarch/modbustools/tree/main/src/client/runtime"
click node_node_client_dataview "https://github.com/serhmarch/modbustools/tree/main/src/client/gui/dataview"
click node_node_client_tools "https://github.com/serhmarch/modbustools/tree/main/src/client/gui/sendmessage"
click node_node_client_projectui "https://github.com/serhmarch/modbustools/tree/main/src/client/gui/project"
click node_node_server_ui "https://github.com/serhmarch/modbustools/tree/main/src/server/gui"
click node_node_server_project "https://github.com/serhmarch/modbustools/tree/main/src/server/project"
click node_node_server_runtime "https://github.com/serhmarch/modbustools/tree/main/src/server/runtime"
click node_node_server_dataview "https://github.com/serhmarch/modbustools/tree/main/src/server/gui/dataview"
click node_node_server_device "https://github.com/serhmarch/modbustools/tree/main/src/server/gui/device"
click node_node_server_scripts "https://github.com/serhmarch/modbustools/tree/main/src/server/gui/script"
click node_node_server_actions "https://github.com/serhmarch/modbustools/tree/main/src/server/gui/simactions"
click node_node_repo_build "https://github.com/serhmarch/modbustools/blob/main/CMakeLists.txt"
click node_node_repo_docs "https://github.com/serhmarch/modbustools/tree/main/doc"
click node_node_modbuslib "https://github.com/serhmarch/modbustools/tree/main/modbus"

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_node_core_shell,node_node_core_project,node_node_core_runtime,node_node_core_gui_project,node_node_core_gui_dataview,node_node_core_gui_misc,node_node_core_sdk toneBlue
class node_node_client_ui,node_node_client_project,node_node_client_runtime,node_node_client_dataview,node_node_client_tools,node_node_client_projectui toneAmber
class node_node_server_ui,node_node_server_project,node_node_server_runtime,node_node_server_dataview,node_node_server_device,node_node_server_scripts,node_node_server_actions toneMint
class node_node_repo_build,node_node_repo_docs,node_node_modbuslib toneRose
```

## Components

### Core

Shared libraries, project model, runtime, SDK, and reusable GUI

- [Core shell](https://github.com/serhmarch/modbustools/tree/main/src/core/core): shared infra · Application shell, file manager, plugin manager, and shared core entrypoints · `src/core/core`
- [Project model](https://github.com/serhmarch/modbustools/tree/main/src/core/project): domain model · Shared Project, Port, Device, DataView, DOM, and builder layer · `src/core/project`
- [Runtime core](https://github.com/serhmarch/modbustools/tree/main/src/core/runtime): execution · Shared runtime task threads and execution support · `src/core/runtime`
- [Project UI](https://github.com/serhmarch/modbustools/tree/main/src/core/gui/project): gui boundary · Shared project tree, models, delegates, and project dialogs · `src/core/gui/project`
- [Dataview UI](https://github.com/serhmarch/modbustools/tree/main/src/core/gui/dataview): gui boundary · Shared dataview widgets, models, delegates, and editors · `src/core/gui/dataview`
- [Core widgets](https://github.com/serhmarch/modbustools/tree/main/src/core/gui): gui boundary · Shared log view, statistics, help browser, settings, address widget, and dialogs · `src/core/gui`
- [SDK](https://github.com/serhmarch/modbustools/tree/main/src/core/sdk): support library · Binary readers/writers, task interfaces, and shared helpers · `src/core/sdk`

### Client

Modbus client simulator application

- [Client UI](https://github.com/serhmarch/modbustools/tree/main/src/client/gui): application shell · Main window, client-specific UI wiring, and window management · `src/client/gui`
- [Client project](https://github.com/serhmarch/modbustools/tree/main/src/client/project): domain extension · Client-specific project, port, device, dataview, DOM, and builder extensions · `src/client/project`
- [Client runtime](https://github.com/serhmarch/modbustools/tree/main/src/client/runtime): execution · Runnable ports, devices, messages, threads, and request execution · `src/client/runtime`
- [Client dataview](https://github.com/serhmarch/modbustools/tree/main/src/client/gui/dataview): ui module · Client dataview browser, model, delegate, and manager · `src/client/gui/dataview`
- [Client tools](https://github.com/serhmarch/modbustools/tree/main/src/client/gui/sendmessage): ui module · Send message, send bytes, scanner, and statistics dialogs · `src/client/gui/sendmessage`
- [Client project UI](https://github.com/serhmarch/modbustools/tree/main/src/client/gui/project): ui module · Client project tree, models, delegates, and dialogs · `src/client/gui/project`

### Server

Modbus server and device simulation application

- [Server UI](https://github.com/serhmarch/modbustools/tree/main/src/server/gui): application shell · Main window, output view, and server-specific UI wiring · `src/server/gui`
- [Server project](https://github.com/serhmarch/modbustools/tree/main/src/server/project): domain extension · Server-specific project, device refs, dataview, sim actions, script modules, DOM, and builder · `src/server/project`
- [Server runtime](https://github.com/serhmarch/modbustools/tree/main/src/server/runtime): execution · Runnable ports, devices, simulation actions, scripts, threads, and runtime coordination · `src/server/runtime`
- [Server dataview](https://github.com/serhmarch/modbustools/tree/main/src/server/gui/dataview): ui module · Server dataview browser, model, delegate, and manager · `src/server/gui/dataview`
- [Device UI](https://github.com/serhmarch/modbustools/tree/main/src/server/gui/device): ui module · Device management, device editor, and device UI model/delegate · `src/server/gui/device`
- [Script UI](https://github.com/serhmarch/modbustools/tree/main/src/server/gui/script): ui module · Script editor, script manager, script module editor, and device script editors · `src/server/gui/script`
- [Sim actions](https://github.com/serhmarch/modbustools/tree/main/src/server/gui/simactions): ui module · Simulation action browser, model, delegate, and editor dialogs · `src/server/gui/simactions`

### Repo

Build, docs, examples, and packaging

- [Build & packaging](https://github.com/serhmarch/modbustools/blob/main/CMakeLists.txt): repo tooling · CMake, Qt project files, Dockerfile, and GitHub Actions publishing · `CMakeLists.txt`
- [Docs & examples](https://github.com/serhmarch/modbustools/tree/main/doc): repo assets · Doxygen docs, README content, samples, screenshots, and troubleshooting notes · `doc`
- [ModbusLib](https://github.com/serhmarch/modbustools/tree/main/modbus): external dependency · External Modbus protocol library used by both applications · `modbus`

## Connections

- Core shell → Project model: manages · Core shell owns shared project lifecycle
- Core shell → Runtime core: orchestrates · Core shell coordinates runtime startup and shutdown
- Project model → SDK: uses · Shared project layer relies on SDK helpers and task types
- Project UI → Project model: edits · Project UI presents the shared project model
- Dataview UI → Project model: edits · Dataview UI binds to shared dataview entities
- Core widgets → Project model: observes · Shared dialogs and widgets reflect project state
- Core widgets → Runtime core: monitors · Log, statistics, and help views observe runtime behavior
- Client project → Project model: extends · Client domain specializes the shared project model
- Client UI → Client project UI: hosts · Client application shell hosts project editing screens
- Client UI → Client dataview: hosts · Client shell also hosts dataview browsing
- Client UI → Client tools: hosts · Client shell exposes message sending and scanner tools
- Client project UI → Client project: edits · Client project UI edits client-specific project data
- Client dataview → Client project: binds · Client dataview UI binds to client dataview objects
- Client tools → Client runtime: injects · Send message, bytes, and scanner tools drive the same communication layer
- Client runtime → Runtime core: builds on · Client runtime uses shared runtime threads and execution support
- Client runtime → Client project: compiles · Client runtime turns project definitions into runnable objects
- Server project → Project model: extends · Server domain specializes the shared project model
- Server UI → Server project: hosts · Server shell hosts project, device, script, and action screens
- Server UI → Server dataview: hosts · Server shell exposes dataview editing and browsing
- Server UI → Device UI: hosts · Server shell manages device editing and selection
- Server UI → Script UI: hosts · Server shell provides script editor workflows
- Server UI → Sim actions: hosts · Server shell exposes simulation action editing
- Server dataview → Server project: binds · Server dataview UI binds to server dataview objects
- Device UI → Server project: edits · Device UI edits server device definitions
- Script UI → Server project: edits · Script tools edit script modules and device scripts
- Sim actions → Server project: edits · Simulation action tools edit server actions
- Server runtime → Runtime core: builds on · Server runtime uses shared runtime threads and execution support
- Server runtime → Server project: compiles · Server runtime turns project definitions into runnable ports, devices, and scripts
- Server runtime → ModbusLib: uses · Server runtime depends on the external Modbus library
- Client runtime → ModbusLib: uses · Client runtime depends on the external Modbus library
- Build & packaging → Core shell: builds · Repo build config includes the shared core targets
- Build & packaging → Client UI: builds · Repo build config includes the client application
- Build & packaging → Server UI: builds · Repo build config includes the server application
- Docs & examples → Client project: documents · Examples and docs show client project usage
- Docs & examples → Server project: documents · Examples and docs show server project and scripting usage
