# 8ored/solar-system-simulator architecture

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

- Interactive diagram: https://gitdiagram.com/8ored/solar-system-simulator
- Repository: https://github.com/8ored/solar-system-simulator

## Overview

This is a C++ OpenGL solar-system visualization. The main workflow is keyboard and mouse input, per-frame camera and orbit simulation, then rendering the Sun, planets, Moon, and scene overlays. The graph also preserves documented features such as scale modes, proximity behavior, Saturn’s ring, and texture fallbacks. Several implementations were not sampled in full, so their relationships are included only where the excerpts, source index, or README support them.

Main entry points: [`render.cpp`](https://github.com/8ored/solar-system-simulator/blob/main/render.cpp) (Scene Rendering), [`input.cpp`](https://github.com/8ored/solar-system-simulator/blob/main/input.cpp) (Input Callbacks), [`simulation.cpp`](https://github.com/8ored/solar-system-simulator/blob/main/simulation.cpp) (Frame Simulation), [`main.cpp`](https://github.com/8ored/solar-system-simulator/blob/main/main.cpp) (Window Setup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application"]
  node_main["Window Setup<br/>[main.cpp]"]
  node_config["Scale and Constants<br/>[config.h]"]
  node_state["Shared State<br/>[state.cpp]"]
end

subgraph group_controls["Camera and Controls"]
  node_input["Input Callbacks<br/>[input.cpp]"]
end

subgraph group_dynamics["Solar System Dynamics"]
  node_simulation["Frame Simulation<br/>[simulation.cpp]"]
  node_orbit["Orbit Positions<br/>[orbit.cpp]"]
end

subgraph group_graphics["Scene Graphics"]
  node_render["Scene Rendering<br/>[render.cpp]"]
  node_sphere["Sphere Mesh<br/>[sphere.cpp]"]
  node_texture["Texture Loading<br/>[texture.cpp]"]
  node_image["Image Decoder<br/>[stb_image.h]"]
end

node_user(("Viewer"))
node_scene["Solar System View"]

node_user -->|"controls"| node_input
node_main -->|"registers callbacks"| node_input
node_main -->|"starts timer"| node_simulation
node_main -->|"registers display"| node_render
node_main -->|"loads textures"| node_texture
node_input -->|"updates"| node_state
node_input -->|"calls physics"| node_simulation
node_input -->|"gets positions"| node_orbit
node_simulation -->|"updates"| node_state
node_simulation -->|"gets positions"| node_orbit
node_render -->|"reads"| node_state
node_render -->|"gets positions"| node_orbit
node_render -->|"draws spheres"| node_sphere
node_texture -->|"decodes images"| node_image
node_render -->|"draws"| node_scene
node_render -->|"uses constants"| node_config
node_simulation -->|"uses constants"| node_config
node_input -->|"uses constants"| node_config

click node_main "https://github.com/8ored/solar-system-simulator/blob/main/main.cpp"
click node_config "https://github.com/8ored/solar-system-simulator/blob/main/config.h"
click node_state "https://github.com/8ored/solar-system-simulator/blob/main/state.cpp"
click node_input "https://github.com/8ored/solar-system-simulator/blob/main/input.cpp"
click node_simulation "https://github.com/8ored/solar-system-simulator/blob/main/simulation.cpp"
click node_orbit "https://github.com/8ored/solar-system-simulator/blob/main/orbit.cpp"
click node_render "https://github.com/8ored/solar-system-simulator/blob/main/render.cpp"
click node_sphere "https://github.com/8ored/solar-system-simulator/blob/main/sphere.cpp"
click node_texture "https://github.com/8ored/solar-system-simulator/blob/main/texture.cpp"
click node_image "https://github.com/8ored/solar-system-simulator/blob/main/stb_image.h"

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_main,node_config,node_state,node_user,node_scene toneBlue
class node_input toneAmber
class node_simulation,node_orbit toneMint
class node_render,node_sphere,node_texture,node_image toneRose
```

## Components

### Application

- [Window Setup](https://github.com/8ored/solar-system-simulator/blob/main/main.cpp): `main.cpp`
- [Scale and Constants](https://github.com/8ored/solar-system-simulator/blob/main/config.h): `config.h`
- [Shared State](https://github.com/8ored/solar-system-simulator/blob/main/state.cpp): `state.cpp`

### Camera and Controls

- [Input Callbacks](https://github.com/8ored/solar-system-simulator/blob/main/input.cpp): `input.cpp`

### Solar System Dynamics

- [Frame Simulation](https://github.com/8ored/solar-system-simulator/blob/main/simulation.cpp): `simulation.cpp`
- [Orbit Positions](https://github.com/8ored/solar-system-simulator/blob/main/orbit.cpp): `orbit.cpp`

### Scene Graphics

- [Scene Rendering](https://github.com/8ored/solar-system-simulator/blob/main/render.cpp): `render.cpp`
- [Sphere Mesh](https://github.com/8ored/solar-system-simulator/blob/main/sphere.cpp): `sphere.cpp`
- [Texture Loading](https://github.com/8ored/solar-system-simulator/blob/main/texture.cpp): `texture.cpp`
- [Image Decoder](https://github.com/8ored/solar-system-simulator/blob/main/stb_image.h): `stb_image.h`

### Other components

- **Viewer**
- **Solar System View**

## Connections

- Viewer → Input Callbacks: controls (evidence: `README.md`)
- Window Setup → Input Callbacks: registers callbacks (evidence: `main.cpp`)
- Window Setup → Frame Simulation: starts timer (evidence: `main.cpp`)
- Window Setup → Scene Rendering: registers display (evidence: `main.cpp`)
- Window Setup → Texture Loading: loads textures (evidence: `main.cpp`)
- Input Callbacks → Shared State: updates (evidence: `input.cpp`)
- Input Callbacks → Frame Simulation: calls physics (evidence: `input.cpp`)
- Input Callbacks → Orbit Positions: gets positions (evidence: `input.cpp`)
- Frame Simulation → Shared State: updates (evidence: `simulation.cpp`)
- Frame Simulation → Orbit Positions: gets positions (evidence: `simulation.cpp`)
- Scene Rendering → Shared State: reads (evidence: `render.cpp`)
- Scene Rendering → Orbit Positions: gets positions (evidence: `render.cpp`)
- Scene Rendering → Sphere Mesh: draws spheres (evidence: `render.cpp`)
- Texture Loading → Image Decoder: decodes images (evidence: `texture.cpp`)
- Scene Rendering → Solar System View: draws (evidence: `render.cpp`)
- Scene Rendering → Scale and Constants: uses constants (evidence: `render.cpp`)
- Frame Simulation → Scale and Constants: uses constants (evidence: `simulation.cpp`)
- Input Callbacks → Scale and Constants: uses constants (evidence: `input.cpp`)
