# project-simple/simple.toolchain architecture

> Architecture diagram of the GitHub repository project-simple/simple.toolchain, 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/project-simple/simple.toolchain
- Repository: https://github.com/project-simple/simple.toolchain

## Overview

- The “GAMA Plugin” – a set of Java/Maven-based modules (with files like pom.xml, ant scripts, and Eclipse project descriptors) that integrate as a plugin into the GAMA simulation environment.
- The “Unity Template” – a full-fledged Unity project containing scenes, assets, scripts, and editor extensions intended to serve as a starting point for building Unity applications (including VR/AR setups) that work with the SIMPLE toolchain.

##### Main Components
a. GAMA Simulation Environment (external system) – the host into which the “GAMA Plugin” is installed.
– Versioning and build scripts (using Maven and Ant for tasks)
– GAML extension modules (e.g., “gaml.extension.unity”) and other package areas that indicate command handling, species extension, operator definitions, and serialization.
– Connection and communication components (the “Connection” package under “Gama Provider”, WebSocketConnector, etc.) which likely manage bidirectional communication between GAMA and the Unity client.
c. Unity Template – a Unity Project that:
– Provides assets, scenes (both for game simulations and demo environments like multi-player and VR templates)
– Contains user-interface elements and scripts (e.g., “GAMAGeometryExportUI.cs”, “GAMAGeometryLoaderUI.cs”) and runtime logic (for player movement and simulation managers).
– Integrates plugins (such as WebSocket libraries) to connect to the GAMA Plugin for simulation data exchange.
d. Communication Layer – often implemented via WebSockets (as evidenced by the “WebSocket.cs” files in both the Unity Template and the “Gama Provider/Connection” folder). This layer shows the bidirectional data flow between the simulation (GAMA Plugin) and the Unity client.

##### Relationships and Interactions
- The GAMA Plugin sits within the GAMA simulation environment. It exposes a set of APIs or event handlers (likely through serialized data and commands in the “Serialization” and “Simulation” modules) for receiving simulation commands from or sending simulation updates to external systems.
- The Unity Template serves as a client that uses these APIs and communication channels to synchronize simulation state, trigger scene changes, or update visuals in real-time. This interaction is typically mediated via the WebSocket communication layer.
- At a higher level, the two parts are “paired” – one builds on the simulation side and the other on the visualization/client side.
- The build and configuration scripts (files under .github/workflows and project settings for Unity) indicate that there is an automated process for managing releases and integration across these two components.

##### Architectural Patterns and Design Principles
- Modularity is key: the GAMA Plugin is built as a stand-alone module (with its own Maven/Ant build structure) that integrates with GAMA, while the Unity Template is organized as a standard Unity project with well-separated assets, scenes, and scripts.
- There is a clear separation of concerns between simulation (back-end/GAMA) and visualization (front-end/Unity). The communication layer (WebSocket connectors) decouples these two parts.
- Dependency management and continuous integration are present (evidenced by the presence of GitHub Actions workflow files for building and releasing plugins), reinforcing a modular, testable design.

## Diagram (Mermaid)

```mermaid
graph TD
    U["User/Environment"]:::external
    GS["GAMA Simulation Environment"]:::external
    U -->|"interacts"| GS

    subgraph "GAMA Simulation Environment Components"
        GS_Plugin["SIMPLE GAMA Plugin"]:::plugin
        subgraph "GAMA Plugin Components"
            PV["Versioning and Build Scripts"]:::plugin
            PE["GAML Extension Modules"]:::plugin
            PF["Unity Feature for GAMA"]:::plugin
            PWC["Plugin WebSocket Connector (Java)"]:::communication
        end
        GS_Plugin -->|"contains"| PV
        GS_Plugin -->|"contains"| PE
        GS_Plugin -->|"contains"| PF
        GS_Plugin -->|"integrates"| PWC
    end

    GS -->|"hosts"| GS_Plugin
    GS_Plugin -->|"exposes APIs"| C["Communication Layer (WebSocket)"]:::communication

    subgraph "Unity Template Components"
        UT["Unity Template"]:::unity
        UUI["UI and Runtime Scripts"]:::unity
        UGP["GAMA Provider Connection (Unity)"]:::unity
        UWC["WebSocket Connector (Unity)"]:::communication
        UT -->|"includes"| UUI
        UT -->|"includes"| UGP
        UT -->|"includes"| UWC
    end

    C -->|"transmits simulation data"| UT

    click GS_Plugin "https://github.com/project-simple/simple.toolchain/tree/Unity-6/GAMA Plugin/"
    click PV "https://github.com/project-simple/simple.toolchain/tree/Unity-6/GAMA Plugin/eu.project-simple.parent/"
    click PE "https://github.com/project-simple/simple.toolchain/tree/Unity-6/GAMA Plugin/gaml.extension.unity/"
    click PF "https://github.com/project-simple/simple.toolchain/tree/Unity-6/GAMA Plugin/gaml.feature.unity/"
    click PWC "https://github.com/project-simple/simple.toolchain/tree/Unity-6/GAMA Plugin/gaml.extension.unity/src/gaml/extension/unity/commands/"
    click UT "https://github.com/project-simple/simple.toolchain/tree/Unity-6/Unity Template/"
    click UWC "https://github.com/project-simple/simple.toolchain/blob/Unity-6/Unity Template/Assets/Plugins/WebSocket.cs"
    click UGP "https://github.com/project-simple/simple.toolchain/tree/Unity-6/Unity Template/Assets/Scripts/Gama Provider/Connection/"

    classDef external fill:#f9f,stroke:#333,stroke-width:2px;
    classDef plugin fill:#bbf,stroke:#000,stroke-width:1px;
    classDef communication fill:#bfb,stroke:#0a0,stroke-width:1px;
    classDef unity fill:#ffb,stroke:#a50,stroke-width:1px;
```
