# evergineteam/digitaltwin-demo architecture

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

- Interactive diagram: https://gitdiagram.com/evergineteam/digitaltwin-demo
- Repository: https://github.com/evergineteam/digitaltwin-demo

## Overview

##### Project Type and Purpose
- It is a simulation platform (Digital Twin) aimed at representing a solar energy field.
- The simulation provides time lapse functionalities and interactive measurement displays (clicking on panels opens up measurement dialogs).
- The architecture supports multiple deployment targets (Web, Windows, and a custom editor) and relies on 3D models and scenes stored within the Content folder.

##### Main Components
a. Core Simulation Module:
- This is embodied by the main DigitalTwin project and associated features (Orbit, Picking, SolarPanel, Sun) under DigitalTwin/Features.
- It contains logic for simulation control, time lapse service, scene management (MyApplication.cs, MyScene.cs), and data handling (SampleData, TimeLapseService).

b. Content Assets:
- The Content directory holds a structured collection of 3D models (e.g., Panel, Valley) and scene data under “Models” and “Scenes”.
- Visual resources such as textures, materials, and embedded assets are organized hierarchically, representing the physical simulation environment.

c. User Interfaces and Interaction Layers:
- DigitalTwin.Web.Server (with its cshtml pages, API endpoints, and configuration files) and DigitalTwin.Web provide the web-based front end.
- DigitalTwin.Windows and DigitalTwin.Windows.OpenGL represent alternative Windows-based rendering or client solutions.
- DigitalTwin.Editor offers a custom tool for editing or adjusting simulation parameters.

d. Infrastructure & Integration:
- External tools and dependencies: .NET6 framework, Evergine engine (as noted on the README and use of Evergine assets in the wwwroot folder).
- Platform-specific build solutions (multiple .sln files) help accommodate the different client apps.

##### Relationships and Data Flow
- The Core Simulation module interacts with the Content Assets to render scenes and models, using the materials, textures, and 3D models to build the simulation.
- The UI layers (Web, Windows, and Editor) act as front ends—receiving user inputs (e.g., mouse clicks for panel selection) that are then forwarded as commands or queries to the core simulation.
- The Web Server acts as a bridge, handling API calls and routing data between the simulation backend and the web-based UI.
- Inter-component communication might be represented via API calls, direct method invocations, or event-driven triggers (e.g., when a panel is picked or the solar angle updates).

##### Architectural Patterns/Design Principles
- Modular design: The segregation into different folders (Features, Content, various project solutions) suggests a plug-and-play or modular architecture.
- Multi-platform support is key – consider representing each client (web, Windows, editor) as separate nodes that all interface with a common simulation core.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "User Interfaces"
        UI1["Web Server"]:::ui
        UI2["Web Front-End"]:::ui
        UI3["Windows Client"]:::ui
        UI4["Windows OpenGL Client"]:::ui
        UI5["Custom Editor"]:::ui
    end

    subgraph "Core Simulation Module"
        A["MyApplication"]:::simulation
        B["MyScene"]:::simulation
        C["SampleData"]:::simulation
        D["TimeLapseService"]:::simulation
        subgraph "Features"
            E["Orbit"]:::simulation
            F["Picking"]:::simulation
            G["SolarPanel"]:::simulation
            H["Sun"]:::simulation
        end
    end

    CA["3D Models & Scenes"]:::content
    EX["External: .NET6 & Evergine"]:::integration

    UI1 -->|"API"| A
    UI2 -->|"input"| A
    UI3 -->|"client_request"| A
    UI4 -->|"client_request"| A
    UI5 -->|"parameter_edits"| A

    A -->|"flow"| B
    B -->|"flow"| C
    C -->|"flow"| D

    D -->|"scene_management"| CA
    EX -->|"engine_integration"| A

    click A "https://github.com/evergineteam/digitaltwin-demo/blob/main/DigitalTwin/MyApplication.cs"
    click B "https://github.com/evergineteam/digitaltwin-demo/blob/main/DigitalTwin/MyScene.cs"
    click C "https://github.com/evergineteam/digitaltwin-demo/blob/main/DigitalTwin/SampleData.cs"
    click D "https://github.com/evergineteam/digitaltwin-demo/blob/main/DigitalTwin/TimeLapseService.cs"
    click E "https://github.com/evergineteam/digitaltwin-demo/tree/main/DigitalTwin/Features/Orbit"
    click F "https://github.com/evergineteam/digitaltwin-demo/tree/main/DigitalTwin/Features/Picking"
    click G "https://github.com/evergineteam/digitaltwin-demo/tree/main/DigitalTwin/Features/SolarPanel"
    click H "https://github.com/evergineteam/digitaltwin-demo/tree/main/DigitalTwin/Features/Sun"
    click CA "https://github.com/evergineteam/digitaltwin-demo/tree/main/Content/"
    click UI1 "https://github.com/evergineteam/digitaltwin-demo/tree/main/DigitalTwin.Web.Server/"
    click UI2 "https://github.com/evergineteam/digitaltwin-demo/tree/main/DigitalTwin.Web/"
    click UI3 "https://github.com/evergineteam/digitaltwin-demo/tree/main/DigitalTwin.Windows/"
    click UI4 "https://github.com/evergineteam/digitaltwin-demo/tree/main/DigitalTwin.Windows.OpenGL/"
    click UI5 "https://github.com/evergineteam/digitaltwin-demo/tree/main/DigitalTwin.Editor/"

    classDef simulation fill:#ffcccc,stroke:#cc0000,stroke-width:2px;
    classDef content fill:#ccffcc,stroke:#009900,stroke-width:2px;
    classDef ui fill:#ccccff,stroke:#000099,stroke-width:2px;
    classDef integration fill:#ffffcc,stroke:#999900,stroke-width:2px;
```
