# dpedwards/java-petrinet-simulator architecture

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

- Interactive diagram: https://gitdiagram.com/dpedwards/java-petrinet-simulator
- Repository: https://github.com/dpedwards/java-petrinet-simulator

## Overview

Based on your project’s file tree and README, this is a Java-based Petri Net Simulator that integrates a graphical user interface (GUI) with a simulation engine for Petri Nets. The project is structured in layers and follows an MVC-like separation – with the “business” package representing the core simulation/model logic, the “presentation” package implementing the GUI (views and controllers), and the “data” package handling file management. You also have external assets, tests, build configuration (Ant), and several third-party libraries for mocking and testing.

##### Main Components
- GUI / Presentation Layer:
– Located in the “src/presentation” directory.
- Business / Simulation Engine Layer:
– Found in “src/business”.
– Houses the core Petri Net simulation classes such as PetriNet, Transition, Place, Arc (InputArc, OutputArc), Simulation, TimedSimulation, and other related model classes.
- Data / File Management Layer:
– In the “src/data” package.
– Includes FileManager.java which is likely used for import/export of Petri Net descriptions (supported also by XML import templates in assets/import_templates).
- Asset and UML Documentation:
- Testing:
– The “test” directory shows unit tests for almost every business class, reinforcing design accuracy.
- Build and Dependencies:
– The existence of build.xml, nbproject files, and dependency libraries (e.g., JUnit) indicates integration and build management using Apache Ant along with IDE support (NetBeans, Visual Studio Code).

##### Relationships and Interactions
- The GUI layer interacts with the Business layer by triggering operations to create, simulate, and analyze a Petri Net.
– For example, GUI actions (like “Run PetriNet” or “Add Transition”) invoke methods in the PetriNet or Simulation classes.
- The Business layer is architected to encapsulate core simulation data and logic.
– It models the Petri Net components (Places, Transitions, Arcs) and simulation steps.
- The Data layer provides file I/O and persistence functionality.
– It enables import and export of net definitions and simulation settings, bridged with the Business layer.
- The testing suite validates these interactions and core functionalities ensuring that each component works correctly.

##### Architectural Patterns and Design Principles
- Model-View Separation:
– The separation between the “business” (model/simulation) and “presentation” (GUI) packages reflects a Model-View-Controller (MVC)–esque approach.
- Modularization:
– Splitting concerns into distinct packages allows clear dependency management and easier maintenance.
- Extensibility:

##### Incorporate Key Technologies
- Java 19 for the runtime environment.
- Apache Ant for build automation.
- NetBeans and Visual Studio Code for IDE and dependency management.
- Libraries like JUnit for testing, Mockito for mock testing, as well as byte-buddy and janino for any underlying dynamic or compilation features.

##### Elements
- Use clear labels for each major component:
- “GUI/Presentation”
- “Simulation Engine/Business Logic”
- “File Management/Data Layer”
- “Testing Suite”
- And optionally “Assets & Documentation”
- E.g., from GUI components to Simulation Engine (user actions trigger simulation events).
- Rectangles for main components.

##### Detail and Clarity
- As many essential architectural elements as possible.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% GUI / Presentation Layer
    subgraph "GUI / Presentation Layer"
        GUI["GUI.java & Frm*/Canvas"]:::presentation
    end

    %% Simulation Engine / Business Logic
    subgraph "Simulation Engine / Business Logic"
        Simulation["PetriNet Simulation Engine"]:::business
        PetriNet["PetriNet Model"]:::business
        Transition["Transition Model"]:::business
        Place["Place Model"]:::business
        Arc["Arc Models (InputArc/OutputArc)"]:::business
        SimProcess["Simulation Process (TimedSimulation)"]:::business
    end

    %% Data / File Management Layer
    subgraph "File Management / Data Layer"
        FileManager["FileManager.java (I/O)"]:::data
    end

    %% Testing Suite
    subgraph "Testing Suite"
        Tests["Unit Tests (Business)"]:::testing
    end

    %% Assets & Documentation
    subgraph "Assets & Documentation"
        Assets["UML & Import Templates"]:::assets
    end

    %% Build & Dependencies Management
    subgraph "Build & Dependencies"
        Build["build.xml & nbproject/ & lib"]:::build
    end

    %% Connections
    GUI -->|"simulatePetriNet"| Simulation
    Simulation -->|"load/saveNet"| FileManager
    Simulation -->|"modeledBy"| PetriNet
    Simulation -->|"modeledBy"| Transition
    Simulation -->|"modeledBy"| Place
    Simulation -->|"modeledBy"| Arc
    Simulation -->|"executes"| SimProcess
    Tests -->|"validate"| Simulation
    Build -->|"builds"| GUI
    Build -->|"builds"| Simulation
    Build -->|"builds"| FileManager
    Assets -->|"documents"| GUI
    Assets -->|"references"| Simulation

    %% Click Events
    click GUI "https://github.com/dpedwards/java-petrinet-simulator/tree/main/src/presentation"
    click Simulation "https://github.com/dpedwards/java-petrinet-simulator/tree/main/src/business"
    click FileManager "https://github.com/dpedwards/java-petrinet-simulator/blob/main/src/data/FileManager.java"
    click Assets "https://github.com/dpedwards/java-petrinet-simulator/tree/main/assets"
    click Tests "https://github.com/dpedwards/java-petrinet-simulator/tree/main/test"
    click Build "https://github.com/dpedwards/java-petrinet-simulator/blob/main/build.xml"

    %% Styles
    classDef presentation fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
    classDef business fill:#F9E79F,stroke:#B9770E,stroke-width:2px;
    classDef data fill:#D5F5E3,stroke:#27AE60,stroke-width:2px;
    classDef testing fill:#FADBD8,stroke:#C0392B,stroke-width:2px;
    classDef assets fill:#E8DAEF,stroke:#8E44AD,stroke-width:2px;
    classDef build fill:#FCF3CF,stroke:#B7950B,stroke-width:2px;
```
