# marct1me/gravitysimulation2-javaedition architecture

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

- Interactive diagram: https://gitdiagram.com/marct1me/gravitysimulation2-javaedition
- Repository: https://github.com/marct1me/gravitysimulation2-javaedition

## Overview

1. **Project shape**
   - This is a multi-module **LibGDX** game written in Java.
   - The main runtime is split into `core` (game logic) and `lwjgl3` (desktop launcher). There are also `server` and `shared` modules, but the visible architecture is primarily a single-player desktop simulation.

2. **Startup and platform boundary**
   - `lwjgl3/Lwjgl3Launcher` is the platform entry point.
   - It boots the LibGDX application and applies window-related startup behavior before handing control to the core game class.
   - `core/GravitySimulation2` is the central game bootstrapper: it loads configuration, initializes UI, and selects the first screen.

3. **Screen-based application flow**
   - The app is organized around LibGDX screens:
     - `MainMenuScreen`
     - `SceneLoadingScreen`
     - `SceneScreen`
   - These represent the major runtime states: menu, load transition, and active simulation.
   - `screen/DefaultBackground` and `screen/scene/SceneScreenBackground` provide visual backdrops under the screens.

4. **UI and menu subsystem**
   - `gameinterface` contains the in-game interface layer and menu objects.
   - It is split into concrete menus for:
     - main menu
     - load menu
     - pause menu
     - settings menu
   - Settings are organized as fields/categories:
     - game settings
     - graphic settings
     - window settings
   - This layer controls visibility/state of menu objects and is the main bridge between user input and game-state transitions.

5. **Configuration system**
   - `config` defines the runtime configuration model and its loading/management.
   - The repository ships with three config categories stored under `assets/config`:
     - `game.json`
     - `graphic.json`
     - `window.json`
   - `ConfigManager` is the central loader/manager, while `GameConfig`, `GraphicConfig`, and `WindowConfig` represent category-specific settings.
   - These configs affect both UI behavior and runtime rendering/window behavior.

6. **Simulation domain**
   - The core simulation model lives under `objects`.
   - `GameScene` is the container for the active world.
   - `objects/object` defines scene entities through `GameObject` plus type-specific implementations such as:
     - `StarObject`
     - `PlanetObject`
     - `SatelliteObject`
     - `EmptyObject`
   - `ObjectType` / `ObjectTypes` separate object behavior/metadata from the base object structure.

7. **Physics engine and threading boundary**
   - The physics subsystem is under `objects/physic`.
   - Key parts are:
     - `Simulation`
     - `SimulationSpace`
     - `Physic`
     - `PhysicBody`
     - `Vector2D`
   - The README indicates simulation calculations run in a **separate thread**, so the physics engine is a distinct runtime boundary from the render/UI thread.
   - This is a major architectural separation: UI/screens drive state, while the simulation thread advances object motion.

8. **Camera subsystem**
   - `objects/camera` contains `Camera` and `CameraController`.
   - The camera is part of the scene state and is persisted in save files.
   - Camera settings are tied into both gameplay and loading/saving, so camera state is not just a render concern; it is part of the serialized scene snapshot.

9. **Save/load pipeline**
   - Save handling is under `save`.
   - The save format is split into multiple files per scenario:
     - `save.json` as the header/metadata
     - `scene.json` for scene objects
     - `simulation.json` for simulation parameters
     - `camera.json` for camera state
   - `SceneParser` reconstructs a full scene from the save folder.
   - The load flow is staged: header first, then scene/simulation/camera data, then the scene is activated and the simulation starts.

10. **Content/data assets**
   - `assets/ui` contains bitmap font and skin assets used by the UI.
   - `assets/saves/*` contains predefined scenarios such as `centauri`, `duet`, `magic`, `simple`, `sol`, and `test`.
   - These are not just data files; they are runtime content that defines the initial simulation worlds the user can load.

11. **Main data flow**
   - User starts in the menu.
   - Configs are loaded and applied.
   - Selecting a save triggers parsing of the save folder into scene, simulation, objects, and camera.
   - The app switches to the scene screen.
   - The simulation thread advances physics while the screen layer renders objects and overlays.
   - Returning to the main menu clears the active scene and stops/tears down the simulation state.

12. **Additional modules and boundaries**
   - `server` contains a `ServerMain` entrypoint, but no clear integration with the core game flow is visible in this tree.
   - `shared` exists as a separate module, likely intended for code reuse or tests, but it is not shown as part of the main runtime path.
   - This makes the repository primarily a desktop game/simulation app, with extra module boundaries prepared for future expansion.

Main entry points: [`core/src/main/java/com/gravitysimulation2/gameinterface`](https://github.com/marct1me/gravitysimulation2-javaedition/tree/master/core/src/main/java/com/gravitysimulation2/gameinterface) (UI layer), [`core/src/main/java/com/gravitysimulation2/GravitySimulation2.java`](https://github.com/marct1me/gravitysimulation2-javaedition/blob/master/core/src/main/java/com/gravitysimulation2/GravitySimulation2.java) (Game bootstrap), [`core/src/main/java/com/gravitysimulation2/objects/GameScene.java`](https://github.com/marct1me/gravitysimulation2-javaedition/blob/master/core/src/main/java/com/gravitysimulation2/objects/GameScene.java) (Game scene), [`core/src/main/java/com/gravitysimulation2/screen/scene/SceneScreen.java`](https://github.com/marct1me/gravitysimulation2-javaedition/blob/master/core/src/main/java/com/gravitysimulation2/screen/scene/SceneScreen.java) (Scene screen)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_module_lwjgl3["lwjgl3"]
  node_lwjgl3_launcher["Launcher<br/>desktop entrypoint"]
  node_startup_helper["Startup helper<br/>platform bootstrap<br/>[StartupHelper.java]"]
end

subgraph group_module_core["core"]
  node_game_bootstrap["Game bootstrap<br/>core app"]
  node_main_menu_screen["Main menu<br/>screen"]
  node_loading_screen["Load screen"]
  node_scene_screen["Scene screen<br/>[SceneScreen.java]"]
  node_scene_background["Scene backdrop<br/>render background"]
  node_default_background["Default backdrop<br/>render background"]
  node_ui_layer["UI layer<br/>interface system"]
  node_settings_menu["Settings menu<br/>[SettingsMenu.java]"]
  node_main_menu_ui["Main menu UI<br/>[MainMenu.java]"]
  node_load_menu["Load menu<br/>[LoadMenu.java]"]
  node_pause_menu["Pause menu<br/>[PauseMenu.java]"]
  node_config_manager["Config manager<br/>config loader<br/>[ConfigManager.java]"]
  node_game_scene["Game scene<br/>scene model<br/>[GameScene.java]"]
  node_camera_system["Camera<br/>[Camera.java]"]
  node_object_model["Objects<br/>domain model"]
  node_physics_engine["Physics<br/>simulation thread"]
  node_save_parser["Save parser<br/>save/load pipeline<br/>[SceneParser.java]"]
end

subgraph group_module_server["server"]
  node_server_main["Server main<br/>server entrypoint<br/>[ServerMain.java]"]
end

subgraph group_module_shared["shared"]
  node_shared_module["Shared<br/>[SharedTest.java]"]
end

subgraph group_assets["assets"]
  node_asset_configs["Config assets<br/>runtime assets"]
  node_asset_saves["Save assets<br/>runtime content"]
  node_asset_ui["UI assets<br/>ui resources"]
end

node_lwjgl3_launcher -->|"boots"| node_startup_helper
node_startup_helper -->|"launches"| node_game_bootstrap
node_game_bootstrap -->|"loads"| node_config_manager
node_game_bootstrap -->|"opens"| node_main_menu_screen
node_game_bootstrap -->|"initializes"| node_ui_layer
node_ui_layer -->|"contains"| node_main_menu_ui
node_ui_layer -->|"contains"| node_load_menu
node_ui_layer -->|"contains"| node_pause_menu
node_ui_layer -->|"contains"| node_settings_menu
node_settings_menu -->|"edits"| node_config_manager
node_main_menu_screen -->|"navigates"| node_loading_screen
node_loading_screen -->|"parses"| node_save_parser
node_save_parser -->|"builds"| node_game_scene
node_game_bootstrap -->|"switches to"| node_scene_screen
node_scene_screen -->|"renders"| node_game_scene
node_scene_screen -->|"uses"| node_scene_background
node_main_menu_screen -->|"uses"| node_default_background
node_scene_screen -->|"drives"| node_camera_system
node_game_scene -->|"includes"| node_camera_system
node_game_scene -->|"contains"| node_object_model
node_object_model -->|"updates through"| node_physics_engine
node_game_scene -->|"runs with"| node_physics_engine
node_physics_engine -.->|"serializes to"| node_save_parser
node_save_parser -->|"reads"| node_asset_saves
node_config_manager -->|"reads"| node_asset_configs
node_ui_layer -->|"skins with"| node_asset_ui
node_server_main -.->|"depends on"| node_shared_module

click node_lwjgl3_launcher "https://github.com/marct1me/gravitysimulation2-javaedition/blob/master/lwjgl3/src/main/java/com/gravitysimulation2/lwjgl3/Lwjgl3Launcher.java"
click node_startup_helper "https://github.com/marct1me/gravitysimulation2-javaedition/blob/master/lwjgl3/src/main/java/com/gravitysimulation2/lwjgl3/StartupHelper.java"
click node_game_bootstrap "https://github.com/marct1me/gravitysimulation2-javaedition/blob/master/core/src/main/java/com/gravitysimulation2/GravitySimulation2.java"
click node_main_menu_screen "https://github.com/marct1me/gravitysimulation2-javaedition/blob/master/core/src/main/java/com/gravitysimulation2/screen/mainmenu/MainMenuScreen.java"
click node_loading_screen "https://github.com/marct1me/gravitysimulation2-javaedition/blob/master/core/src/main/java/com/gravitysimulation2/screen/loading/SceneLoadingScreen.java"
click node_scene_screen "https://github.com/marct1me/gravitysimulation2-javaedition/blob/master/core/src/main/java/com/gravitysimulation2/screen/scene/SceneScreen.java"
click node_scene_background "https://github.com/marct1me/gravitysimulation2-javaedition/blob/master/core/src/main/java/com/gravitysimulation2/screen/scene/SceneScreenBackground.java"
click node_default_background "https://github.com/marct1me/gravitysimulation2-javaedition/blob/master/core/src/main/java/com/gravitysimulation2/screen/DefaultBackground.java"
click node_ui_layer "https://github.com/marct1me/gravitysimulation2-javaedition/tree/master/core/src/main/java/com/gravitysimulation2/gameinterface"
click node_settings_menu "https://github.com/marct1me/gravitysimulation2-javaedition/blob/master/core/src/main/java/com/gravitysimulation2/gameinterface/menu/settings/SettingsMenu.java"
click node_main_menu_ui "https://github.com/marct1me/gravitysimulation2-javaedition/blob/master/core/src/main/java/com/gravitysimulation2/gameinterface/menu/main/MainMenu.java"
click node_load_menu "https://github.com/marct1me/gravitysimulation2-javaedition/blob/master/core/src/main/java/com/gravitysimulation2/gameinterface/menu/load/LoadMenu.java"
click node_pause_menu "https://github.com/marct1me/gravitysimulation2-javaedition/blob/master/core/src/main/java/com/gravitysimulation2/gameinterface/menu/pause/PauseMenu.java"
click node_config_manager "https://github.com/marct1me/gravitysimulation2-javaedition/blob/master/core/src/main/java/com/gravitysimulation2/config/ConfigManager.java"
click node_game_scene "https://github.com/marct1me/gravitysimulation2-javaedition/blob/master/core/src/main/java/com/gravitysimulation2/objects/GameScene.java"
click node_camera_system "https://github.com/marct1me/gravitysimulation2-javaedition/blob/master/core/src/main/java/com/gravitysimulation2/objects/camera/Camera.java"
click node_object_model "https://github.com/marct1me/gravitysimulation2-javaedition/tree/master/core/src/main/java/com/gravitysimulation2/objects/object"
click node_physics_engine "https://github.com/marct1me/gravitysimulation2-javaedition/tree/master/core/src/main/java/com/gravitysimulation2/objects/physic"
click node_save_parser "https://github.com/marct1me/gravitysimulation2-javaedition/blob/master/core/src/main/java/com/gravitysimulation2/save/SceneParser.java"
click node_server_main "https://github.com/marct1me/gravitysimulation2-javaedition/blob/master/server/src/main/java/com/gravitysimulation2/server/ServerMain.java"
click node_shared_module "https://github.com/marct1me/gravitysimulation2-javaedition/blob/master/shared/src/main/java/com/gravitysimulation2/SharedTest.java"
click node_asset_configs "https://github.com/marct1me/gravitysimulation2-javaedition/tree/master/assets/config"
click node_asset_saves "https://github.com/marct1me/gravitysimulation2-javaedition/tree/master/assets/saves"
click node_asset_ui "https://github.com/marct1me/gravitysimulation2-javaedition/tree/master/assets/ui"

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_lwjgl3_launcher,node_startup_helper toneBlue
class node_game_bootstrap,node_main_menu_screen,node_loading_screen,node_scene_screen,node_scene_background,node_default_background,node_ui_layer,node_settings_menu,node_main_menu_ui,node_load_menu,node_pause_menu,node_config_manager,node_game_scene,node_camera_system,node_object_model,node_physics_engine,node_save_parser toneAmber
class node_server_main toneMint
class node_shared_module toneRose
class node_asset_configs,node_asset_saves,node_asset_ui toneIndigo
```

## Components

### lwjgl3

Desktop launcher and platform startup

- [Launcher](https://github.com/marct1me/gravitysimulation2-javaedition/blob/master/lwjgl3/src/main/java/com/gravitysimulation2/lwjgl3/Lwjgl3Launcher.java): desktop entrypoint · Starts the LibGDX app and applies desktop startup behavior. · `lwjgl3/src/main/java/com/gravitysimulation2/lwjgl3/Lwjgl3Launcher.java`
- [Startup helper](https://github.com/marct1me/gravitysimulation2-javaedition/blob/master/lwjgl3/src/main/java/com/gravitysimulation2/lwjgl3/StartupHelper.java): platform bootstrap · Handles platform-specific startup details before the game opens. · `lwjgl3/src/main/java/com/gravitysimulation2/lwjgl3/StartupHelper.java`

### core

Game runtime, screens, simulation, and UI

- [Game bootstrap](https://github.com/marct1me/gravitysimulation2-javaedition/blob/master/core/src/main/java/com/gravitysimulation2/GravitySimulation2.java): core app · Central game class that loads config, initializes UI, and selects the first screen. · `core/src/main/java/com/gravitysimulation2/GravitySimulation2.java`
- [Main menu](https://github.com/marct1me/gravitysimulation2-javaedition/blob/master/core/src/main/java/com/gravitysimulation2/screen/mainmenu/MainMenuScreen.java): screen · Initial screen for menu-driven startup and navigation. · `core/src/main/java/com/gravitysimulation2/screen/mainmenu/MainMenuScreen.java`
- [Load screen](https://github.com/marct1me/gravitysimulation2-javaedition/blob/master/core/src/main/java/com/gravitysimulation2/screen/loading/SceneLoadingScreen.java): screen · Transition screen used while loading a save or scene. · `core/src/main/java/com/gravitysimulation2/screen/loading/SceneLoadingScreen.java`
- [Scene screen](https://github.com/marct1me/gravitysimulation2-javaedition/blob/master/core/src/main/java/com/gravitysimulation2/screen/scene/SceneScreen.java): screen · Active simulation screen that renders and drives the world. · `core/src/main/java/com/gravitysimulation2/screen/scene/SceneScreen.java`
- [Scene backdrop](https://github.com/marct1me/gravitysimulation2-javaedition/blob/master/core/src/main/java/com/gravitysimulation2/screen/scene/SceneScreenBackground.java): render background · Visual background used behind the active scene screen. · `core/src/main/java/com/gravitysimulation2/screen/scene/SceneScreenBackground.java`
- [Default backdrop](https://github.com/marct1me/gravitysimulation2-javaedition/blob/master/core/src/main/java/com/gravitysimulation2/screen/DefaultBackground.java): render background · Shared background used by screen-level UI states. · `core/src/main/java/com/gravitysimulation2/screen/DefaultBackground.java`
- [UI layer](https://github.com/marct1me/gravitysimulation2-javaedition/tree/master/core/src/main/java/com/gravitysimulation2/gameinterface): interface system · In-game interface layer that coordinates menus and interaction state. · `core/src/main/java/com/gravitysimulation2/gameinterface`
- [Settings menu](https://github.com/marct1me/gravitysimulation2-javaedition/blob/master/core/src/main/java/com/gravitysimulation2/gameinterface/menu/settings/SettingsMenu.java): menu · Menu for adjusting game, graphics, and window settings. · `core/src/main/java/com/gravitysimulation2/gameinterface/menu/settings/SettingsMenu.java`
- [Main menu UI](https://github.com/marct1me/gravitysimulation2-javaedition/blob/master/core/src/main/java/com/gravitysimulation2/gameinterface/menu/main/MainMenu.java): menu · Concrete main menu object and navigation entry. · `core/src/main/java/com/gravitysimulation2/gameinterface/menu/main/MainMenu.java`
- [Load menu](https://github.com/marct1me/gravitysimulation2-javaedition/blob/master/core/src/main/java/com/gravitysimulation2/gameinterface/menu/load/LoadMenu.java): menu · Menu for choosing and opening bundled save scenarios. · `core/src/main/java/com/gravitysimulation2/gameinterface/menu/load/LoadMenu.java`
- [Pause menu](https://github.com/marct1me/gravitysimulation2-javaedition/blob/master/core/src/main/java/com/gravitysimulation2/gameinterface/menu/pause/PauseMenu.java): menu · Pause-state overlay for controlling the running simulation. · `core/src/main/java/com/gravitysimulation2/gameinterface/menu/pause/PauseMenu.java`
- [Config manager](https://github.com/marct1me/gravitysimulation2-javaedition/blob/master/core/src/main/java/com/gravitysimulation2/config/ConfigManager.java): config loader · Loads and manages runtime configuration categories. · `core/src/main/java/com/gravitysimulation2/config/ConfigManager.java`
- [Game scene](https://github.com/marct1me/gravitysimulation2-javaedition/blob/master/core/src/main/java/com/gravitysimulation2/objects/GameScene.java): scene model · Container for the active world, simulation, and camera state. · `core/src/main/java/com/gravitysimulation2/objects/GameScene.java`
- [Camera](https://github.com/marct1me/gravitysimulation2-javaedition/blob/master/core/src/main/java/com/gravitysimulation2/objects/camera/Camera.java): scene camera · Camera state and controller persisted with the scene. · `core/src/main/java/com/gravitysimulation2/objects/camera/Camera.java`
- [Objects](https://github.com/marct1me/gravitysimulation2-javaedition/tree/master/core/src/main/java/com/gravitysimulation2/objects/object): domain model · Base scene objects and object-type implementations. · `core/src/main/java/com/gravitysimulation2/objects/object`
- [Physics](https://github.com/marct1me/gravitysimulation2-javaedition/tree/master/core/src/main/java/com/gravitysimulation2/objects/physic): simulation thread · Separate physics runtime that advances bodies and motion. · `core/src/main/java/com/gravitysimulation2/objects/physic`
- [Save parser](https://github.com/marct1me/gravitysimulation2-javaedition/blob/master/core/src/main/java/com/gravitysimulation2/save/SceneParser.java): save/load pipeline · Rebuilds a full scene from save metadata, scene, simulation, and camera files. · `core/src/main/java/com/gravitysimulation2/save/SceneParser.java`

### server

Standalone server entrypoint

- [Server main](https://github.com/marct1me/gravitysimulation2-javaedition/blob/master/server/src/main/java/com/gravitysimulation2/server/ServerMain.java): server entrypoint · Standalone server entrypoint not wired into the desktop game flow. · `server/src/main/java/com/gravitysimulation2/server/ServerMain.java`

### shared

Shared module placeholder

- [Shared](https://github.com/marct1me/gravitysimulation2-javaedition/blob/master/shared/src/main/java/com/gravitysimulation2/SharedTest.java): shared module · Placeholder module for code reuse or future expansion. · `shared/src/main/java/com/gravitysimulation2/SharedTest.java`

### assets

Runtime configs, UI skins, and bundled saves

- [Config assets](https://github.com/marct1me/gravitysimulation2-javaedition/tree/master/assets/config): runtime assets · Bundled configuration files for game, graphics, and window settings. · `assets/config`
- [Save assets](https://github.com/marct1me/gravitysimulation2-javaedition/tree/master/assets/saves): runtime content · Bundled scenario saves that define loadable worlds. · `assets/saves`
- [UI assets](https://github.com/marct1me/gravitysimulation2-javaedition/tree/master/assets/ui): ui resources · Fonts and skin resources used by the interface layer. · `assets/ui`

## Connections

- Launcher → Startup helper: boots · Desktop launcher uses startup helper for platform-specific boot behavior.
- Startup helper → Game bootstrap: launches · Startup hands control to the core LibGDX game.
- Game bootstrap → Config manager: loads · Core bootstrap loads runtime configuration at startup.
- Game bootstrap → Main menu: opens · Initial state is the main menu screen.
- Game bootstrap → UI layer: initializes · Bootstraps the in-game interface layer.
- UI layer → Main menu UI: contains · UI layer hosts the main menu.
- UI layer → Load menu: contains · UI layer hosts the load menu.
- UI layer → Pause menu: contains · UI layer hosts the pause menu.
- UI layer → Settings menu: contains · UI layer hosts the settings menu.
- Settings menu → Config manager: edits · Settings menu reads and updates runtime config categories.
- Main menu → Load screen: navigates · Menu flow transitions into loading when a save is selected.
- Load screen → Save parser: parses · Load screen reconstructs scene data through the save pipeline.
- Save parser → Game scene: builds · Parsed save data becomes the active scene model.
- Game bootstrap → Scene screen: switches to · Core game activates the scene screen after loading.
- Scene screen → Game scene: renders · Scene screen displays the active world state.
- Scene screen → Scene backdrop: uses · Active scene has its own background layer.
- Main menu → Default backdrop: uses · Menu screens use shared background rendering.
- Scene screen → Camera: drives · Scene screen consumes camera state for view control.
- Game scene → Camera: includes · Camera is part of the serialized scene state.
- Game scene → Objects: contains · Scene owns the world objects.
- Objects → Physics: updates through · Objects are advanced by the physics subsystem.
- Game scene → Physics: runs with · Active scene is paired with the simulation thread.
- Physics → Save parser: serializes to · Simulation state is persisted as part of the save format.
- Save parser → Save assets: reads · Load pipeline reads bundled save scenarios.
- Config manager → Config assets: reads · Configuration manager loads shipped config files.
- UI layer → UI assets: skins with · Interface uses bundled fonts and skin assets.
- Server main → Shared: depends on · Server module likely shares common code boundary.
