# thiagoralves/openplc_editor architecture

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

- Interactive diagram: https://gitdiagram.com/thiagoralves/openplc_editor
- Repository: https://github.com/thiagoralves/openplc_editor

## Overview

This repo is a **cross-platform desktop IDE** (“OpenPLC Editor”) used to **author PLC programs** for the **OpenPLC Runtime**. It is a curated/modified distribution of:
- **Beremiz** (PLC IDE framework, PLCopen tooling, UI/editor workflow)
- **MatIEC** (IEC 61131-3 compiler toolchain)

Key architectural implication: this is **not** a client/server web app; it’s a **local application** that embeds/ships tooling (compiler) and produces artifacts consumed by an external runtime (OpenPLC Runtime).

- The **desktop application** as the primary system boundary
- The **compiler toolchain** (MatIEC) as an internal/packaged subsystem invoked by the IDE
- The **outputs/artifacts** produced (e.g., generated code, PLCopen project files) and where they go (OpenPLC Runtime / deployment target)
- The **update/install flows** (install scripts + optional “check for updates” cloning this repo)

##### File structure (what to map into components)
Top-level structure:
- `editor/` → the **IDE application** (Beremiz-derived, Python3 + wxPython Phoenix per README)
- `matiec/` → the **IEC 61131-3 compiler** (toolchain invoked by the editor)
- `install.sh`, `install-gentoo.sh` → Linux install orchestration (dependencies, setup)
- `update.sh`, `update.cmd` → update automation; implies “self-update / pull latest” mechanics
- `distclean.sh` → build/cleanup; suggests generated artifacts/cache
- `revision` → versioning/build metadata
- `.gitmodules` → vendored submodules (likely upstream Beremiz/MatIEC origins or dependencies)

##### What the README adds (architecture signals)
- Updated to **Python3** + **wxPython Phoenix** → clearly indicates **GUI layer** + Python application logic.
- Windows/macOS installer downloaded from autonomylogic.com → external distribution channel.
- “Check for updates … clone this repository into your installed Editor” → an **update subsystem** that uses Git operations and network access to a repo origin.

##### Desktop GUI Application (Python3 + wxPython Phoenix)
- Lives under `editor/`
- Responsible for UI, project workflow, invoking toolchain
##### Compiler Toolchain (MatIEC executable/library)
- Lives under `matiec/`
- Invoked by the GUI application (likely as a subprocess / CLI tool, or via bindings—confirm by searching `editor/` for calls into matiec)
##### Local File System / Workspace (Projects + Generated Artifacts)
- PLCopen project files, generated code, build outputs, temporary files
##### Install/Update Scripts
- `install.sh`, `install-gentoo.sh`, `update.sh`, `update.cmd`, `distclean.sh`
- These are “ops tooling containers” (not runtime, but essential to lifecycle)

Key interactions:
- GUI App ↔ File System: reads/writes project files and generated outputs
- GUI App → MatIEC: compile/build (pass source/intermediate files, receive artifacts/logs)
- Update tooling ↔ Git origin: fetch latest code
- Install scripts → OS/package manager: install dependencies (wxPython, Python deps, compiler deps)

You label **where each runs**: all local on the developer machine, but with optional network access for updates.

**Goal:** Show major internal modules. This is where you “separate into as many components as possible”.

- **UI Layer (wxPython Views/Frames/Dialogs)**
- **Project Model / PLCopen Model**
- In Beremiz-style IDEs, there’s typically a PLCopen XML model and project tree representation
- **Editors**
- **Build/Compile Orchestrator**
- Converts project model into compilable form
- Invokes MatIEC
- Collects diagnostics/errors and maps them back to editor locations
- **Code Generation / Export**
- Emits C code or runtime-specific artifacts (depending on MatIEC integration)
- **Runtime/Deployment Integration (if present)**
- **Update Manager**
- “Check for updates” feature that clones/pulls repo into installation

For MatIEC (`matiec/`), show pipeline components (verify by looking at MatIEC docs/source):
- **Parser / Frontend**
- **Semantic analysis**
- **IR/AST**
- **Code generator** (often to C)
- **Compiler outputs** (C files, headers, logs)

- UI → Project Model (commands, editing operations)
- Project Model → Build Orchestrator (build request)
- Build Orchestrator → MatIEC (compile)
- MatIEC → Build Orchestrator (errors, outputs)
- Build Orchestrator → UI (diagnostics panel)
- All modules → File System (read/write)

##### Technologies to annotate (only the ones that materially affect architecture)
- `editor/`: **Python 3**, **wxPython Phoenix**, (Beremiz-derived)
- `matiec/`: **MatIEC (IEC 61131-3 compiler)** (implementation language likely C/C++; confirm in subtree)
- OS targets: **Windows / Linux / macOS**
- Update mechanism: **Git** (clone/pull), scripts: **bash**, **cmd**

##### Practical “make it accurate” checklist (what to verify from the repo before finalizing)
- Where/how the editor invokes MatIEC (subprocess call? embedded lib? wrapper script?)
- What the **artifact types** are (C code? XML? binary? runtime package?)
- Any direct integration with OpenPLC Runtime (network deploy vs manual export)
- Where update feature points (remote URL, git remote, branching/tagging)
- Any additional internal services (e.g., symbol browser, plugin system, device config)

## Diagram (Mermaid)

```mermaid
flowchart TD
  %% =========================
  %% Level 1: System Context
  %% =========================
  subgraph L1["C4 L1 — System Context"]
    direction TB

    User["User (PLC Developer)"]:::person

    subgraph Machine["Developer Machine (Windows / Linux / macOS)"]
      direction TB
      EditorSystem["OpenPLC Editor (Desktop IDE)"]:::system
      WorkspaceFS[("Local Workspace / File System\nProjects + Generated Artifacts")]:::storage
    end

    Runtime["OpenPLC Runtime (External)"]:::external
    Installer["Installer Download Site\n(autonomylogic.com)"]:::external
    GitOrigin["Git Repository Origin\n(remote)"]:::external

    User -->|"author_programs"| EditorSystem
    EditorSystem <-->|"read_write"| WorkspaceFS
    EditorSystem -->|"export_deploy_artifacts"| Runtime

    User -->|"download_installer"| Installer
    EditorSystem -->|"check_updates_clone_pull"| GitOrigin
  end

  %% =========================
  %% Level 2: Containers
  %% =========================
  L1 --> L2Anchor[" "]:::hidden

  subgraph L2["C4 L2 — Containers (Local on Developer Machine)"]
    direction TB

    subgraph OpenPLCEditorBoundary["OpenPLC Editor (This Repo)"]
      direction TB
      GUI["Desktop GUI Application\nPython 3 + wxPython Phoenix\n(Beremiz-derived)"]:::ide
      Toolchain["Compiler Toolchain\nMatIEC (IEC 61131-3)"]:::compiler
      FS[("Local Workspace / File System\nPLCopen projects + generated code + logs")]:::storage

      subgraph Ops["Lifecycle Tooling (Install / Update / Clean)"]
        direction TB
        InstallLinux["install.sh\nLinux install orchestration"]:::ops
        InstallGentoo["install-gentoo.sh\nGentoo install orchestration"]:::ops
        UpdateSh["update.sh\nUpdate automation (shell)"]:::ops
        UpdateCmd["update.cmd\nUpdate automation (Windows)"]:::ops
        Distclean["distclean.sh\nBuild/artifact cleanup"]:::ops
        Revision["revision\nVersioning/build metadata"]:::meta
        Gitmodules[".gitmodules\nSubmodule configuration"]:::meta
        Readme["README.md\nDocs / usage notes"]:::meta
        License["LICENSE"]:::meta
      end
    end

    OS["Host OS + Package Managers\n(apt/dnf/pacman/emerge, etc.)"]:::external
    RemoteGit["Git Repository Origin\n(remote)"]:::external
    DistSite["Installer Download Site\n(autonomylogic.com)"]:::external

    GUI <-->|"project_io"| FS
    GUI -->|"invoke_compile"| Toolchain
    Toolchain -->|"outputs_errors_artifacts"| FS
    GUI -->|"show_diagnostics"| GUI

    InstallLinux -->|"install_deps"| OS
    InstallGentoo -->|"install_deps"| OS
    UpdateSh -->|"git_clone_pull"| RemoteGit
    UpdateCmd -->|"git_clone_pull"| RemoteGit
    Distclean -->|"remove_generated"| FS

    Readme -.->|"guides_install_update"| InstallLinux
    Readme -.->|"guides_install_update"| UpdateSh
    DistSite -.->|"provides_installers"| GUI
  end

  %% =========================
  %% Level 3: Components (Editor focus)
  %% =========================
  L2 --> L3Anchor[" "]:::hidden

  subgraph L3["C4 L3 — Component View (Focus: editor/ invoking matiec/)"]
    direction TB

    subgraph EditorComp["editor/ — OpenPLC Editor (Python/wxPython)"]
      direction TB
      UI["UI Layer\nwxPython Frames/Dialogs/Views"]:::ide
      Editors["Language Editors\nLD / FBD / ST / etc."]:::ide
      ProjectModel["Project Model / PLCopen Model\n(Project tree, symbols, metadata)"]:::core
      BuildOrch["Build/Compile Orchestrator\n(pipeline + diagnostics mapping)"]:::core
      Exporter["Code Generation / Export\n(artifacts for runtime)"]:::core
      UpdateMgr["Update Manager\n(Check for updates via Git)"]:::ops

      UI -->|"edit_commands"| Editors
      Editors -->|"mutate_model"| ProjectModel
      UI -->|"browse_configure"| ProjectModel
      UI -->|"build_request"| BuildOrch
      ProjectModel -->|"build_inputs"| BuildOrch
      BuildOrch -->|"generate_export"| Exporter
      UI -->|"update_request"| UpdateMgr
    end

    subgraph MatiecComp["matiec/ — MatIEC Compiler Toolchain"]
      direction TB
      Frontend["Parser / Frontend"]:::compiler
      Semantics["Semantic Analysis"]:::compiler
      IR["AST / IR"]:::compiler
      Codegen["Code Generator (e.g., C)"]:::compiler
      Frontend -->|"build_ast"| IR
      IR -->|"analyze"| Semantics
      Semantics -->|"annotate_ir"| IR
      IR -->|"emit"| Codegen
    end

    Store[("Local Workspace / Artifacts\nPLCopen XML, generated C, logs, temp")]:::storage
    Runtime2["OpenPLC Runtime (External)"]:::external
    Git2["Git Repository Origin (remote)"]:::external

    UI <-->|"read_write"| Store
    ProjectModel <-->|"persist"| Store
    BuildOrch -->|"invoke_matiec"| Frontend
    Codegen -->|"write_outputs"| Store
    BuildOrch -->|"collect_errors"| UI
    Exporter -->|"write_artifacts"| Store
    Exporter -->|"deploy_or_export"| Runtime2
    UpdateMgr -->|"clone_pull"| Git2
  end

  %% =========================
  %% Click events (from component_mapping)
  %% =========================
  click EditorComp "https://github.com/thiagoralves/openplc_editor/tree/master/editor/"
  click MatiecComp "https://github.com/thiagoralves/openplc_editor/tree/master/matiec/"
  click InstallLinux "https://github.com/thiagoralves/openplc_editor/blob/master/install.sh"
  click InstallGentoo "https://github.com/thiagoralves/openplc_editor/blob/master/install-gentoo.sh"
  click UpdateSh "https://github.com/thiagoralves/openplc_editor/blob/master/update.sh"
  click UpdateCmd "https://github.com/thiagoralves/openplc_editor/blob/master/update.cmd"
  click Distclean "https://github.com/thiagoralves/openplc_editor/blob/master/distclean.sh"
  click Revision "https://github.com/thiagoralves/openplc_editor/tree/master/revision"
  click Gitmodules "https://github.com/thiagoralves/openplc_editor/blob/master/.gitmodules"
  click Readme "https://github.com/thiagoralves/openplc_editor/blob/master/README.md"
  click License "https://github.com/thiagoralves/openplc_editor/tree/master/LICENSE"

  %% =========================
  %% Styles
  %% =========================
  classDef hidden fill:transparent,stroke:transparent,color:transparent;

  classDef person fill:#FFF4CC,stroke:#CC9A00,stroke-width:1px,color:#2b2b2b;
  classDef system fill:#D9EEFF,stroke:#2B78C5,stroke-width:1.5px,color:#0f2a44;
  classDef ide fill:#E7F3FF,stroke:#2B78C5,stroke-width:1px,color:#0f2a44;
  classDef core fill:#E9F7EF,stroke:#2E7D32,stroke-width:1px,color:#123a1a;
  classDef compiler fill:#F3E8FF,stroke:#6A1B9A,stroke-width:1px,color:#2b1236;
  classDef storage fill:#FFF0F0,stroke:#C62828,stroke-width:1px,color:#3a0f0f;
  classDef ops fill:#FFEFD6,stroke:#EF6C00,stroke-width:1px,color:#3a2000;
  classDef meta fill:#ECEFF1,stroke:#546E7A,stroke-width:1px,color:#1b2a33;
  classDef external fill:#F5F5F5,stroke:#616161,stroke-width:1px,color:#1f1f1f;
```
