# chrxh/alien architecture

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

## Overview

##### Project type and purpose
- This is a desktop-based full-stack simulation application (“ALIEN”) with three primary interfaces:
- A GUI client (ImGui + OpenGL + CUDA)
- A headless CLI (for batch runs)
- A set of PHP‐based server scripts (for upload/download/upvote)

##### File structure
- Top‐level components (all built via CMake + vcpkg):
- external/… – third-party dependencies (ImGui, GLFW, cpp-httplib, CUDA helpers, fonts)
- source/
– Base (logging, math, JSON parsing, settings)
– Cli (headless entry point)
– EngineGpuKernels (all CUDA kernels)
– EngineImpl & EngineInterface (facade, data types, services)
– Gui (all ImGui windows, controllers, OpenGL helpers)
– Network & NetworkTests (REST client services + tests)
– PersisterInterface & PersisterImpl (I/O abstraction for local files and network persistence)
– EngineTests, NetworkTests (unit/integration tests)
- resources/ (shaders, certificates, autosave, settings)
- scripts/Server (PHP REST endpoints)
- scripts/CLI-Tools (Python helpers)
- CMakeLists.txt, vcpkg.json, .github/workflows (CI)

##### README
- Confirms a GPU‐driven physics & life engine, real-time GUI, CLI for batch, REST server for sharing
- Lists external tech: CUDA Toolkit, OpenGL (GLFW/GLAD/GLEW), Dear ImGui, cereal, cpp-httplib, PHP backend, etc.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Libraries
    subgraph "External Libraries"
        EXLib["External Libraries\n(ImGui, GLFW, cpp-httplib, cereal, CUDA runtime)"]:::external
    end

    %% Base Services
    subgraph "Base Services"
        Base["Base Services\n(logging, math, settings, JSON)"]:::base
    end

    %% UI Layer
    subgraph "UI Layer" 
        GUI["GUI Client\n(Dear ImGui, OpenGL)"]:::ui
        CLI["CLI Client\n(headless)"]:::ui
    end

    %% Engine Layer
    subgraph "Engine Layer"
        EI["EngineInterface\n(facade)"]:::engine
        EImpl["EngineImpl\n(core logic)"]:::engine
        EK["EngineGpuKernels\n(CUDA)"]:::engine
    end

    %% Persistence Layer
    subgraph "Persistence Layer"
        PI["PersisterInterface\n(abstraction)"]:::persistence
        PImpl["PersisterImpl\n(local + remote)"]:::persistence
        LocalFS["Local FileSystem"]:::persistence
    end

    %% Network Layer
    subgraph "Network Layer"
        HTTP["HTTP Client Services\n(cpp-httplib)"]:::network
        PHP["PHP REST API\n(scripts/Server)"]:::network
        DB["Database"]:::network
    end

    %% Resources
    Resources["Resources\n(shaders, certificates, autosave)"]:::resources

    %% CI/CD and Build
    CIBuild["CI/CD Workflow\n(.github/workflows)"]:::ci
    BuildCfg["Build Config\n(CMakeLists.txt, vcpkg.json)"]:::ci

    %% Connections
    EXLib -->|provides libs to| GUI
    EXLib -->|provides libs to| CLI
    EXLib -->|provides libs to| EI
    EXLib -->|provides libs to| PI
    EXLib -->|provides libs to| HTTP

    Resources -->|loaded by| GUI
    Resources -->|loaded by| EI

    GUI -->|uses| Base
    CLI -->|uses| Base

    GUI -->|calls| EI
    CLI -->|calls| EI

    EI -->|implements| EImpl
    EImpl -->|invokes| EK

    GUI -->|persists via| PI
    CLI -->|persists via| PI
    PI -->|implemented by| PImpl
    PImpl -->|writes to| LocalFS
    PImpl -->|requests via| HTTP

    GUI -->|lists/uploads via| HTTP
    HTTP -->|"HTTP/REST"| PHP
    PHP -->|reads/writes| DB

    CIBuild -->|builds/tests| BuildCfg

    %% Click Events
    click GUI "https://github.com/chrxh/alien/tree/develop/source/Gui"
    click CLI "https://github.com/chrxh/alien/blob/develop/source/Cli/Main.cpp"
    click EI "https://github.com/chrxh/alien/tree/develop/source/EngineInterface"
    click EImpl "https://github.com/chrxh/alien/tree/develop/source/EngineImpl"
    click EK "https://github.com/chrxh/alien/tree/develop/source/EngineGpuKernels"
    click PI "https://github.com/chrxh/alien/tree/develop/source/PersisterInterface"
    click PImpl "https://github.com/chrxh/alien/tree/develop/source/PersisterImpl"
    click HTTP "https://github.com/chrxh/alien/tree/develop/source/Network"
    click PHP "https://github.com/chrxh/alien/tree/develop/scripts/Server"
    click Base "https://github.com/chrxh/alien/tree/develop/source/Base"
    click EXLib "https://github.com/chrxh/alien/tree/develop/external"
    click Resources "https://github.com/chrxh/alien/tree/develop/resources"
    click CIBuild "https://github.com/chrxh/alien/blob/develop/.github/workflows/ubuntu-ci.yml"
    click BuildCfg "https://github.com/chrxh/alien/blob/develop/CMakeLists.txt"
    classDef ui fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef engine fill:#90EE90,stroke:#333,stroke-width:1px
    classDef persistence fill:#FFA500,stroke:#333,stroke-width:1px
    classDef network fill:#DDA0DD,stroke:#333,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef base fill:#FFFFFF,stroke:#333,stroke-width:1px
    classDef resources fill:#FFE4B5,stroke:#333,stroke-width:1px
    classDef ci fill:#E0E0E0,stroke:#333,stroke-width:1px
```
