# resaki1/stellar-nomad architecture

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

- Interactive diagram: https://gitdiagram.com/resaki1/stellar-nomad
- Repository: https://github.com/resaki1/stellar-nomad

## Overview

Stellar Nomad is a browser-based space exploration and resource-gathering game. The documented player journey starts in Earth orbit, proceeds through ship piloting and asteroid mining, and uses gathered resources for crafting and upgrades before exploration of other planets. Its runtime combines a 3D scene, celestial rendering, streamed asteroid simulation, ship controls, HUD, and research/progression state. README statements establish the broad gameplay links; source-index references and excerpts support the internal asteroid, research, and rendering links. Some gameplay component wiring is not shown, so those links are documented rather than source-verified.

Main entry points: [`src/components/Game/Game.tsx`](https://github.com/resaki1/stellar-nomad/blob/main/src/components/Game/Game.tsx) (Game session), [`src/components/HUD/ResearchPanel/ResearchPanel.tsx`](https://github.com/resaki1/stellar-nomad/blob/main/src/components/HUD/ResearchPanel/ResearchPanel.tsx) (Research panel), [`src/components/celestial/CelestialBody.tsx`](https://github.com/resaki1/stellar-nomad/blob/main/src/components/celestial/CelestialBody.tsx) (Celestial bodies), [`src/sim/asteroids/runtime.ts`](https://github.com/resaki1/stellar-nomad/blob/main/src/sim/asteroids/runtime.ts) (Asteroid runtime)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_play["Player gameplay"]
  node_game["Game session<br/>[Game.tsx]"]
  node_ship["Ship piloting<br/>[Spaceship.tsx]"]
  node_controls["Navigation controls<br/>[Navigation.tsx]"]
  node_mining["Asteroid mining<br/>[MiningSystem.tsx]"]
end

subgraph group_world["World rendering"]
  node_scene["3D scene<br/>[Scene.tsx]"]
  node_celestials["Celestial bodies<br/>[CelestialBody.tsx]"]
  node_clouds["Cloud volumes<br/>[noiseVolumes.ts]"]
  node_photometry["Light model<br/>[photometry.ts]"]
end

subgraph group_sim["Simulation"]
  node_asteroidfield["Asteroid fields<br/>[AsteroidField.tsx]"]
  node_asteroidruntime["Asteroid runtime<br/>[runtime.ts]"]
  node_generation["Chunk generation<br/>[generation.ts]"]
  node_worker["Chunk worker"]
  node_persistence[("Asteroid persistence<br/>[persistence.ts]")]
end

subgraph group_progress["Interface and progression"]
  node_hud["Game HUD<br/>[HUD.tsx]"]
  node_researchui["Research panel<br/>[ResearchPanel.tsx]"]
  node_researchstate["Research state<br/>[research.ts]"]
  node_ticker["Research ticker<br/>[ResearchTicker.tsx]"]
  node_content["Items and research<br/>[content.ts]"]
  node_toast["Toast state<br/>[toast.ts]"]
end

node_player(("Player"))

node_player -->|"starts journey"| node_game
node_game -.->|"pilots ship"| node_ship
node_player -->|"steers with"| node_controls
node_ship -->|"mines asteroids"| node_mining
node_mining -->|"yields resources"| node_player
node_player -->|"explores planets"| node_celestials
node_game -.->|"presents world"| node_scene
node_scene -.->|"renders"| node_celestials
node_celestials -.->|"samples volumes"| node_clouds
node_celestials -->|"uses lighting"| node_photometry
node_game -.->|"shows fields"| node_asteroidfield
node_asteroidfield -.->|"streams chunks"| node_asteroidruntime
node_asteroidruntime -->|"reads and writes"| node_persistence
node_worker -->|"generates chunks"| node_generation
node_worker -.->|"returns chunks"| node_asteroidruntime
node_game -.->|"displays status"| node_hud
node_player -->|"chooses upgrades"| node_researchui
node_researchui -->|"reads and updates"| node_researchstate
node_researchui -->|"loads definitions"| node_content
node_researchui -->|"updates notices"| node_toast
node_ticker -->|"advances research"| node_researchstate
node_ticker -->|"loads definitions"| node_content
node_researchstate -->|"checks prerequisites"| node_content

click node_game "https://github.com/resaki1/stellar-nomad/blob/main/src/components/Game/Game.tsx"
click node_ship "https://github.com/resaki1/stellar-nomad/blob/main/src/components/Spaceship.tsx"
click node_controls "https://github.com/resaki1/stellar-nomad/blob/main/src/components/Navigation/Navigation.tsx"
click node_mining "https://github.com/resaki1/stellar-nomad/blob/main/src/components/Mining/MiningSystem.tsx"
click node_scene "https://github.com/resaki1/stellar-nomad/blob/main/src/components/Scene/Scene.tsx"
click node_celestials "https://github.com/resaki1/stellar-nomad/blob/main/src/components/celestial/CelestialBody.tsx"
click node_clouds "https://github.com/resaki1/stellar-nomad/blob/main/src/components/celestial/bodies/noiseVolumes.ts"
click node_photometry "https://github.com/resaki1/stellar-nomad/blob/main/src/components/space/photometry.ts"
click node_asteroidfield "https://github.com/resaki1/stellar-nomad/blob/main/src/components/Asteroids/AsteroidField.tsx"
click node_asteroidruntime "https://github.com/resaki1/stellar-nomad/blob/main/src/sim/asteroids/runtime.ts"
click node_generation "https://github.com/resaki1/stellar-nomad/blob/main/src/sim/asteroids/generation.ts"
click node_worker "https://github.com/resaki1/stellar-nomad/blob/main/src/workers/asteroidChunkWorker.ts"
click node_persistence "https://github.com/resaki1/stellar-nomad/blob/main/src/sim/asteroids/persistence.ts"
click node_hud "https://github.com/resaki1/stellar-nomad/blob/main/src/components/HUD/HUD.tsx"
click node_researchui "https://github.com/resaki1/stellar-nomad/blob/main/src/components/HUD/ResearchPanel/ResearchPanel.tsx"
click node_researchstate "https://github.com/resaki1/stellar-nomad/blob/main/src/store/research.ts"
click node_ticker "https://github.com/resaki1/stellar-nomad/blob/main/src/components/Research/ResearchTicker.tsx"
click node_content "https://github.com/resaki1/stellar-nomad/blob/main/src/data/content.ts"
click node_toast "https://github.com/resaki1/stellar-nomad/blob/main/src/store/toast.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_game,node_ship,node_controls,node_mining toneBlue
class node_scene,node_celestials,node_clouds,node_photometry toneAmber
class node_asteroidfield,node_asteroidruntime,node_generation,node_worker,node_persistence toneMint
class node_hud,node_researchui,node_researchstate,node_ticker,node_content,node_toast toneRose
class node_player toneIndigo
```

## Components

### Player gameplay

- [Game session](https://github.com/resaki1/stellar-nomad/blob/main/src/components/Game/Game.tsx): `src/components/Game/Game.tsx`
- [Ship piloting](https://github.com/resaki1/stellar-nomad/blob/main/src/components/Spaceship.tsx): `src/components/Spaceship.tsx`
- [Navigation controls](https://github.com/resaki1/stellar-nomad/blob/main/src/components/Navigation/Navigation.tsx): `src/components/Navigation/Navigation.tsx`
- [Asteroid mining](https://github.com/resaki1/stellar-nomad/blob/main/src/components/Mining/MiningSystem.tsx): `src/components/Mining/MiningSystem.tsx`

### World rendering

- [3D scene](https://github.com/resaki1/stellar-nomad/blob/main/src/components/Scene/Scene.tsx): `src/components/Scene/Scene.tsx`
- [Celestial bodies](https://github.com/resaki1/stellar-nomad/blob/main/src/components/celestial/CelestialBody.tsx): `src/components/celestial/CelestialBody.tsx`
- [Cloud volumes](https://github.com/resaki1/stellar-nomad/blob/main/src/components/celestial/bodies/noiseVolumes.ts): `src/components/celestial/bodies/noiseVolumes.ts`
- [Light model](https://github.com/resaki1/stellar-nomad/blob/main/src/components/space/photometry.ts): `src/components/space/photometry.ts`

### Simulation

- [Asteroid fields](https://github.com/resaki1/stellar-nomad/blob/main/src/components/Asteroids/AsteroidField.tsx): `src/components/Asteroids/AsteroidField.tsx`
- [Asteroid runtime](https://github.com/resaki1/stellar-nomad/blob/main/src/sim/asteroids/runtime.ts): `src/sim/asteroids/runtime.ts`
- [Chunk generation](https://github.com/resaki1/stellar-nomad/blob/main/src/sim/asteroids/generation.ts): `src/sim/asteroids/generation.ts`
- [Chunk worker](https://github.com/resaki1/stellar-nomad/blob/main/src/workers/asteroidChunkWorker.ts): `src/workers/asteroidChunkWorker.ts`
- [Asteroid persistence](https://github.com/resaki1/stellar-nomad/blob/main/src/sim/asteroids/persistence.ts): `src/sim/asteroids/persistence.ts`

### Interface and progression

- [Game HUD](https://github.com/resaki1/stellar-nomad/blob/main/src/components/HUD/HUD.tsx): `src/components/HUD/HUD.tsx`
- [Research panel](https://github.com/resaki1/stellar-nomad/blob/main/src/components/HUD/ResearchPanel/ResearchPanel.tsx): `src/components/HUD/ResearchPanel/ResearchPanel.tsx`
- [Research state](https://github.com/resaki1/stellar-nomad/blob/main/src/store/research.ts): `src/store/research.ts`
- [Research ticker](https://github.com/resaki1/stellar-nomad/blob/main/src/components/Research/ResearchTicker.tsx): `src/components/Research/ResearchTicker.tsx`
- [Items and research](https://github.com/resaki1/stellar-nomad/blob/main/src/data/content.ts): `src/data/content.ts`
- [Toast state](https://github.com/resaki1/stellar-nomad/blob/main/src/store/toast.ts): `src/store/toast.ts`

### Other components

- **Player**

## Connections

- Player → Game session: starts journey
- Game session → Ship piloting: pilots ship
- Player → Navigation controls: steers with
- Ship piloting → Asteroid mining: mines asteroids
- Asteroid mining → Player: yields resources
- Player → Celestial bodies: explores planets
- Game session → 3D scene: presents world
- 3D scene → Celestial bodies: renders
- Celestial bodies → Cloud volumes: samples volumes
- Celestial bodies → Light model: uses lighting
- Game session → Asteroid fields: shows fields
- Asteroid fields → Asteroid runtime: streams chunks
- Asteroid runtime → Asteroid persistence: reads and writes (evidence: `src/sim/asteroids/runtime.ts`)
- Chunk worker → Chunk generation: generates chunks (evidence: `src/workers/asteroidChunkWorker.ts`)
- Chunk worker → Asteroid runtime: returns chunks
- Game session → Game HUD: displays status
- Player → Research panel: chooses upgrades
- Research panel → Research state: reads and updates (evidence: `src/components/HUD/ResearchPanel/ResearchPanel.tsx`)
- Research panel → Items and research: loads definitions (evidence: `src/components/HUD/ResearchPanel/ResearchPanel.tsx`)
- Research panel → Toast state: updates notices (evidence: `src/components/HUD/ResearchPanel/ResearchPanel.tsx`)
- Research ticker → Research state: advances research (evidence: `src/components/Research/ResearchTicker.tsx`)
- Research ticker → Items and research: loads definitions (evidence: `src/components/Research/ResearchTicker.tsx`)
- Research state → Items and research: checks prerequisites (evidence: `src/store/research.ts`)
