# esdlmapeditoressim/esdl-mapeditor architecture

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

- Interactive diagram: https://gitdiagram.com/esdlmapeditoressim/esdl-mapeditor
- Repository: https://github.com/esdlmapeditoressim/esdl-mapeditor

## Overview

- Frontend (Client Side): Represent the Vue-based application. This includes:
- Vue components (located in the “vue” directory and its subdirectories such as “components”, “apps”, “composables”, etc.).
- Static assets (from the “static” directory) that include custom CSS, JavaScript utilities, and plugins.
- Templates (in “templates”) used for rendering web pages.
- Backend (Server Side): Represent the Python application server.
- The central entry point “app.py” which starts the server.
- Core domain logic split into packages such as “esdl” (for ESDL handling), “extensions” (various integration modules like for BAG, spatial operations, and workflows), and “src” (which contains additional helper functions, configurations, workflow logic, etc.).
- External Integrations and APIs: Illustrate the integration points with several external energy models/services:
- ESSIM (for energy system simulation)
- ETM (Energy Transition Model)
- VESTA, PICO, and more
This may also include integration with external data repositories and GIS engines (GEOS via PostGIS as mentioned in the README).
- Docker and Deployment: Represent the Docker container setup that encapsulates the whole stack.
- This includes several Dockerfiles (e.g., Dockerfile-uwsgi, Dockerfile-gunicorn, etc.) and docker-compose configurations for development and production.

##### Component Relationships and Data Flows
- How the Frontend communicates with the Backend:
- Data flow for editing, saving, and loading ESDL files.
- Dependencies within the backend:
- “esdl” and “extensions” modules interact to provide the core business logic for loading, processing and converting energy system data.
- “src” modules add supporting functionality (logging, versioning, workflow management).
- External services:
- The Docker layer should be depicted as an orchestration layer encapsulating both the frontend container (or build process) and the backend container, with explicit ports (e.g., port 8111) and network relationships (as configured in the docker-compose files).

##### Architectural Patterns and Design Principles
- MVC/MVVM-like Separation: Although not formally documented, there is a clear separation between a presentation layer (Vue components, templates, static files) and a backend service layer (Python modules, API endpoints, workflow logic).
- Microservice or Modular Components: While the code exists in one repository, the presence of distinct directories for “extensions” (multiple integration/feature modules) hints at a modular structure that can be independently extended or maintained.
- Containerization: The use of multiple Dockerfiles and docker-compose configurations emphasizes that deployment and environment consistency are key design principles.

##### Relevant Technologies
- Python 3 used for the backend; important libraries are likely referenced in requirements.txt, requirements-uwsgi, and other dependency files.
- Vue.js is the framework for the frontend.
- Docker (with various configurations) for containerizing the application.
- Yarn and NodeJS for frontend package management and build processes.
- External services and simulation tools (ESSIM, ETM, etc.) that are integrated to support energy system simulation and optimization.

##### Specific Elements
- Clear labels for each component:
- “Vue Frontend” comprising “components,” “apps,” “static assets,” etc.
- “Python Backend” with modules “esdl”, “extensions”, and “src.”
- “External APIs/Services” such as ESSIM, ETM, VESTA, and others.
- “Docker Deployment” which includes multiple Dockerfiles and docker-compose configuration.
- Requests originating from the Vue frontend into the Flask (or similar) server process in Python.
- Data updates between the backend and external simulation engines.
- Additional visual cues:

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend Layer"
        A["Vue Components"]:::frontend
        B["Static Assets"]:::frontend
        C["Templates"]:::frontend
    end

    subgraph "Backend Layer"
        D["app.py (Server Entry)"]:::backend
        E["ESDL Module"]:::backend
        F["Extensions Module"]:::backend
        G["src Module"]:::backend
    end

    subgraph "External Services"
        H["ESSIM Service"]:::external
        I["ETM Service"]:::external
        J["VESTA Service"]:::external
    end

    subgraph "Docker & Deployment"
        K["Docker & Compose"]:::docker
        L["Makefile"]:::docker
        M["Environment Files"]:::docker
    end

    %% Frontend sends REST API calls to Backend
    A ---|"RESTAPI_calls"| D
    B ---|"RESTAPI_calls"| D
    C ---|"RESTAPI_calls"| D

    %% Backend invokes internal modules
    D -->|"invokes"| E
    D -->|"invokes"| F
    D -->|"invokes"| G

    %% Extensions module integrates with external services
    F -->|"integration"| H
    F -->|"integration"| I
    F -->|"integration"| J

    %% Docker deployment orchestrates Frontend and Backend
    K ---|"deploys"| A
    K ---|"deploys"| D
    L --- K
    M --- K

    %% Click Events for Frontend Components
    click A "https://github.com/esdlmapeditoressim/esdl-mapeditor/tree/main/vue/"
    click B "https://github.com/esdlmapeditoressim/esdl-mapeditor/tree/main/static/"
    click C "https://github.com/esdlmapeditoressim/esdl-mapeditor/tree/main/templates/"

    %% Click Events for Python Backend
    click D "https://github.com/esdlmapeditoressim/esdl-mapeditor/blob/main/app.py"
    click E "https://github.com/esdlmapeditoressim/esdl-mapeditor/tree/main/esdl/"
    click F "https://github.com/esdlmapeditoressim/esdl-mapeditor/tree/main/extensions/"
    click G "https://github.com/esdlmapeditoressim/esdl-mapeditor/tree/main/src/"

    %% Click Events for External Integrations
    click H "https://github.com/esdlmapeditoressim/esdl-mapeditor/blob/main/extensions/essim.py"
    click I "https://github.com/esdlmapeditoressim/esdl-mapeditor/blob/main/extensions/etm_interface.py"
    click J "https://github.com/esdlmapeditoressim/esdl-mapeditor/blob/main/extensions/vesta.py"

    %% Click Events for Docker & Deployment
    click K "https://github.com/esdlmapeditoressim/esdl-mapeditor/tree/main/docker/"
    click L "https://github.com/esdlmapeditoressim/esdl-mapeditor/tree/main/Makefile"
    click M "https://github.com/esdlmapeditoressim/esdl-mapeditor/blob/main/.env.local-docker"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef backend fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef external fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef docker fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
```
