# stephengold/v-sport architecture

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

- Interactive diagram: https://gitdiagram.com/stephengold/v-sport
- Repository: https://github.com/stephengold/v-sport

## Overview

#### Purpose and module layout
V-Sport is a Java Vulkan rendering engine designed to visualize Libbulletjme physics. The Gradle multi-project build separates the reusable engine in `lib/` from executable demos, tutorials, and manual tests in `apps/`. Core build/module definitions are `settings.gradle`, `lib/build.gradle`, and `apps/build.gradle`.

#### Application entry model
Applications extend the physics-aware base class, initialize a physics space, populate it, and update it before rendering. The principal lifecycle boundary is `lib/src/main/java/com/github/stephengold/vsport/physics/BasePhysicsApp.java`, built on `lib/src/main/java/com/github/stephengold/vsport/BaseApplication.java`. Runnable examples include `apps/src/main/java/com/github/stephengold/vsport/tutorial/HelloSport.java` and the Swing launcher `apps/src/main/java/com/github/stephengold/vsport/demo/AppChooser.java`.

#### Vulkan runtime and frame pipeline
`BaseApplication` owns engine lifecycle; Vulkan-facing setup and device selection are organized around `PhysicalDevice`, `LogicalDevice`, and internal state in `lib/src/main/java/com/github/stephengold/vsport/PhysicalDevice.java`, `lib/src/main/java/com/github/stephengold/vsport/LogicalDevice.java`, and `lib/src/main/java/com/github/stephengold/vsport/Internals.java`. Per-frame synchronization, command recording, and presentation flow through `Frame`, `CommandSequence`, and swapchain-related resources such as `lib/src/main/java/com/github/stephengold/vsport/Frame.java` and `lib/src/main/java/com/github/stephengold/vsport/ChainResources.java`.

#### Renderable-object boundary
There is no scene graph. Constructing a `Geometry` registers it in the engine’s internal renderable list; application code therefore controls visibility through geometry lifetime. Geometry combines mesh/material-like shader inputs and draw state, centered on `lib/src/main/java/com/github/stephengold/vsport/Geometry.java`, `lib/src/main/java/com/github/stephengold/vsport/Mesh.java`, and `lib/src/main/java/com/github/stephengold/vsport/Draw.java`. Standard procedural meshes live under `lib/src/main/java/com/github/stephengold/vsport/mesh/`.

#### GPU assets, shaders, and camera data
CPU mesh data becomes Vulkan buffers/images through resource wrappers including `lib/src/main/java/com/github/stephengold/vsport/VertexBuffer.java`, `lib/src/main/java/com/github/stephengold/vsport/DeviceImage.java`, and `lib/src/main/java/com/github/stephengold/vsport/Texture.java`. Shader programs and uniform inputs bridge rendering state to GLSL/SPIR-V compilation/loading: `lib/src/main/java/com/github/stephengold/vsport/ShaderProgram.java`, `lib/src/main/java/com/github/stephengold/vsport/GlobalUniformValues.java`, and `lib/src/main/resources/Shaders/`. Camera/projection state is isolated in `lib/src/main/java/com/github/stephengold/vsport/Camera.java` and `lib/src/main/java/com/github/stephengold/vsport/Projection.java`.

#### Physics visualization layer
The physics package adapts Libbulletjme collision objects, constraints, vehicles, and soft bodies into geometries rather than modifying the physics engine. `lib/src/main/java/com/github/stephengold/vsport/physics/RigidBodyShapeGeometry.java`, `lib/src/main/java/com/github/stephengold/vsport/physics/ConstraintGeometry.java`, and `lib/src/main/java/com/github/stephengold/vsport/physics/ShapeMesh.java` define this boundary. Frame updates synchronize these visualizations with physics-space state.

#### Input, imports, and external runtime dependencies
GLFW-backed input is routed through processors in `lib/src/main/java/com/github/stephengold/vsport/input/InputManager.java` and `lib/src/main/java/com/github/stephengold/vsport/input/CameraInputProcessor.java`. Model importing uses Assimp via `lib/src/main/java/com/github/stephengold/vsport/importers/AssimpUtils.java`. Runtime depends on Vulkan through LWJGL, GLFW, Assimp, JOML, jSnapLoader, and Libbulletjme native libraries; consumers must explicitly select platform-native Libbulletjme and LWJGL artifacts.

Main entry points: [`lib/src/main/java/com/github/stephengold/vsport/BaseApplication.java`](https://github.com/stephengold/v-sport/blob/master/lib/src/main/java/com/github/stephengold/vsport/BaseApplication.java) (BaseApplication), [`lib/src/main/java/com/github/stephengold/vsport/Frame.java`](https://github.com/stephengold/v-sport/blob/master/lib/src/main/java/com/github/stephengold/vsport/Frame.java) (Frame pipeline), [`lib/src/main/java/com/github/stephengold/vsport/physics/BasePhysicsApp.java`](https://github.com/stephengold/v-sport/blob/master/lib/src/main/java/com/github/stephengold/vsport/physics/BasePhysicsApp.java) (BasePhysicsApp), [`lib/src/main/java/com/github/stephengold/vsport/physics/RigidBodyShapeGeometry.java`](https://github.com/stephengold/v-sport/blob/master/lib/src/main/java/com/github/stephengold/vsport/physics/RigidBodyShapeGeometry.java) (Physics geometries)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_build["Gradle modules"]
  node_settings["Multi-project build<br/>Gradle settings<br/>[settings.gradle]"]
  node_lib_build["Engine module<br/>Gradle module<br/>[build.gradle]"]
  node_apps_build["Apps module<br/>Gradle module<br/>[build.gradle]"]
end

subgraph group_engine["V-Sport engine"]
  node_base_app["BaseApplication<br/>engine lifecycle"]
  node_vulkan_devices{{"Vulkan devices<br/>device setup"}}
  node_internals["Internals<br/>engine state<br/>[Internals.java]"]
  node_frame_pipeline["Frame pipeline<br/>Vulkan frame flow<br/>[Frame.java]"]
  node_chain_resources["Swapchain resources<br/>frame resources"]
  node_geometry["Geometry<br/>renderable registry<br/>[Geometry.java]"]
  node_mesh_draw["Mesh and draw state<br/>render primitives<br/>[Mesh.java]"]
  node_gpu_assets["GPU assets<br/>buffers and textures<br/>[VertexBuffer.java]"]
  node_shaders["Shaders and uniforms<br/>shader pipeline<br/>[ShaderProgram.java]"]
  node_camera["Camera and projection<br/>view state<br/>[Camera.java]"]
  node_input["Input manager<br/>GLFW input<br/>[InputManager.java]"]
  node_importer["Assimp importer<br/>model import<br/>[AssimpUtils.java]"]
end

subgraph group_physics["Physics visualization"]
  node_base_physics["BasePhysicsApp<br/>physics app lifecycle"]
  node_physics_visuals["Physics geometries<br/>Libbulletjme adapter"]
  node_shape_mesh["ShapeMesh<br/>physics mesh adapter<br/>[ShapeMesh.java]"]
end

subgraph group_apps["Applications"]
  node_hello_sport["HelloSport<br/>tutorial application<br/>[HelloSport.java]"]
  node_app_chooser["AppChooser<br/>Swing launcher<br/>[AppChooser.java]"]
end

node_native_runtime{{"Native runtime<br/>external dependencies"}}

node_settings -->|"includes"| node_lib_build
node_settings -->|"includes"| node_apps_build
node_apps_build -->|"depends on"| node_lib_build
node_hello_sport -->|"extends"| node_base_physics
node_base_physics -->|"extends"| node_base_app
node_base_physics -->|"updates"| node_physics_visuals
node_physics_visuals -->|"builds meshes"| node_shape_mesh
node_physics_visuals -->|"creates"| node_geometry
node_base_app -->|"initializes"| node_vulkan_devices
node_base_app -->|"owns"| node_internals
node_base_app -->|"runs per frame"| node_frame_pipeline
node_vulkan_devices -->|"uses Vulkan"| node_native_runtime
node_frame_pipeline -->|"uses"| node_chain_resources
node_frame_pipeline -->|"renders registered"| node_geometry
node_geometry -->|"combines"| node_mesh_draw
node_mesh_draw -->|"uploads through"| node_gpu_assets
node_frame_pipeline -->|"binds"| node_shaders
node_camera -->|"supplies uniforms"| node_shaders
node_input -->|"controls"| node_camera
node_importer -->|"loads models into"| node_mesh_draw
node_input -->|"uses GLFW"| node_native_runtime
node_importer -->|"uses Assimp"| node_native_runtime
node_app_chooser -.->|"launches examples"| node_hello_sport

click node_settings "https://github.com/stephengold/v-sport/blob/master/settings.gradle"
click node_lib_build "https://github.com/stephengold/v-sport/blob/master/lib/build.gradle"
click node_apps_build "https://github.com/stephengold/v-sport/blob/master/apps/build.gradle"
click node_base_app "https://github.com/stephengold/v-sport/blob/master/lib/src/main/java/com/github/stephengold/vsport/BaseApplication.java"
click node_vulkan_devices "https://github.com/stephengold/v-sport/blob/master/lib/src/main/java/com/github/stephengold/vsport/PhysicalDevice.java"
click node_internals "https://github.com/stephengold/v-sport/blob/master/lib/src/main/java/com/github/stephengold/vsport/Internals.java"
click node_frame_pipeline "https://github.com/stephengold/v-sport/blob/master/lib/src/main/java/com/github/stephengold/vsport/Frame.java"
click node_chain_resources "https://github.com/stephengold/v-sport/blob/master/lib/src/main/java/com/github/stephengold/vsport/ChainResources.java"
click node_geometry "https://github.com/stephengold/v-sport/blob/master/lib/src/main/java/com/github/stephengold/vsport/Geometry.java"
click node_mesh_draw "https://github.com/stephengold/v-sport/blob/master/lib/src/main/java/com/github/stephengold/vsport/Mesh.java"
click node_gpu_assets "https://github.com/stephengold/v-sport/blob/master/lib/src/main/java/com/github/stephengold/vsport/VertexBuffer.java"
click node_shaders "https://github.com/stephengold/v-sport/blob/master/lib/src/main/java/com/github/stephengold/vsport/ShaderProgram.java"
click node_camera "https://github.com/stephengold/v-sport/blob/master/lib/src/main/java/com/github/stephengold/vsport/Camera.java"
click node_input "https://github.com/stephengold/v-sport/blob/master/lib/src/main/java/com/github/stephengold/vsport/input/InputManager.java"
click node_importer "https://github.com/stephengold/v-sport/blob/master/lib/src/main/java/com/github/stephengold/vsport/importers/AssimpUtils.java"
click node_base_physics "https://github.com/stephengold/v-sport/blob/master/lib/src/main/java/com/github/stephengold/vsport/physics/BasePhysicsApp.java"
click node_physics_visuals "https://github.com/stephengold/v-sport/blob/master/lib/src/main/java/com/github/stephengold/vsport/physics/RigidBodyShapeGeometry.java"
click node_shape_mesh "https://github.com/stephengold/v-sport/blob/master/lib/src/main/java/com/github/stephengold/vsport/physics/ShapeMesh.java"
click node_hello_sport "https://github.com/stephengold/v-sport/blob/master/apps/src/main/java/com/github/stephengold/vsport/tutorial/HelloSport.java"
click node_app_chooser "https://github.com/stephengold/v-sport/blob/master/apps/src/main/java/com/github/stephengold/vsport/demo/AppChooser.java"

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_settings,node_lib_build,node_apps_build toneBlue
class node_base_app,node_vulkan_devices,node_internals,node_frame_pipeline,node_chain_resources,node_geometry,node_mesh_draw,node_gpu_assets,node_shaders,node_camera,node_input,node_importer toneAmber
class node_base_physics,node_physics_visuals,node_shape_mesh toneMint
class node_hello_sport,node_app_chooser toneRose
class node_native_runtime toneNeutral
```

## Components

### Gradle modules

Reusable engine and runnable applications are separate modules.

- [Multi-project build](https://github.com/stephengold/v-sport/blob/master/settings.gradle): Gradle settings · `settings.gradle`
- [Engine module](https://github.com/stephengold/v-sport/blob/master/lib/build.gradle): Gradle module · `lib/build.gradle`
- [Apps module](https://github.com/stephengold/v-sport/blob/master/apps/build.gradle): Gradle module · `apps/build.gradle`

### V-Sport engine

- [BaseApplication](https://github.com/stephengold/v-sport/blob/master/lib/src/main/java/com/github/stephengold/vsport/BaseApplication.java): engine lifecycle · Owns engine lifecycle and Vulkan runtime orchestration. · `lib/src/main/java/com/github/stephengold/vsport/BaseApplication.java`
- [Vulkan devices](https://github.com/stephengold/v-sport/blob/master/lib/src/main/java/com/github/stephengold/vsport/PhysicalDevice.java): device setup · Physical-device selection and logical-device creation. · `lib/src/main/java/com/github/stephengold/vsport/PhysicalDevice.java`
- [Internals](https://github.com/stephengold/v-sport/blob/master/lib/src/main/java/com/github/stephengold/vsport/Internals.java): engine state · `lib/src/main/java/com/github/stephengold/vsport/Internals.java`
- [Frame pipeline](https://github.com/stephengold/v-sport/blob/master/lib/src/main/java/com/github/stephengold/vsport/Frame.java): Vulkan frame flow · Synchronizes, records commands, and presents swapchain frames. · `lib/src/main/java/com/github/stephengold/vsport/Frame.java`
- [Swapchain resources](https://github.com/stephengold/v-sport/blob/master/lib/src/main/java/com/github/stephengold/vsport/ChainResources.java): frame resources · `lib/src/main/java/com/github/stephengold/vsport/ChainResources.java`
- [Geometry](https://github.com/stephengold/v-sport/blob/master/lib/src/main/java/com/github/stephengold/vsport/Geometry.java): renderable registry · Construction registers a renderable; lifetime controls visibility. · `lib/src/main/java/com/github/stephengold/vsport/Geometry.java`
- [Mesh and draw state](https://github.com/stephengold/v-sport/blob/master/lib/src/main/java/com/github/stephengold/vsport/Mesh.java): render primitives · `lib/src/main/java/com/github/stephengold/vsport/Mesh.java`
- [GPU assets](https://github.com/stephengold/v-sport/blob/master/lib/src/main/java/com/github/stephengold/vsport/VertexBuffer.java): buffers and textures · Uploads CPU mesh and texture data into Vulkan resources. · `lib/src/main/java/com/github/stephengold/vsport/VertexBuffer.java`
- [Shaders and uniforms](https://github.com/stephengold/v-sport/blob/master/lib/src/main/java/com/github/stephengold/vsport/ShaderProgram.java): shader pipeline · `lib/src/main/java/com/github/stephengold/vsport/ShaderProgram.java`
- [Camera and projection](https://github.com/stephengold/v-sport/blob/master/lib/src/main/java/com/github/stephengold/vsport/Camera.java): view state · `lib/src/main/java/com/github/stephengold/vsport/Camera.java`
- [Input manager](https://github.com/stephengold/v-sport/blob/master/lib/src/main/java/com/github/stephengold/vsport/input/InputManager.java): GLFW input · `lib/src/main/java/com/github/stephengold/vsport/input/InputManager.java`
- [Assimp importer](https://github.com/stephengold/v-sport/blob/master/lib/src/main/java/com/github/stephengold/vsport/importers/AssimpUtils.java): model import · `lib/src/main/java/com/github/stephengold/vsport/importers/AssimpUtils.java`

### Physics visualization

- [BasePhysicsApp](https://github.com/stephengold/v-sport/blob/master/lib/src/main/java/com/github/stephengold/vsport/physics/BasePhysicsApp.java): physics app lifecycle · Initializes and updates the physics space before rendering. · `lib/src/main/java/com/github/stephengold/vsport/physics/BasePhysicsApp.java`
- [Physics geometries](https://github.com/stephengold/v-sport/blob/master/lib/src/main/java/com/github/stephengold/vsport/physics/RigidBodyShapeGeometry.java): Libbulletjme adapter · Maps collision objects and constraints to engine geometries. · `lib/src/main/java/com/github/stephengold/vsport/physics/RigidBodyShapeGeometry.java`
- [ShapeMesh](https://github.com/stephengold/v-sport/blob/master/lib/src/main/java/com/github/stephengold/vsport/physics/ShapeMesh.java): physics mesh adapter · `lib/src/main/java/com/github/stephengold/vsport/physics/ShapeMesh.java`

### Applications

- [HelloSport](https://github.com/stephengold/v-sport/blob/master/apps/src/main/java/com/github/stephengold/vsport/tutorial/HelloSport.java): tutorial application · `apps/src/main/java/com/github/stephengold/vsport/tutorial/HelloSport.java`
- [AppChooser](https://github.com/stephengold/v-sport/blob/master/apps/src/main/java/com/github/stephengold/vsport/demo/AppChooser.java): Swing launcher · `apps/src/main/java/com/github/stephengold/vsport/demo/AppChooser.java`

### Other components

- **Native runtime**: external dependencies · LWJGL Vulkan, GLFW, Assimp, and Libbulletjme native artifacts.

## Connections

- Multi-project build → Engine module: includes
- Multi-project build → Apps module: includes
- Apps module → Engine module: depends on
- HelloSport → BasePhysicsApp: extends
- BasePhysicsApp → BaseApplication: extends
- BasePhysicsApp → Physics geometries: updates
- Physics geometries → ShapeMesh: builds meshes
- Physics geometries → Geometry: creates
- BaseApplication → Vulkan devices: initializes
- BaseApplication → Internals: owns
- BaseApplication → Frame pipeline: runs per frame
- Vulkan devices → Native runtime: uses Vulkan
- Frame pipeline → Swapchain resources: uses
- Frame pipeline → Geometry: renders registered
- Geometry → Mesh and draw state: combines
- Mesh and draw state → GPU assets: uploads through
- Frame pipeline → Shaders and uniforms: binds
- Camera and projection → Shaders and uniforms: supplies uniforms
- Input manager → Camera and projection: controls
- Assimp importer → Mesh and draw state: loads models into
- Input manager → Native runtime: uses GLFW
- Assimp importer → Native runtime: uses Assimp
- AppChooser → HelloSport: launches examples
