# tapaal/tapaal-gui architecture

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

- Interactive diagram: https://gitdiagram.com/tapaal/tapaal-gui
- Repository: https://github.com/tapaal/tapaal-gui

## Overview

The TAPAAL GUI project is essentially a desktop GUI application built in Java that provides a graphical environment for creating, editing, verifying, and simulating timed Petri nets. Its design integrates a rich set of components that cover the user interface, core modeling and simulation engines, I/O, parsing, and verification functionalities.

##### Main Components
- Core Modeling & Business Logic Layer – Found primarily in dk/aau/cs/model (and its subpackages like CPN, NTA, tapn) as well as the translation modules under dk/aau/cs/translations. This layer contains the data structures, simulation classes, and translation code that govern how Petri net elements are modeled, manipulated, and verified.
- Verification and Simulation Engine – Contained in dk/aau/cs/verification and dk/aau/cs/approximation, along with the executables in the UPPAAL and VerifyTAPN subpackages. This is responsible for model checking (including boundedness analysis, simulation runs, and verification result processing).
- Input/Output Operations – Encompassing the dk/aau/cs/io package and its batch processing and query subpackages. These classes handle loading of Petri net files (e.g., pnml, XML formats), writing outputs, and integrating with external verifiers.
- Parsing and Compiler-Like Components – Distributed across the javacc directories (e.g., dk/aau/cs/TCTL and its related parser subdirectories) to parse temporal logic queries and Petri net definitions.
- Utilities & Helpers – Additional low-level support such as logging (Logger.java), debugging (Logger in debug subpackage), memory monitoring, and other utility functions to support the entire application.

##### Relationships and Data Flow
- The User Interface interacts with the Controller layer to capture user actions (e.g., editing a net or running a verification) and translates these events into commands.
- The Controller/Command layer dispatches these actions to the Core Engine, which processes operations on Petri net models, simulation settings, and verification requests.
- The I/O layer interacts both with the Core Engine (loading/saving Petri nets and queries) and external resources (such as invoking external verifiers like UPPAAL).
- Parsing components ensure that both user-generated (or imported) query files and net files are converted into internal representations for further processing.
- Utility classes support cross-cutting concerns like logging, error handling, and memory monitoring.

##### Architectural Patterns and Design Principles
- MVC (Model-View-Controller) Concepts – The application separates the GUI (view) from the business logic (model) and uses controllers and command/undo mechanisms to bridge the two.
- Layered Architecture – The clear separation into presentation (GUI), application logic (controller/commands), domain/model (Petri net representation, simulation, verification), and infrastructure (I/O, parsing) supports maintainability.
- Extensibility – The use of visitors (for example, in the dk/aau/cs/TCTL/visitors package) indicates a design that is open to new operations on the model without altering object structures.

##### Relevant Technologies
- Java with Gradle as the build system.
- Swing components for the GUI.
- JavaCC for parser generation.
- Integration with external tools such as UPPAAL (and possibly other model checking engines) through dedicated packages.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interface Layer
    subgraph "User Interface Layer"
        UI1["User Interface (net.tapaal/gui)"]:::gui
        UI2["User Interface (pipe/gui)"]:::gui
    end

    %% Application Logic / Controller
    subgraph "Application Logic / Controller"
        CTRL["Controller/Command Layer"]:::controller
    end

    %% Core Domain Engine
    subgraph "Core Domain Engine"
        subgraph "Core Modeling & Business Logic"
            MODEL["Model (dk/aau/cs/model)"]:::core
            TRANS["Translations (dk/aau/cs/translations)"]:::core
        end
        subgraph "Verification and Simulation Engine"
            VER["Verification (dk/aau/cs/verification)"]:::verification
            APPROX["Approximation (dk/aau/cs/approximation)"]:::verification
        end
    end

    %% Infrastructure Layer
    subgraph "Infrastructure Layer"
        IO["I/O Operations (dk/aau/cs/io)"]:::io
        subgraph "Parsing & Compiler Components"
            XML["XML Parsing (dk/aau/cs/TCTL/XMLParsing)"]:::parsing
            JAVACC["JavaCC Parsing (src/main/javacc/dk/aau/cs/TCTL)"]:::parsing
        end
    end

    %% Utilities & Helpers
    subgraph "Utilities & Helpers"
        LOGGER["Logger (dk/aau/cs/debug)"]:::utility
        UTIL["Utilities (dk/aau/cs/util)"]:::utility
    end

    %% Build & Deployment Infrastructure
    subgraph "Build & Deployment"
        BUILD["Build Infrastructure"]:::build
    end

    %% Inter-layer Connections
    UI1 -->|"triggers"| CTRL
    UI2 -->|"triggers"| CTRL
    CTRL -->|"invokes"| MODEL
    CTRL -->|"invokes"| IO
    IO -->|"providesData"| XML
    IO -->|"providesData"| JAVACC
    XML -->|"converts"| MODEL
    JAVACC -->|"converts"| MODEL
    MODEL -->|"checks"| VER
    MODEL -->|"checks"| APPROX
    MODEL -->|"translates"| TRANS

    %% Utilities Support
    LOGGER -- "supports" --> MODEL
    LOGGER -- "supports" --> IO
    UTIL -- "supports" --> CTRL

    %% Click Events
    click UI1 "https://github.com/tapaal/tapaal-gui/tree/main/src/main/java/net/tapaal/gui"
    click UI2 "https://github.com/tapaal/tapaal-gui/tree/main/src/main/java/pipe/gui"
    click MODEL "https://github.com/tapaal/tapaal-gui/tree/main/src/main/java/dk/aau/cs/model"
    click TRANS "https://github.com/tapaal/tapaal-gui/tree/main/src/main/java/dk/aau/cs/translations"
    click VER "https://github.com/tapaal/tapaal-gui/tree/main/src/main/java/dk/aau/cs/verification"
    click APPROX "https://github.com/tapaal/tapaal-gui/tree/main/src/main/java/dk/aau/cs/approximation"
    click IO "https://github.com/tapaal/tapaal-gui/tree/main/src/main/java/dk/aau/cs/io"
    click XML "https://github.com/tapaal/tapaal-gui/tree/main/src/main/java/dk/aau/cs/TCTL/XMLParsing"
    click JAVACC "https://github.com/tapaal/tapaal-gui/tree/main/src/main/javacc/dk/aau/cs/TCTL"
    click LOGGER "https://github.com/tapaal/tapaal-gui/tree/main/src/main/java/dk/aau/cs/debug"
    click UTIL "https://github.com/tapaal/tapaal-gui/tree/main/src/main/java/dk/aau/cs/util"
    click BUILD "https://github.com/tapaal/tapaal-gui/blob/main/build.gradle"

    %% Style definitions
    classDef gui fill:#AEDFF7,stroke:#000,stroke-width:2px;
    classDef controller fill:#F7D6E0,stroke:#000,stroke-width:2px;
    classDef core fill:#C8F7C5,stroke:#000,stroke-width:2px;
    classDef verification fill:#FFF7B2,stroke:#000,stroke-width:2px;
    classDef io fill:#C3D7F2,stroke:#000,stroke-width:2px;
    classDef parsing fill:#F7C3C3,stroke:#000,stroke-width:2px;
    classDef utility fill:#D7F7FF,stroke:#000,stroke-width:2px;
    classDef build fill:#F7D7A3,stroke:#000,stroke-width:2px;
```
