# barthpaleologue/cosmosjourneyer architecture

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

- Interactive diagram: https://gitdiagram.com/barthpaleologue/cosmosjourneyer
- Repository: https://github.com/barthpaleologue/cosmosjourneyer

## Overview

##### Main Components
- Web Application Frontend – This includes everything inside the “src” folder. It is responsible for the game’s core logic, rendering, animations, procedural generation, user interface (HTML, CSS/SCSS, and TypeScript modules), shaders, and assets management.
- Tauri-based Backend/Container – Found in the “src-tauri” directory, this part deals with bundling the web app in a desktop application and may include system-level capabilities and native code integration (written in Rust).
- Game Engine and Simulation Core – This is represented by several TypeScript modules (in “src/ts”) that cover core simulation elements such as star systems, orbital objects, celestial bodies, physics, procedural asset generation (planets, space stations, missions, etc.), and post-processes.
- Rendering and Visualization – The “src/asset”, “src/shaders”, and “src/html” directories include the assets (3D models, textures), shader programs for visual effects, and HTML pages for overlays and menus.
- User Interface and Input Management – Under “src/ts/ui”, “src/styles”, and “src/locales,” you have the UI panels, internationalization files, and styles, ensuring an immersive user experience.
- Asset and Save Management – The “src/ts/assets” and “src/ts/saveFile” directories indicate components for managing in-game assets (textures, sounds, and procedural elements) and implementing saving/loading of game states.
- Research and Experimentation – The “research” folder holds various notebooks and documents (in Jupyter and LyX) that likely contain experimental implementations or data used to drive some simulation parameters (such as atmospheric density, temperature, gradients, etc.).
- Continuous Integration & Deployment – The “.github” folder with its workflows shows automated pipelines for testing, linting, deploying, and building both web and Tauri versions.

##### Relationships and Interactions
- The web client (the main game code in “src/ts”) is the heart of the simulation and rendering engine. It interacts closely with the asset modules to load and manage game assets and with the UI modules to handle user inputs and render overlays.
- Procedural generation and simulation modules, such as those under “src/ts/starSystem,” “src/ts/planets,” “src/ts/orbit,” and “src/ts/asteroidFields,” interact to build the virtual universe. They share data with the rendering engine and feedback into the physics and controls systems.
- The shader modules and graphic asset folders provide the rendering logic for visual effects. They are used by the main engine to deliver realistic rendering and post-processing (e.g., atmospheric scattering, lens flare, and volumetric effects).
- The Tauri backend bridges the web technologies with native capabilities, facilitating desktop deployment. Data flow between the Tauri Rust code (in “src-tauri”) and the TypeScript frontend must be clearly depicted.
- External services and deployment pipelines (as defined in CI/CD workflows) support integration and testing, ensuring consistency between the web and desktop versions.

##### Architectural Patterns and Design Principles
- Modular and Layered Design: The architecture separates concerns clearly—rendering, simulation, UI, asset management, and native integration.
- Client-Container Separation: Emphasize the decoupling between the frontend (which runs the game simulation using web technologies) and the desktop container (Tauri), which provides system-level capabilities.
- CI/CD Pipeline Integration: It is also valuable to represent (even at a higher level) how the automated workflows connect with code testing, formatting, and deployment for both web and Tauri environments.

##### Relevant Technologies, Frameworks, and Libraries
- Web Technologies: TypeScript, HTML, CSS/SCSS.
- Rendering Framework: Likely based on BabylonJS (as referenced in credits), along with custom GLSL shaders.
- Desktop Integration: Tauri (utilizing Rust code in “src-tauri” for the native bridge).
- Build and Deployment: pnpm for dependency management, GitHub Actions for CI/CD, and tooling for code formatting and linting (ESLint, Prettier).
- Asset Management: Custom procedural asset generation modules and standard asset pipelines (models, textures, sounds).

## Diagram (Mermaid)

```mermaid
flowchart TD
    CI("CI/CD Pipelines (.github)"):::ci
    RES("Research & Experimentation (research)"):::research
    FE("Web Application Frontend (src/)"):::frontend
    GE("Game Engine and Simulation Core (src/ts/)"):::simulation
    R1("Assets (src/asset/)"):::rendering
    R2("Shaders (src/shaders/)"):::rendering
    R3("HTML (src/html/)"):::rendering
    UI("UI Modules (src/ts/ui/)"):::ui
    ST("Styles (src/styles/)"):::ui
    LO("Locales (src/locales/)"):::ui
    AM("Asset Management (src/ts/assets/)"):::assets
    SM("Save Management (src/ts/saveFile/)"):::assets
    TAURI("Tauri-based Backend/Container (src-tauri/)"):::tauri

    %% CI/CD influences both Web Frontend and Tauri Backend
    CI --> FE
    CI --> TAURI

    %% Research informs the simulation core
    RES --> GE

    %% Web Application Frontend contains core modules
    FE --> GE
    FE --> R1
    FE --> R2
    FE --> R3
    FE --> UI
    FE --> AM
    FE --> TAURI

    %% Internal interactions within Frontend modules
    GE --> R1
    GE --> R2
    GE --> UI
    GE --> AM

    %% UI modules breakdown
    UI --> ST
    UI --> LO

    %% Asset management chain
    AM --> SM

    %% Styling
    classDef ci fill:#d1c4e9,stroke:#4a148c,stroke-width:2px
    classDef research fill:#ffc1e3,stroke:#ad1457,stroke-width:2px
    classDef frontend fill:#bbdefb,stroke:#0d47a1,stroke-width:2px
    classDef simulation fill:#c8e6c9,stroke:#1b5e20,stroke-width:2px
    classDef rendering fill:#ffe0b2,stroke:#e65100,stroke-width:2px
    classDef ui fill:#fff9c4,stroke:#f57f17,stroke-width:2px
    classDef assets fill:#e0e0e0,stroke:#424242,stroke-width:2px
    classDef tauri fill:#ffccbc,stroke:#bf360c,stroke-width:2px

    %% Click events mapping
    click FE "https://github.com/barthpaleologue/cosmosjourneyer/tree/main/src/"
    click TAURI "https://github.com/barthpaleologue/cosmosjourneyer/tree/main/src-tauri/"
    click GE "https://github.com/barthpaleologue/cosmosjourneyer/tree/main/src/ts/"
    click R1 "https://github.com/barthpaleologue/cosmosjourneyer/tree/main/src/asset/"
    click R2 "https://github.com/barthpaleologue/cosmosjourneyer/tree/main/src/shaders/"
    click R3 "https://github.com/barthpaleologue/cosmosjourneyer/tree/main/src/html/"
    click UI "https://github.com/barthpaleologue/cosmosjourneyer/tree/main/src/ts/ui/"
    click ST "https://github.com/barthpaleologue/cosmosjourneyer/tree/main/src/styles/"
    click LO "https://github.com/barthpaleologue/cosmosjourneyer/tree/main/src/locales/"
    click AM "https://github.com/barthpaleologue/cosmosjourneyer/tree/main/src/ts/assets/"
    click SM "https://github.com/barthpaleologue/cosmosjourneyer/tree/main/src/ts/saveFile/"
    click RES "https://github.com/barthpaleologue/cosmosjourneyer/tree/main/research/"
    click CI "https://github.com/barthpaleologue/cosmosjourneyer/tree/main/.github/"
```
