# anotherseeker/comp3320-undergrad-group-project architecture

> Architecture diagram of the GitHub repository anotherseeker/comp3320-undergrad-group-project, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/anotherseeker/comp3320-undergrad-group-project
- Repository: https://github.com/anotherseeker/comp3320-undergrad-group-project

## Overview

Sunken Castle is a small 3D engine with a C ABI and a Luau scripting host. A client initializes the engine, loads mesh and shader assets, creates scene objects, and runs the render loop; input and frame events can be forwarded to client callbacks or Luau. Rendering collects scene entities into draw commands and uses camera and object transforms to draw meshes with shaders. The sampled source supports the main engine flow; runtime internals and several engine modules were not sampled, so their wiring is shown only where evidenced by the tree or explicit calls.

Main entry points: [`engine/sunken_engine.cpp`](https://github.com/anotherseeker/comp3320-undergrad-group-project/blob/main/engine/sunken_engine.cpp) (C API facade), [`engine/core/app.cpp`](https://github.com/anotherseeker/comp3320-undergrad-group-project/blob/main/engine/core/app.cpp) (App loop), [`engine/core/asset_manager.cpp`](https://github.com/anotherseeker/comp3320-undergrad-group-project/blob/main/engine/core/asset_manager.cpp) (Asset manager), [`runtime/src/runtime.rs`](https://github.com/anotherseeker/comp3320-undergrad-group-project/blob/main/runtime/src/runtime.rs) (Luau runtime)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Engine API"]
  node_api_facade["C API facade<br/>[sunken_engine.cpp]"]
end

subgraph group_core["Engine Core"]
  node_app_loop["App loop<br/>[app.cpp]"]
  node_events["Event manager<br/>[events.cpp]"]
  node_scene["Scene graph<br/>[scene_graph.cpp]"]
  node_assets["Asset manager<br/>[asset_manager.cpp]"]
  node_debugger["Debugger<br/>[debugger.cpp]"]
end

subgraph group_render["Rendering"]
  node_mesh["Mesh<br/>[mesh.cpp]"]
  node_shader["Shader<br/>[shader.cpp]"]
  node_renderer["Renderer<br/>[renderer.cpp]"]
end

subgraph group_script["Luau Runtime"]
  node_rust_host["Rust host<br/>[main.rs]"]
  node_lua_runtime["Luau runtime<br/>[runtime.rs]"]
  node_ffi_bindings["Engine bindings<br/>[bindings.rs]"]
  node_user_objects["User objects<br/>[ud_object.rs]"]
end

node_cpp_client(("C++ client"))
node_luau_script["Luau script<br/>[demo.luau]"]
node_asset_files["Mesh and shader files"]
node_glfw["GLFW"]
node_opengl["OpenGL"]

node_cpp_client -->|"calls API"| node_api_facade
node_api_facade -->|"initializes, runs"| node_app_loop
node_api_facade -->|"registers listeners"| node_events
node_api_facade -->|"loads, retrieves"| node_assets
node_api_facade -->|"creates, moves"| node_scene
node_api_facade -->|"sets view"| node_renderer
node_app_loop -->|"polls events"| node_glfw
node_app_loop -->|"dispatches events"| node_events
node_events -->|"calls callback"| node_api_facade
node_app_loop -->|"submits entities"| node_scene
node_scene -->|"submits draws"| node_renderer
node_renderer -->|"issues draw calls"| node_opengl
node_assets -->|"reads assets"| node_asset_files
node_assets -->|"builds meshes"| node_mesh
node_assets -->|"creates shaders"| node_shader
node_rust_host -->|"runs script"| node_lua_runtime
node_lua_runtime -->|"loads"| node_luau_script
node_rust_host -->|"uses bindings"| node_ffi_bindings
node_ffi_bindings -->|"calls exported API"| node_api_facade
node_api_facade -->|"forwards events"| node_rust_host
node_lua_runtime -->|"uses objects"| node_user_objects

click node_luau_script "https://github.com/anotherseeker/comp3320-undergrad-group-project/blob/main/runtime/demo_scripts/demo.luau"
click node_api_facade "https://github.com/anotherseeker/comp3320-undergrad-group-project/blob/main/engine/sunken_engine.cpp"
click node_app_loop "https://github.com/anotherseeker/comp3320-undergrad-group-project/blob/main/engine/core/app.cpp"
click node_events "https://github.com/anotherseeker/comp3320-undergrad-group-project/blob/main/engine/core/events/events.cpp"
click node_scene "https://github.com/anotherseeker/comp3320-undergrad-group-project/blob/main/engine/core/scene_graph.cpp"
click node_assets "https://github.com/anotherseeker/comp3320-undergrad-group-project/blob/main/engine/core/asset_manager.cpp"
click node_debugger "https://github.com/anotherseeker/comp3320-undergrad-group-project/blob/main/engine/core/debugger.cpp"
click node_asset_files "https://github.com/anotherseeker/comp3320-undergrad-group-project/tree/main/assets"
click node_mesh "https://github.com/anotherseeker/comp3320-undergrad-group-project/blob/main/engine/renderer/mesh.cpp"
click node_shader "https://github.com/anotherseeker/comp3320-undergrad-group-project/blob/main/engine/renderer/shader.cpp"
click node_renderer "https://github.com/anotherseeker/comp3320-undergrad-group-project/blob/main/engine/renderer/renderer.cpp"
click node_rust_host "https://github.com/anotherseeker/comp3320-undergrad-group-project/blob/main/runtime/src/main.rs"
click node_lua_runtime "https://github.com/anotherseeker/comp3320-undergrad-group-project/blob/main/runtime/src/runtime.rs"
click node_ffi_bindings "https://github.com/anotherseeker/comp3320-undergrad-group-project/blob/main/runtime/src/bindings.rs"
click node_user_objects "https://github.com/anotherseeker/comp3320-undergrad-group-project/blob/main/runtime/src/ud_object.rs"

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_api_facade,node_cpp_client toneBlue
class node_app_loop,node_events,node_scene,node_assets,node_debugger toneAmber
class node_mesh,node_shader,node_renderer toneMint
class node_rust_host,node_lua_runtime,node_ffi_bindings,node_user_objects toneRose
class node_luau_script,node_asset_files toneTeal
class node_glfw,node_opengl toneIndigo
```

## Components

### Engine API

- [C API facade](https://github.com/anotherseeker/comp3320-undergrad-group-project/blob/main/engine/sunken_engine.cpp): `engine/sunken_engine.cpp`

### Engine Core

- [App loop](https://github.com/anotherseeker/comp3320-undergrad-group-project/blob/main/engine/core/app.cpp): `engine/core/app.cpp`
- [Event manager](https://github.com/anotherseeker/comp3320-undergrad-group-project/blob/main/engine/core/events/events.cpp): `engine/core/events/events.cpp`
- [Scene graph](https://github.com/anotherseeker/comp3320-undergrad-group-project/blob/main/engine/core/scene_graph.cpp): `engine/core/scene_graph.cpp`
- [Asset manager](https://github.com/anotherseeker/comp3320-undergrad-group-project/blob/main/engine/core/asset_manager.cpp): `engine/core/asset_manager.cpp`
- [Debugger](https://github.com/anotherseeker/comp3320-undergrad-group-project/blob/main/engine/core/debugger.cpp): `engine/core/debugger.cpp`

### Rendering

- [Mesh](https://github.com/anotherseeker/comp3320-undergrad-group-project/blob/main/engine/renderer/mesh.cpp): `engine/renderer/mesh.cpp`
- [Shader](https://github.com/anotherseeker/comp3320-undergrad-group-project/blob/main/engine/renderer/shader.cpp): `engine/renderer/shader.cpp`
- [Renderer](https://github.com/anotherseeker/comp3320-undergrad-group-project/blob/main/engine/renderer/renderer.cpp): `engine/renderer/renderer.cpp`

### Luau Runtime

- [Rust host](https://github.com/anotherseeker/comp3320-undergrad-group-project/blob/main/runtime/src/main.rs): `runtime/src/main.rs`
- [Luau runtime](https://github.com/anotherseeker/comp3320-undergrad-group-project/blob/main/runtime/src/runtime.rs): `runtime/src/runtime.rs`
- [Engine bindings](https://github.com/anotherseeker/comp3320-undergrad-group-project/blob/main/runtime/src/bindings.rs): `runtime/src/bindings.rs`
- [User objects](https://github.com/anotherseeker/comp3320-undergrad-group-project/blob/main/runtime/src/ud_object.rs): `runtime/src/ud_object.rs`

### Other components

- **C++ client**
- [Luau script](https://github.com/anotherseeker/comp3320-undergrad-group-project/blob/main/runtime/demo_scripts/demo.luau): `runtime/demo_scripts/demo.luau`
- [Mesh and shader files](https://github.com/anotherseeker/comp3320-undergrad-group-project/tree/main/assets): `assets`
- **GLFW**
- **OpenGL**

## Connections

- C++ client → C API facade: calls API
- C API facade → App loop: initializes, runs
- C API facade → Event manager: registers listeners
- C API facade → Asset manager: loads, retrieves
- C API facade → Scene graph: creates, moves
- C API facade → Renderer: sets view
- App loop → GLFW: polls events
- App loop → Event manager: dispatches events
- Event manager → C API facade: calls callback
- App loop → Scene graph: submits entities
- Scene graph → Renderer: submits draws
- Renderer → OpenGL: issues draw calls
- Asset manager → Mesh and shader files: reads assets
- Asset manager → Mesh: builds meshes
- Asset manager → Shader: creates shaders
- Rust host → Luau runtime: runs script
- Luau runtime → Luau script: loads
- Rust host → Engine bindings: uses bindings
- Engine bindings → C API facade: calls exported API
- C API facade → Rust host: forwards events
- Luau runtime → User objects: uses objects
