# mavati56/classicladder architecture

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

- Interactive diagram: https://gitdiagram.com/mavati56/classicladder
- Repository: https://github.com/mavati56/classicladder

## Overview

Classic Ladder is a GTK-based PLC ladder and sequential-logic editor with an execution runtime, project persistence, variable access, and local or remote monitoring. The main user flow is to edit and organize sections, save or load a project, then run its logic and inspect variables or connect to a target. The README also documents event logs, Modbus/TCP serving, project transfer, and real-time operation. Some paths are linked only where the README or source index supports the relationship; unsampled implementations limit finer-grained call-flow claims.

Main entry points: [`src/vars_access.c`](https://github.com/mavati56/classicladder/blob/main/src/vars_access.c) (Variable access), [`src/classicladder_gtk.c`](https://github.com/mavati56/classicladder/blob/main/src/classicladder_gtk.c) (Main window), [`src/files.c`](https://github.com/mavati56/classicladder/blob/main/src/files.c) (Project files), [`src/monitor_protocol.c`](https://github.com/mavati56/classicladder/blob/main/src/monitor_protocol.c) (Remote monitor protocol)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_authoring["Logic authoring"]
  node_rung_edit["Ladder editor<br/>[edit.c]"]
  node_seq_edit["Sequential editor<br/>[edit_sequential.c]"]
  node_sections["Section manager<br/>[manager.c]"]
  node_search["Logic search<br/>[search.c]"]
end

subgraph group_runtime["Execution runtime"]
  node_calc["Ladder execution<br/>[calc.c]"]
  node_seq_calc["Sequential execution<br/>[calc_sequential.h]"]
  node_tasks["Periodic tasks<br/>[tasks.c]"]
  node_hardware["Hardware I/O<br/>[hardware.c]"]
end

subgraph group_data["Project and variables"]
  node_vars["Variable access<br/>[vars_access.c]"]
  node_names["Variable names<br/>[vars_names.c]"]
  node_projects["Project files<br/>[files.c]"]
  node_project_meta["Project metadata<br/>[files_project.c]"]
  node_preferences["Preferences<br/>[preferences.c]"]
  node_symbols["Symbols<br/>[symbols.c]"]
end

subgraph group_operations["Monitoring and operations"]
  node_logs["Event logging<br/>[log_events.c]"]
  node_monitor["Remote monitor protocol<br/>[monitor_protocol.c]"]
  node_transfer["Project transfer<br/>[monitor_transfer.c]"]
  node_modbus_server["Modbus/TCP server"]
  node_modbus_master["Modbus master"]
end

subgraph group_interface["GTK interface"]
  node_gtk["Main window"]
  node_menus["Menus and toolbar"]
  node_section_ui["Sections UI<br/>[manager_gtk.c]"]
  node_drawing["Ladder drawing<br/>[drawing.c]"]
  node_seq_drawing["Sequential drawing"]
  node_monitor_ui["Monitor windows"]
end

node_user(("Engineer"))
node_plc_target(("PLC target"))
node_scada(("SCADA client"))

node_user -->|"uses"| node_gtk
node_gtk -->|"opens actions"| node_menus
node_menus -->|"opens manager"| node_section_ui
node_gtk -->|"displays rungs"| node_drawing
node_gtk -->|"displays steps"| node_seq_drawing
node_rung_edit -->|"updates display"| node_drawing
node_rung_edit -->|"uses section data"| node_sections
node_seq_edit -->|"uses drawing"| node_drawing
node_section_ui -->|"adds sections"| node_sections
node_user -->|"edits logic"| node_rung_edit
node_user -->|"edits steps"| node_seq_edit
node_user -->|"loads or saves"| node_projects
node_projects -->|"loads section data"| node_sections
node_projects -->|"loads log config"| node_logs
node_projects -->|"loads variables"| node_vars
node_projects -.->|"handles project info"| node_project_meta
node_tasks -.->|"runs cycles"| node_calc
node_calc -->|"reads and writes"| node_vars
node_calc -->|"uses sections"| node_sections
node_calc -->|"uses sequential logic"| node_seq_calc
node_seq_edit -->|"uses variable names"| node_vars
node_search -.->|"navigates sections"| node_sections
node_search -->|"finds elements"| node_rung_edit
node_names -.->|"names variables"| node_vars
node_symbols -.->|"annotates variables"| node_vars
node_gtk -->|"opens monitor"| node_monitor_ui
node_menus -->|"starts connection"| node_monitor
node_monitor -->|"reads variables"| node_vars
node_monitor -->|"uses transfer"| node_transfer
node_plc_target -->|"connects remotely"| node_monitor
node_monitor -->|"transfers projects"| node_projects
node_scada -->|"connects via TCP"| node_modbus_server
node_modbus_master -->|"accesses variables"| node_vars
node_hardware -.->|"updates I/O"| node_vars
node_logs -.->|"logs configured variables"| node_vars
node_gtk -->|"uses preferences"| node_preferences
node_user -->|"searches logic"| node_search

click node_gtk "https://github.com/mavati56/classicladder/blob/main/src/classicladder_gtk.c"
click node_menus "https://github.com/mavati56/classicladder/blob/main/src/menu_and_toolbar_gtk.c"
click node_rung_edit "https://github.com/mavati56/classicladder/blob/main/src/edit.c"
click node_seq_edit "https://github.com/mavati56/classicladder/blob/main/src/edit_sequential.c"
click node_sections "https://github.com/mavati56/classicladder/blob/main/src/manager.c"
click node_section_ui "https://github.com/mavati56/classicladder/blob/main/src/manager_gtk.c"
click node_drawing "https://github.com/mavati56/classicladder/blob/main/src/drawing.c"
click node_seq_drawing "https://github.com/mavati56/classicladder/blob/main/src/drawing_sequential.c"
click node_search "https://github.com/mavati56/classicladder/blob/main/src/search.c"
click node_calc "https://github.com/mavati56/classicladder/blob/main/src/calc.c"
click node_seq_calc "https://github.com/mavati56/classicladder/blob/main/src/calc_sequential.h"
click node_tasks "https://github.com/mavati56/classicladder/blob/main/src/tasks.c"
click node_vars "https://github.com/mavati56/classicladder/blob/main/src/vars_access.c"
click node_names "https://github.com/mavati56/classicladder/blob/main/src/vars_names.c"
click node_projects "https://github.com/mavati56/classicladder/blob/main/src/files.c"
click node_project_meta "https://github.com/mavati56/classicladder/blob/main/src/files_project.c"
click node_logs "https://github.com/mavati56/classicladder/blob/main/src/log_events.c"
click node_monitor "https://github.com/mavati56/classicladder/blob/main/src/monitor_protocol.c"
click node_transfer "https://github.com/mavati56/classicladder/blob/main/src/monitor_transfer.c"
click node_monitor_ui "https://github.com/mavati56/classicladder/blob/main/src/monitor_windows_gtk.c"
click node_modbus_server "https://github.com/mavati56/classicladder/blob/main/src/protocol_modbus_slave.c"
click node_modbus_master "https://github.com/mavati56/classicladder/blob/main/src/protocol_modbus_master.c"
click node_preferences "https://github.com/mavati56/classicladder/blob/main/src/preferences.c"
click node_symbols "https://github.com/mavati56/classicladder/blob/main/src/symbols.c"
click node_hardware "https://github.com/mavati56/classicladder/blob/main/src/hardware.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_rung_edit,node_seq_edit,node_sections,node_search,node_scada toneBlue
class node_calc,node_seq_calc,node_tasks,node_hardware toneAmber
class node_vars,node_names,node_projects,node_project_meta,node_preferences,node_symbols toneMint
class node_logs,node_monitor,node_transfer,node_modbus_server,node_modbus_master toneRose
class node_gtk,node_menus,node_section_ui,node_drawing,node_seq_drawing,node_monitor_ui,node_user,node_plc_target toneIndigo
```

## Components

### Logic authoring

- [Ladder editor](https://github.com/mavati56/classicladder/blob/main/src/edit.c): `src/edit.c`
- [Sequential editor](https://github.com/mavati56/classicladder/blob/main/src/edit_sequential.c): `src/edit_sequential.c`
- [Section manager](https://github.com/mavati56/classicladder/blob/main/src/manager.c): `src/manager.c`
- [Logic search](https://github.com/mavati56/classicladder/blob/main/src/search.c): `src/search.c`

### Execution runtime

- [Ladder execution](https://github.com/mavati56/classicladder/blob/main/src/calc.c): `src/calc.c`
- [Sequential execution](https://github.com/mavati56/classicladder/blob/main/src/calc_sequential.h): `src/calc_sequential.h`
- [Periodic tasks](https://github.com/mavati56/classicladder/blob/main/src/tasks.c): `src/tasks.c`
- [Hardware I/O](https://github.com/mavati56/classicladder/blob/main/src/hardware.c): `src/hardware.c`

### Project and variables

- [Variable access](https://github.com/mavati56/classicladder/blob/main/src/vars_access.c): `src/vars_access.c`
- [Variable names](https://github.com/mavati56/classicladder/blob/main/src/vars_names.c): `src/vars_names.c`
- [Project files](https://github.com/mavati56/classicladder/blob/main/src/files.c): `src/files.c`
- [Project metadata](https://github.com/mavati56/classicladder/blob/main/src/files_project.c): `src/files_project.c`
- [Preferences](https://github.com/mavati56/classicladder/blob/main/src/preferences.c): `src/preferences.c`
- [Symbols](https://github.com/mavati56/classicladder/blob/main/src/symbols.c): `src/symbols.c`

### Monitoring and operations

- [Event logging](https://github.com/mavati56/classicladder/blob/main/src/log_events.c): `src/log_events.c`
- [Remote monitor protocol](https://github.com/mavati56/classicladder/blob/main/src/monitor_protocol.c): `src/monitor_protocol.c`
- [Project transfer](https://github.com/mavati56/classicladder/blob/main/src/monitor_transfer.c): `src/monitor_transfer.c`
- [Modbus/TCP server](https://github.com/mavati56/classicladder/blob/main/src/protocol_modbus_slave.c): `src/protocol_modbus_slave.c`
- [Modbus master](https://github.com/mavati56/classicladder/blob/main/src/protocol_modbus_master.c): `src/protocol_modbus_master.c`

### GTK interface

- [Main window](https://github.com/mavati56/classicladder/blob/main/src/classicladder_gtk.c): `src/classicladder_gtk.c`
- [Menus and toolbar](https://github.com/mavati56/classicladder/blob/main/src/menu_and_toolbar_gtk.c): `src/menu_and_toolbar_gtk.c`
- [Sections UI](https://github.com/mavati56/classicladder/blob/main/src/manager_gtk.c): `src/manager_gtk.c`
- [Ladder drawing](https://github.com/mavati56/classicladder/blob/main/src/drawing.c): `src/drawing.c`
- [Sequential drawing](https://github.com/mavati56/classicladder/blob/main/src/drawing_sequential.c): `src/drawing_sequential.c`
- [Monitor windows](https://github.com/mavati56/classicladder/blob/main/src/monitor_windows_gtk.c): `src/monitor_windows_gtk.c`

### Other components

- **Engineer**
- **PLC target**
- **SCADA client**

## Connections

- Engineer → Main window: uses
- Main window → Menus and toolbar: opens actions (evidence: `src/classicladder_gtk.c`)
- Menus and toolbar → Sections UI: opens manager (evidence: `src/menu_and_toolbar_gtk.c`)
- Main window → Ladder drawing: displays rungs (evidence: `src/classicladder_gtk.c`)
- Main window → Sequential drawing: displays steps (evidence: `src/classicladder_gtk.c`)
- Ladder editor → Ladder drawing: updates display (evidence: `src/edit.c`)
- Ladder editor → Section manager: uses section data (evidence: `src/edit.c`)
- Sequential editor → Ladder drawing: uses drawing (evidence: `src/edit_sequential.c`)
- Sections UI → Section manager: adds sections (evidence: `src/manager_gtk.c`)
- Engineer → Ladder editor: edits logic
- Engineer → Sequential editor: edits steps
- Engineer → Project files: loads or saves
- Project files → Section manager: loads section data (evidence: `src/files.c`)
- Project files → Event logging: loads log config (evidence: `src/files.c`)
- Project files → Variable access: loads variables (evidence: `src/files.c`)
- Project files → Project metadata: handles project info
- Periodic tasks → Ladder execution: runs cycles
- Ladder execution → Variable access: reads and writes (evidence: `src/calc.c`)
- Ladder execution → Section manager: uses sections (evidence: `src/calc.c`)
- Ladder execution → Sequential execution: uses sequential logic (evidence: `src/calc.c`)
- Sequential editor → Variable access: uses variable names (evidence: `src/edit_sequential.c`)
- Logic search → Section manager: navigates sections
- Logic search → Ladder editor: finds elements (evidence: `src/search.c`)
- Variable names → Variable access: names variables
- Symbols → Variable access: annotates variables
- Main window → Monitor windows: opens monitor (evidence: `src/classicladder_gtk.c`)
- Menus and toolbar → Remote monitor protocol: starts connection (evidence: `src/menu_and_toolbar_gtk.c`)
- Remote monitor protocol → Variable access: reads variables (evidence: `src/monitor_protocol.c`)
- Remote monitor protocol → Project transfer: uses transfer (evidence: `src/monitor_protocol.c`)
- PLC target → Remote monitor protocol: connects remotely
- Remote monitor protocol → Project files: transfers projects (evidence: `src/monitor_protocol.c`)
- SCADA client → Modbus/TCP server: connects via TCP
- Modbus master → Variable access: accesses variables (evidence: `src/protocol_modbus_master.c`)
- Hardware I/O → Variable access: updates I/O
- Event logging → Variable access: logs configured variables
- Main window → Preferences: uses preferences (evidence: `src/classicladder_gtk.c`)
- Engineer → Logic search: searches logic
