# stellarium/stellarium-web-engine architecture

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

- Interactive diagram: https://gitdiagram.com/stellarium/stellarium-web-engine
- Repository: https://github.com/stellarium/stellarium-web-engine

## Overview

##### Core Engine Layer
- Render Engine (WebGL)
- Core Components
- Observer System
- Navigation System
- Projection System
- Asset Management
- Algorithms Module
- Astronomical Calculations
- Coordinate Systems
- Ephemeris Computations

##### Module System Layer
- Atmosphere
- Stars
- Planets
- Constellations
- Landscapes
- Satellites
- DSO (Deep Space Objects)
- Other astronomical objects

##### Data Management Layer
- Asset Loading System
- Cache Management
- HiPS Survey Integration
- Gaia Stars Database Interface

##### Frontend Integration Layer
- JavaScript API
- WebGL Context
- Event Handling
- User Interface Components

##### Use a Layered Architecture Representation
- [Web Applications]
- ↑↓
- [Frontend Integration Layer]
- ↑↓
- [Core Engine Layer]
- ↑↓
- [Module System Layer]
- ↑↓
- [Data Management Layer]

##### Component Details
- File references from the src/ directory
- Major external dependencies (WebGL, Emscripten)
- Data flow between components

##### Technical Elements to Highlight
- WASM compilation process
- Shader management
- Asset pipeline
- Performance optimization systems

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Legend
        A1[Core Component]:::core
        A2[Module Component]:::module
        A3[Data Component]:::data
        A4[Frontend Component]:::frontend
        A5[External System]:::external
    end

    subgraph "Frontend Integration Layer"
        JS["JavaScript API"]:::frontend
        WGL["WebGL Context"]:::frontend
        EH["Event Handler"]:::frontend
        UI["UI Components"]:::frontend
    end

    subgraph "Core Engine Layer"
        RE["Render Engine"]:::core
        OBS["Observer System"]:::core
        NAV["Navigation System"]:::core
        PROJ["Projection System"]:::core
        AM["Asset Management"]:::core
        SHD["Shader System"]:::core
    end

    subgraph "Module System Layer"
        ATM["Atmosphere"]:::module
        STR["Stars"]:::module
        PLN["Planets"]:::module
        CON["Constellations"]:::module
        LND["Landscapes"]:::module
        SAT["Satellites"]:::module
        DSO["Deep Space Objects"]:::module
    end

    subgraph "Data Management Layer"
        AL["Asset Loading"]:::data
        CM["Cache Management"]:::data
        HPS["HiPS Survey Integration"]:::data
        EPH["Ephemeris Computations"]:::data
        ALG["Astronomical Algorithms"]:::data
    end

    subgraph "External Systems"
        WEBGL["WebGL"]:::external
        WASM["WebAssembly"]:::external
    end

    %% Connections
    JS --> RE
    WGL --> RE
    EH --> RE
    UI --> JS

    RE --> OBS
    RE --> NAV
    RE --> PROJ
    RE --> AM
    RE --> SHD

    AM --> AL
    AL --> CM
    HPS --> CM
    EPH --> ALG

    RE --> ATM
    RE --> STR
    RE --> PLN
    RE --> CON
    RE --> LND
    RE --> SAT
    RE --> DSO

    RE --> WEBGL
    RE --> WASM

    %% Styles
    classDef core fill:#a8d1f0,stroke:#333,stroke-width:2px
    classDef module fill:#90EE90,stroke:#333,stroke-width:2px
    classDef data fill:#FFB347,stroke:#333,stroke-width:2px
    classDef frontend fill:#DDA0DD,stroke:#333,stroke-width:2px
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:2px

    %% Click Events
    click RE "https://github.com/Stellarium/stellarium-web-engine/blob/master/src/render_gl.c"
    click OBS "https://github.com/Stellarium/stellarium-web-engine/blob/master/src/observer.c"
    click NAV "https://github.com/Stellarium/stellarium-web-engine/blob/master/src/navigation.c"
    click PROJ "https://github.com/Stellarium/stellarium-web-engine/blob/master/src/projection.c"
    click AM "https://github.com/Stellarium/stellarium-web-engine/blob/master/src/assets.c"
    click ATM "https://github.com/Stellarium/stellarium-web-engine/blob/master/src/modules/atmosphere.c"
    click STR "https://github.com/Stellarium/stellarium-web-engine/blob/master/src/modules/stars.c"
    click PLN "https://github.com/Stellarium/stellarium-web-engine/blob/master/src/modules/planets.c"
    click CON "https://github.com/Stellarium/stellarium-web-engine/blob/master/src/modules/constellations.c"
    click LND "https://github.com/Stellarium/stellarium-web-engine/blob/master/src/modules/landscape.c"
    click SAT "https://github.com/Stellarium/stellarium-web-engine/blob/master/src/modules/satellites.c"
    click DSO "https://github.com/Stellarium/stellarium-web-engine/blob/master/src/modules/dso.c"
    click AL "https://github.com/Stellarium/stellarium-web-engine/blob/master/src/assets.c"
    click CM "https://github.com/Stellarium/stellarium-web-engine/blob/master/src/utils/cache.c"
    click HPS "https://github.com/Stellarium/stellarium-web-engine/blob/master/src/hips.c"
    click JS "https://github.com/Stellarium/stellarium-web-engine/tree/master/src/js"
    click WGL "https://github.com/Stellarium/stellarium-web-engine/blob/master/src/utils/gl.c"
    click EH "https://github.com/Stellarium/stellarium-web-engine/blob/master/src/events.c"
    click UI "https://github.com/Stellarium/stellarium-web-engine/tree/master/apps/web-frontend/src/components"
    click SHD "https://github.com/Stellarium/stellarium-web-engine/tree/master/data/shaders"
    click EPH "https://github.com/Stellarium/stellarium-web-engine/blob/master/src/eph-file.c"
    click ALG "https://github.com/Stellarium/stellarium-web-engine/tree/master/src/algos"
```
