# eepyberry/lagrange architecture

> Architecture diagram of the GitHub repository eepyberry/lagrange, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/eepyberry/lagrange
- Repository: https://github.com/eepyberry/lagrange

## Overview

#### Purpose and runtime
Lagrange is a client-side procedural planet builder. Vue 3 provides the application UI; Three.js renders procedural planets through WebGL2 or optionally WebGPU. Vite builds and serves the SPA. Static skyboxes, backgrounds, and extras are shipped from `public/`.

Key entry points: `index.html`, `src/main.ts`, `src/App.vue`, `src/router.config.ts`.

#### Application shell and navigation
The root app initializes global UI, routing, localization, dialogs, navigation, footer, and toast presentation. Routing separates the creation/editor workflow from the saved-planet Codex landing view and a not-found fallback.

Paths: `src/App.vue`, `src/router.config.ts`, `src/views/EditorView.vue`, `src/views/CodexView.vue`, `src/components/global/AppNavigation.vue`.

#### Editor orchestration and state
The editor is the primary interactive boundary. Its service and centralized state coordinate initialization, current planet data, render configuration, scene lifecycle, dirty/save behavior, and UI-to-renderer updates. The editor exposes categorized controls for basic identity, surface, biomes, clouds, atmosphere, rings, lighting, rendering, and post-processing.

Paths: `src/core/services/editor.service.ts`, `src/core/state/editor.state.ts`, `src/components/editor/controls/ControlsContainer.vue`, `src/components/editor/controls/EditorSidebarControls.vue`.

#### Planet and render-domain models
Typed model objects represent editable planet parameters and rendering-pipeline parameters. Converter modules translate persisted/imported data into runtime model shape. Observers react to parameter changes and propagate them into generated scene/material state, separating UI data representation from GPU resources.

Paths: `src/core/models/planet/planet-data.model.ts`, `src/core/models/renderpipeline/render-pipeline-data.model.ts`, `src/core/models/converters/model-converter.ts`, `src/core/observers/planet-data.observer.ts`.

#### Rendering capability, scene, and pipeline
Renderer selection is gated by explicit WebGL/WebGPU capability checks. Scene, preview, texture, and baking helpers establish Three.js objects and render targets; the render-pipeline abstraction controls base rendering and post-processing. This is the browser/GPU boundary and requires WebGL2, with WebGPU available when supported.

Paths: `src/core/capabilities/WebGL.ts`, `src/core/capabilities/WebGPU.ts`, `src/core/helpers/scene.helper.ts`, `src/core/tsl/rendering/render-pipeline.ts`.

#### Procedural GPU materials
Three.js TSL materials implement the planet layers: procedural surface/noise and biomes, clouds, atmosphere scattering, rings, and lens flare. Parameter changes from the editor/models drive uniforms or material graph inputs, then the active renderer produces the viewport and previews.

Paths: `src/core/tsl/materials/planet.tslmat.ts`, `src/core/tsl/materials/atmosphere.tslmat.ts`, `src/core/tsl/materials/clouds.tslmat.ts`, `src/core/tsl/materials/ring.tslmat.ts`.

#### Persistence, import/export, and Codex
Dexie provides browser-local persistent storage, making saved planets available to the Codex. Import/export helpers form the file boundary for portable planet data. The Codex lists saved worlds, produces previews, shows metadata/graphs, and supports deletion.

Paths: `src/core/services/dexie.service.ts`, `src/core/helpers/import.helper.ts`, `src/core/helpers/export.helper.ts`, `src/components/codex/elements/PlanetCardElement.vue`.

#### Deployment and external assets
The app is a static Vite build, suitable for browser hosting; `Dockerfile` supports containerized delivery. CI and release automation are GitHub Actions. No backend service is indicated. External runtime dependencies are the browser WebGL2/WebGPU APIs and Three.js; bundled assets include skyboxes under `public/skyboxes/`.

Paths: `vite.config.ts`, `Dockerfile`, `.github/workflows/main.yml`, `public/skyboxes/`.

Main entry points: [`src/core/services/editor.service.ts`](https://github.com/eepyberry/lagrange/blob/main/src/core/services/editor.service.ts) (Editor service), [`src/core/tsl/rendering/render-pipeline.ts`](https://github.com/eepyberry/lagrange/blob/main/src/core/tsl/rendering/render-pipeline.ts) (Render pipeline), [`src/core/observers/planet-data.observer.ts`](https://github.com/eepyberry/lagrange/blob/main/src/core/observers/planet-data.observer.ts) (Planet observer), [`src/core/state/editor.state.ts`](https://github.com/eepyberry/lagrange/blob/main/src/core/state/editor.state.ts) (Editor state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Vue application"]
  node_vite{{"Vite SPA build<br/>build tool<br/>[vite.config.ts]"}}
  node_entry["Application entry<br/>Vue bootstrap<br/>[main.ts]"]
  node_app_shell["Root application shell<br/>Vue root<br/>[App.vue]"]
  node_router["Router<br/>navigation config<br/>[router.config.ts]"]
  node_navigation["App navigation<br/>Vue component<br/>[AppNavigation.vue]"]
end

subgraph group_editor["Editor domain"]
  node_editor_view["Editor view<br/>Vue view<br/>[EditorView.vue]"]
  node_editor_service["Editor service<br/>orchestration service<br/>[editor.service.ts]"]
  node_editor_state["Editor state<br/>centralized state<br/>[editor.state.ts]"]
  node_controls["Editor controls<br/>Vue controls"]
  node_planet_model["Planet data model<br/>typed domain model"]
  node_render_model["Render pipeline model<br/>typed domain model"]
  node_model_converter["Model converter<br/>data converter<br/>[model-converter.ts]"]
end

subgraph group_rendering["GPU rendering"]
  node_planet_observer["Planet observer<br/>parameter observer"]
  node_capabilities["WebGL/WebGPU checks<br/>browser capability gate<br/>[WebGL.ts]"]
  node_render_pipeline["Render pipeline<br/>Three.js pipeline<br/>[render-pipeline.ts]"]
  node_planet_material["Planet material<br/>TSL GPU material<br/>[planet.tslmat.ts]"]
  node_atmosphere_material["Atmosphere material<br/>TSL GPU material"]
  node_clouds_material["Clouds material<br/>TSL GPU material<br/>[clouds.tslmat.ts]"]
  node_ring_material["Ring material<br/>TSL GPU material<br/>[ring.tslmat.ts]"]
  node_browser_gpu{{"Browser GPU APIs<br/>external runtime"}}
end

subgraph group_data["Persistence &amp; assets"]
  node_codex_view["Codex view<br/>Vue view<br/>[CodexView.vue]"]
  node_planet_card["Planet card<br/>Vue component"]
  node_planet_store[("Local planet store<br/>Dexie persistence<br/>[dexie.service.ts]")]
  node_import_export["Import/export<br/>file boundary<br/>[import.helper.ts]"]
  node_skyboxes["Skybox assets<br/>static assets"]
end

node_vite -->|"builds"| node_entry
node_entry -->|"mounts"| node_app_shell
node_app_shell -->|"uses"| node_router
node_app_shell -->|"hosts"| node_navigation
node_router -->|"routes to"| node_editor_view
node_router -->|"routes to"| node_codex_view
node_editor_view -->|"hosts"| node_controls
node_editor_view -->|"drives"| node_editor_service
node_controls -->|"edits"| node_editor_state
node_editor_service -->|"coordinates"| node_editor_state
node_editor_state -->|"holds"| node_planet_model
node_editor_state -->|"holds"| node_render_model
node_editor_state -->|"notifies"| node_planet_observer
node_planet_observer -->|"updates"| node_planet_material
node_planet_observer -->|"updates"| node_atmosphere_material
node_planet_observer -->|"updates"| node_clouds_material
node_planet_observer -->|"updates"| node_ring_material
node_editor_service -->|"selects renderer via"| node_capabilities
node_capabilities -->|"detects"| node_browser_gpu
node_editor_service -->|"manages"| node_render_pipeline
node_render_pipeline -->|"renders"| node_planet_material
node_render_pipeline -->|"renders"| node_atmosphere_material
node_render_pipeline -->|"renders"| node_clouds_material
node_render_pipeline -->|"renders"| node_ring_material
node_render_pipeline -->|"executes on"| node_browser_gpu
node_editor_service -->|"saves to"| node_planet_store
node_import_export -->|"converts through"| node_model_converter
node_model_converter -->|"creates"| node_planet_model
node_codex_view -->|"lists with"| node_planet_card
node_planet_card -->|"loads and deletes"| node_planet_store
node_editor_service -->|"uses"| node_skyboxes

click node_vite "https://github.com/eepyberry/lagrange/blob/main/vite.config.ts"
click node_entry "https://github.com/eepyberry/lagrange/blob/main/src/main.ts"
click node_app_shell "https://github.com/eepyberry/lagrange/blob/main/src/App.vue"
click node_router "https://github.com/eepyberry/lagrange/blob/main/src/router.config.ts"
click node_navigation "https://github.com/eepyberry/lagrange/blob/main/src/components/global/AppNavigation.vue"
click node_editor_view "https://github.com/eepyberry/lagrange/blob/main/src/views/EditorView.vue"
click node_editor_service "https://github.com/eepyberry/lagrange/blob/main/src/core/services/editor.service.ts"
click node_editor_state "https://github.com/eepyberry/lagrange/blob/main/src/core/state/editor.state.ts"
click node_controls "https://github.com/eepyberry/lagrange/blob/main/src/components/editor/controls/ControlsContainer.vue"
click node_planet_model "https://github.com/eepyberry/lagrange/blob/main/src/core/models/planet/planet-data.model.ts"
click node_render_model "https://github.com/eepyberry/lagrange/blob/main/src/core/models/renderpipeline/render-pipeline-data.model.ts"
click node_model_converter "https://github.com/eepyberry/lagrange/blob/main/src/core/models/converters/model-converter.ts"
click node_planet_observer "https://github.com/eepyberry/lagrange/blob/main/src/core/observers/planet-data.observer.ts"
click node_capabilities "https://github.com/eepyberry/lagrange/blob/main/src/core/capabilities/WebGL.ts"
click node_render_pipeline "https://github.com/eepyberry/lagrange/blob/main/src/core/tsl/rendering/render-pipeline.ts"
click node_planet_material "https://github.com/eepyberry/lagrange/blob/main/src/core/tsl/materials/planet.tslmat.ts"
click node_atmosphere_material "https://github.com/eepyberry/lagrange/blob/main/src/core/tsl/materials/atmosphere.tslmat.ts"
click node_clouds_material "https://github.com/eepyberry/lagrange/blob/main/src/core/tsl/materials/clouds.tslmat.ts"
click node_ring_material "https://github.com/eepyberry/lagrange/blob/main/src/core/tsl/materials/ring.tslmat.ts"
click node_codex_view "https://github.com/eepyberry/lagrange/blob/main/src/views/CodexView.vue"
click node_planet_card "https://github.com/eepyberry/lagrange/blob/main/src/components/codex/elements/PlanetCardElement.vue"
click node_planet_store "https://github.com/eepyberry/lagrange/blob/main/src/core/services/dexie.service.ts"
click node_import_export "https://github.com/eepyberry/lagrange/blob/main/src/core/helpers/import.helper.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_vite,node_entry,node_app_shell,node_router,node_navigation toneBlue
class node_editor_view,node_editor_service,node_editor_state,node_controls,node_planet_model,node_render_model,node_model_converter toneAmber
class node_planet_observer,node_capabilities,node_render_pipeline,node_planet_material,node_atmosphere_material,node_clouds_material,node_ring_material,node_browser_gpu toneMint
class node_codex_view,node_planet_card,node_planet_store,node_import_export,node_skyboxes toneRose
```

## Components

### Vue application

- [Vite SPA build](https://github.com/eepyberry/lagrange/blob/main/vite.config.ts): build tool · Builds and serves the client-side application. · `vite.config.ts`
- [Application entry](https://github.com/eepyberry/lagrange/blob/main/src/main.ts): Vue bootstrap · `src/main.ts`
- [Root application shell](https://github.com/eepyberry/lagrange/blob/main/src/App.vue): Vue root · Hosts global UI, routing, dialogs, navigation, footer, and toasts. · `src/App.vue`
- [Router](https://github.com/eepyberry/lagrange/blob/main/src/router.config.ts): navigation config · Selects editor, Codex, and not-found views. · `src/router.config.ts`
- [App navigation](https://github.com/eepyberry/lagrange/blob/main/src/components/global/AppNavigation.vue): Vue component · `src/components/global/AppNavigation.vue`

### Editor domain

- [Editor view](https://github.com/eepyberry/lagrange/blob/main/src/views/EditorView.vue): Vue view · Primary planet creation and editing workflow. · `src/views/EditorView.vue`
- [Editor service](https://github.com/eepyberry/lagrange/blob/main/src/core/services/editor.service.ts): orchestration service · Coordinates initialization, scene lifecycle, saves, and renderer updates. · `src/core/services/editor.service.ts`
- [Editor state](https://github.com/eepyberry/lagrange/blob/main/src/core/state/editor.state.ts): centralized state · Holds current planet data, render configuration, and dirty state. · `src/core/state/editor.state.ts`
- [Editor controls](https://github.com/eepyberry/lagrange/blob/main/src/components/editor/controls/ControlsContainer.vue): Vue controls · Categorized controls drive editable planet and render parameters. · `src/components/editor/controls/ControlsContainer.vue`
- [Planet data model](https://github.com/eepyberry/lagrange/blob/main/src/core/models/planet/planet-data.model.ts): typed domain model · `src/core/models/planet/planet-data.model.ts`
- [Render pipeline model](https://github.com/eepyberry/lagrange/blob/main/src/core/models/renderpipeline/render-pipeline-data.model.ts): typed domain model · `src/core/models/renderpipeline/render-pipeline-data.model.ts`
- [Model converter](https://github.com/eepyberry/lagrange/blob/main/src/core/models/converters/model-converter.ts): data converter · Transforms persisted or imported data into runtime model shape. · `src/core/models/converters/model-converter.ts`

### GPU rendering

- [Planet observer](https://github.com/eepyberry/lagrange/blob/main/src/core/observers/planet-data.observer.ts): parameter observer · Propagates parameter changes into generated scene and material state. · `src/core/observers/planet-data.observer.ts`
- [WebGL/WebGPU checks](https://github.com/eepyberry/lagrange/blob/main/src/core/capabilities/WebGL.ts): browser capability gate · Requires WebGL2 and enables WebGPU when supported. · `src/core/capabilities/WebGL.ts`
- [Render pipeline](https://github.com/eepyberry/lagrange/blob/main/src/core/tsl/rendering/render-pipeline.ts): Three.js pipeline · Controls base rendering and post-processing. · `src/core/tsl/rendering/render-pipeline.ts`
- [Planet material](https://github.com/eepyberry/lagrange/blob/main/src/core/tsl/materials/planet.tslmat.ts): TSL GPU material · Generates procedural surface, noise, and biome layers. · `src/core/tsl/materials/planet.tslmat.ts`
- [Atmosphere material](https://github.com/eepyberry/lagrange/blob/main/src/core/tsl/materials/atmosphere.tslmat.ts): TSL GPU material · Renders atmospheric scattering. · `src/core/tsl/materials/atmosphere.tslmat.ts`
- [Clouds material](https://github.com/eepyberry/lagrange/blob/main/src/core/tsl/materials/clouds.tslmat.ts): TSL GPU material · `src/core/tsl/materials/clouds.tslmat.ts`
- [Ring material](https://github.com/eepyberry/lagrange/blob/main/src/core/tsl/materials/ring.tslmat.ts): TSL GPU material · `src/core/tsl/materials/ring.tslmat.ts`
- **Browser GPU APIs**: external runtime · WebGL2 and optional WebGPU execution environment.

### Persistence & assets

- [Codex view](https://github.com/eepyberry/lagrange/blob/main/src/views/CodexView.vue): Vue view · Landing view for saved planets. · `src/views/CodexView.vue`
- [Planet card](https://github.com/eepyberry/lagrange/blob/main/src/components/codex/elements/PlanetCardElement.vue): Vue component · Lists saved worlds with previews, metadata, and deletion. · `src/components/codex/elements/PlanetCardElement.vue`
- [Local planet store](https://github.com/eepyberry/lagrange/blob/main/src/core/services/dexie.service.ts): Dexie persistence · Browser-local storage for saved planets. · `src/core/services/dexie.service.ts`
- [Import/export](https://github.com/eepyberry/lagrange/blob/main/src/core/helpers/import.helper.ts): file boundary · Reads and writes portable planet data. · `src/core/helpers/import.helper.ts`
- **Skybox assets**: static assets · Bundled backgrounds and skyboxes.

## Connections

- Vite SPA build → Application entry: builds
- Application entry → Root application shell: mounts
- Root application shell → Router: uses
- Root application shell → App navigation: hosts
- Router → Editor view: routes to
- Router → Codex view: routes to
- Editor view → Editor controls: hosts
- Editor view → Editor service: drives
- Editor controls → Editor state: edits
- Editor service → Editor state: coordinates
- Editor state → Planet data model: holds
- Editor state → Render pipeline model: holds
- Editor state → Planet observer: notifies
- Planet observer → Planet material: updates
- Planet observer → Atmosphere material: updates
- Planet observer → Clouds material: updates
- Planet observer → Ring material: updates
- Editor service → WebGL/WebGPU checks: selects renderer via
- WebGL/WebGPU checks → Browser GPU APIs: detects
- Editor service → Render pipeline: manages
- Render pipeline → Planet material: renders
- Render pipeline → Atmosphere material: renders
- Render pipeline → Clouds material: renders
- Render pipeline → Ring material: renders
- Render pipeline → Browser GPU APIs: executes on
- Editor service → Local planet store: saves to
- Import/export → Model converter: converts through
- Model converter → Planet data model: creates
- Codex view → Planet card: lists with
- Planet card → Local planet store: loads and deletes
- Editor service → Skybox assets: uses
