# gama-platform/gama architecture

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

- Interactive diagram: https://gitdiagram.com/gama-platform/gama
- Repository: https://github.com/gama-platform/gama

## Overview

##### Project type and purpose
- This is an open-source, Eclipse-based, multi-module Java application implementing the GAMA modeling and simulation platform.
- It provides both a full GUI application (Eclipse RCP + plugins) and a headless server, plus a domain-specific language (GAML) compiler, an annotation processor, a host of extensions, documentation, and packaging scripts.

##### Top-level components
- Build & CI: Maven parent POM, Travis CI scripts, module dependency management.
- Core engine (“gama.core”): the simulation kernel, message bus, metamodel, runtime, scheduler, outputs.
- GAML language support
- Annotation processor (“gama.processor”): generates metadata, docs, test scaffolding.
- Compiler (“gaml.compiler”): Xtext-based parser, validator, code generator.
- UI application (Eclipse RCP product)
- Application shell (“gama.ui.application”): workbench, perspectives.
- Editor (“gama.ui.editor”): GAML text editor, Xtext integration.
- Experiment view (“gama.ui.experiment”): controls and displays simulation runs.
- Navigator (“gama.ui.navigator”): project browser.
- Shared UI libraries (“gama.ui.shared”), viewers (“gama.ui.viewers”), display implementations (“java2d”, “opengl”).
- Headless server (“gama.headless”): command parser, batch runner, WebSocket server.
- Extensions (“gama.extension.*”): optional plugins adding BDI, database connectors, network skills, physics, stats, etc.
- Dependencies bundle (“gama.dependencies”): third-party jars (Geotools, JTS, JFreeChart, etc.).
- Documentation generator (“gama.documentation”): XSLT and Java tools producing user docs.
- Product packaging (“gama.product”, “gama.p2site”): assembly of features into installable Eclipse products.

##### Relationships & interactions
- Build pipeline (Maven + Travis) compiles modules in order: annotations → processor → parent → product.
- At runtime:
GAML source (editor or CLI) → compiler → core engine ← annotation-generated helpers.
Core engine publishes events to UI display plugins.
UI application orchestrates editor, experiment and display plugins via OSGi/Eclipse extension points.
Headless server exposes core engine services over WebSockets and CLI.
Extensions register new GAML statements or skills via the annotation processor and plugin.xml.

##### Architectural patterns & principles
- Plugin-based modularization: each feature or layer is an Eclipse/OSGi plugin.
- Multi-module Maven reactor: clear build-time dependency management.
- DSL implementation via Xtext: parser→AST→EMF metamodel→validation→generator.
- Layered separation: language/compiler layer, core engine, UI layer, headless server, packaging.
- Extension points and inversion of control: new behaviors added via plugin.xml and Java annotations.

##### Technologies & frameworks
- Java 21, Maven, Travis CI.
- Eclipse PDE/RCP, OSGi.
- Xtext (for GAML).
- EMF (metamodels, AST).
- WebSocket (Java-WebSocket) for headless server.
- Geotools, JTS, JFreeChart for spatial and chart outputs.
- YourKit profiler support.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Build-time components
    subgraph "Build & CI" 
        direction TB
        MavenPOM["Maven Parent POM"]:::build
        TravisCI["Travis CI & GitHub Actions"]:::build
    end

    %% Language layer
    subgraph "Language Layer"
        direction TB
        Annotations["Annotation Definitions"]:::build
        Processor["Annotation Processor"]:::build
        Compiler["GAML Compiler<br/>(Xtext, EMF)"]:::build
    end

    %% Core runtime layer
    subgraph "Core Engine Layer"
        direction TB
        CoreEngine["Core Engine<br/>(Scheduler, Messaging, Metamodel)"]:::core
    end

    %% UI layer
    subgraph "UI Application" 
        direction TB
        UIShell["Application Shell"]:::ui
        UIEditor["GAML Text Editor"]:::ui
        UIExperiment["Experiment View"]:::ui
        UINavigation["Navigator"]:::ui
        UIShared["Shared UI Libraries"]:::ui
        UIDisplay2D["Display Java2D"]:::ui
        UIDisplayGL["Display OpenGL"]:::ui
        UIViewers["UI Viewers"]:::ui
    end

    %% Headless server
    subgraph "Headless Server" 
        direction TB
        Headless["Headless Server<br/>(WebSocket, CLI)"]:::headless
    end

    %% Extensions
    subgraph "Extensions" 
        direction TB
        ExtBDI["BDI Extension"]:::ext
        ExtDB["Database Connector"]:::ext
        ExtFIPA["FIPA Protocol"]:::ext
        ExtImage["Image Processing"]:::ext
        ExtMaths["Math Models"]:::ext
        ExtNetwork["Network Skills"]:::ext
        ExtPedestrian["Pedestrian Skills"]:::ext
        ExtPhysics["Physics Engine"]:::ext
        ExtSerialize["Serialization"]:::ext
        ExtStats["Statistics"]:::ext
        ExtTraffic["Traffic Simulation"]:::ext
    end

    %% Other modules
    Dependencies["Dependencies Bundle"]:::ext
    DocGen["Documentation Generator"]:::ext
    subgraph "Packaging / Product"
        direction TB
        P2Site["Eclipse Feature Site"]:::ext
        ProductDef["Product Definition & Scripts"]:::ext
    end

    External["External Services<br/>(WebSocket Clients, REST, I/O)"]:::headless

    %% Connections
    MavenPOM -->|builds| Annotations
    MavenPOM --> Processor
    MavenPOM --> Compiler
    MavenPOM --> CoreEngine
    MavenPOM --> UIShell
    MavenPOM --> Headless
    MavenPOM --> Dependencies
    MavenPOM --> DocGen
    MavenPOM --> P2Site
    MavenPOM --> ProductDef
    TravisCI -->|runs pipeline| MavenPOM

    Annotations -->|generates metadata| Processor
    Processor -->|provides API| Compiler
    Compiler -->|generates code| CoreEngine

    CoreEngine -->|publishes events| UIShell
    UIShell -->|uses services| CoreEngine
    CoreEngine -->|exposes CLI/WebSocket| Headless
    Headless -->|invokes engine| CoreEngine

    CoreEngine -->|OSGi registry| ExtBDI
    CoreEngine --> ExtDB
    CoreEngine --> ExtFIPA
    CoreEngine --> ExtImage
    CoreEngine --> ExtMaths
    CoreEngine --> ExtNetwork
    CoreEngine --> ExtPedestrian
    CoreEngine --> ExtPhysics
    CoreEngine --> ExtSerialize
    CoreEngine --> ExtStats
    CoreEngine --> ExtTraffic

    UIShell --> UIEditor
    UIShell --> UIExperiment
    UIShell --> UINavigation
    UIShell --> UIShared
    UIShared --> UIDisplay2D
    UIShared --> UIDisplayGL
    UIShared --> UIViewers

    UIShell -->|package UI| P2Site
    ProductDef -->|assembles| P2Site

    Dependencies -->|runtime libs| CoreEngine
    Dependencies --> UIShell
    Dependencies --> Headless

    DocGen -->|produces docs| P2Site

    Headless --> External
    UIShell --> External

    %% Click Events
    click MavenPOM "https://github.com/gama-platform/gama/blob/2024-06/gama.parent/pom.xml"
    click TravisCI "https://github.com/gama-platform/gama/tree/2024-06/travis/"
    click TravisCI "https://github.com/gama-platform/gama/blob/2024-06/.github/workflows/*.yaml"
    click Annotations "https://github.com/gama-platform/gama/tree/2024-06/gama.annotations/"
    click Processor "https://github.com/gama-platform/gama/tree/2024-06/gama.processor/"
    click Compiler "https://github.com/gama-platform/gama/tree/2024-06/gaml.compiler/"
    click CoreEngine "https://github.com/gama-platform/gama/tree/2024-06/gama.core/"
    click UIShell "https://github.com/gama-platform/gama/tree/2024-06/gama.ui.application/"
    click UIEditor "https://github.com/gama-platform/gama/tree/2024-06/gama.ui.editor/"
    click UIExperiment "https://github.com/gama-platform/gama/tree/2024-06/gama.ui.experiment/"
    click UINavigation "https://github.com/gama-platform/gama/tree/2024-06/gama.ui.navigator/"
    click UIShared "https://github.com/gama-platform/gama/tree/2024-06/gama.ui.shared/"
    click UIDisplay2D "https://github.com/gama-platform/gama/tree/2024-06/gama.ui.display.java2d/"
    click UIDisplayGL "https://github.com/gama-platform/gama/tree/2024-06/gama.ui.display.opengl/"
    click UIViewers "https://github.com/gama-platform/gama/tree/2024-06/gama.ui.viewers/"
    click Headless "https://github.com/gama-platform/gama/tree/2024-06/gama.headless/"
    click ExtBDI "https://github.com/gama-platform/gama/tree/2024-06/gama.extension.bdi/"
    click ExtDB "https://github.com/gama-platform/gama/tree/2024-06/gama.extension.database/"
    click ExtFIPA "https://github.com/gama-platform/gama/tree/2024-06/gama.extension.fipa/"
    click ExtImage "https://github.com/gama-platform/gama/tree/2024-06/gama.extension.image/"
    click ExtMaths "https://github.com/gama-platform/gama/tree/2024-06/gama.extension.maths/"
    click ExtNetwork "https://github.com/gama-platform/gama/tree/2024-06/gama.extension.network/"
    click ExtPedestrian "https://github.com/gama-platform/gama/tree/2024-06/gama.extension.pedestrian/"
    click ExtPhysics "https://github.com/gama-platform/gama/tree/2024-06/gama.extension.physics/"
    click ExtSerialize "https://github.com/gama-platform/gama/tree/2024-06/gama.extension.serialize/"
    click ExtStats "https://github.com/gama-platform/gama/tree/2024-06/gama.extension.stats/"
    click ExtTraffic "https://github.com/gama-platform/gama/tree/2024-06/gama.extension.traffic/"
    click Dependencies "https://github.com/gama-platform/gama/tree/2024-06/gama.dependencies/"
    click DocGen "https://github.com/gama-platform/gama/tree/2024-06/gama.documentation/"
    click P2Site "https://github.com/gama-platform/gama/tree/2024-06/gama.p2site/"
    click ProductDef "https://github.com/gama-platform/gama/tree/2024-06/gama.product/"

    %% Styles
    classDef build fill:#D0E6FF,stroke:#0366D6;
    classDef core fill:#D6FFD6,stroke:#228B22;
    classDef ui fill:#FFE4B5,stroke:#FF8C00;
    classDef headless fill:#E8D0FF,stroke:#8A2BE2;
    classDef ext fill:#F0F0F0,stroke:#A9A9A9;

    %% Legend
    subgraph Legend
        direction TB
        L1["Blue = Build & CI"]:::build
        L2["Green = Core Engine"]:::core
        L3["Orange = UI Modules"]:::ui
        L4["Purple = Headless / External"]:::headless
        L5["Gray = Extensions / Packaging"]:::ext
    end
```
