# ucsd-cse125-sp22/cse125-sp22-group1 architecture

> Architecture diagram of the GitHub repository ucsd-cse125-sp22/cse125-sp22-group1, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ucsd-cse125-sp22/cse125-sp22-group1
- Repository: https://github.com/ucsd-cse125-sp22/cse125-sp22-group1

## Overview

1. **Monorepo structure**
   - The repository is split into four main products: `chariot-client`, `chariot-server`, `chariot-core`, and `chariot-web`.
   - The Rust crates handle the game; the web app is a separate Next.js/TypeScript companion UI.
   - Top-level GitHub Actions workflows cover build, test, lint, formatting, and release packaging.

2. **High-level runtime model**
   - This is a networked 3D game with a clear client/server split.
   - The server owns authoritative game state and simulation.
   - The client handles rendering, local input, audio, and presentation.
   - The web app is a lightweight auxiliary interface, not the game runtime itself.

3. **Shared game contract: `chariot-core`**
   - `chariot-core` contains the shared data types and rules that must match on both sides of the network.
   - It includes player state, choices, lap info, settings, questions, sound-effect identifiers, and networking packet definitions.
   - This crate is the boundary that keeps client and server in sync without duplicating protocol logic.

4. **Server-side simulation: `chariot-server`**
   - The server crate contains the actual game logic: phases, voting, checkpoints, chairs, powerups, and progress tracking.
   - `game/` appears to orchestrate match flow and interactions; `physics/` handles movement, collisions, ramps, triggers, and state changes.
   - Server code likely consumes input packets, updates authoritative physics/game state, and emits state changes back to clients.

5. **Networking path**
   - Networking abstractions live in `chariot-core/src/networking`, with connection, packet, and websocket-related code.
   - The server and client share packet definitions, so the wire format is centralized.
   - The design suggests a real-time state exchange loop: client inputs go to server, and server updates are broadcast back.

6. **Client application: `chariot-client`**
   - The client is the thick runtime: it owns windowing/game loop entry, input handling, rendering, UI state, and audio playback.
   - Main subsystems include `application.rs`, `game.rs`, `graphics.rs`, `menu_input.rs`, `ui_state.rs`, and utility modules.
   - The client is organized around presentation layers rather than game authority.

7. **Rendering pipeline**
   - Rendering is structured as a reusable renderer layer plus drawable techniques.
   - `renderer/` manages render context, render jobs, reflections, and utilities.
   - `drawable/technique/` contains multiple GPU passes/shaders such as geometry, shadow, skybox, bloom, downsampling, UI, probe lighting, and anti-aliasing.
   - This indicates a multi-pass graphics pipeline with deferred or hybrid techniques rather than a single forward pass.

8. **Asset system**
   - Client assets are bundled in-tree: shaders, 3D models, fonts, sprites, UI art, audio, and sound effects.
   - Asset modules under `src/assets/*` suggest compile-time or package-time inclusion and strongly typed access.
   - The repo also depends on an external track/map asset that must be downloaded separately and placed in `tracks/track.glb`, which is a key runtime dependency for the game world.

9. **Audio subsystem**
   - Audio is separated from rendering and has its own thread/context modules.
   - There are distinct ambient music, soundtrack, and SFX asset groups, plus fade-source/options helpers.
   - The structure suggests asynchronous playback and mixing, likely with runtime control for background ambience and event-driven effects.

10. **Scene/data representation on the client**
   - `scenegraph/`, `resources/`, and `drawable/` indicate a layered client architecture: scene entities, GPU/resource caches, and renderable techniques.
   - Resource modules include static meshes, materials, glyph caching, framebuffers, and surfel-related processing, which support both rendering and UI text.
   - Particle systems and UI string utilities imply a mix of world rendering and in-game interface rendering.

11. **Web companion app: `chariot-web`**
   - `chariot-web` is a separate Next.js app with React components, SCSS styling, and small utility modules.
   - It includes pages for the home screen and game-related UI, plus reusable components like buttons, grids, and standings.
   - A `networking.tsx` utility hints that it may connect to the game backend for harassment/observer-style interaction, as described in the README.

12. **Operational and delivery boundaries**
   - The project supports local development by running server and client separately, with configuration via `config.yaml` for port changes.
   - Release workflows are present, including Windows release builds.
   - This setup reinforces that the deployable units are the Rust server/client binaries plus the independent web frontend, with shared game types central to correctness.

Main entry points: [`chariot-server/src/game`](https://github.com/ucsd-cse125-sp22/cse125-sp22-group1/tree/main/chariot-server/src/game) (Game flow), [`chariot-client/src/application.rs`](https://github.com/ucsd-cse125-sp22/cse125-sp22-group1/blob/main/chariot-client/src/application.rs) (App loop), [`chariot-core/src/networking`](https://github.com/ucsd-cse125-sp22/cse125-sp22-group1/tree/main/chariot-core/src/networking) (Networking), [`chariot-core/src/lib.rs`](https://github.com/ucsd-cse125-sp22/cse125-sp22-group1/blob/main/chariot-core/src/lib.rs) (Core lib)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_monorepo["Monorepo"]
  node_repo_root["Repo root<br/>monorepo"]
end

subgraph group_runtime["Game runtime"]
end

subgraph group_client["Client"]
  node_client_main["Client entry<br/>game binary<br/>[main.rs]"]
  node_client_app["App loop<br/>runtime orchestration<br/>[application.rs]"]
  node_client_game["Client game<br/>presentation state<br/>[game.rs]"]
  node_renderer["Renderer<br/>render system"]
  node_techniques["GPU passes<br/>graphics pipeline"]
  node_resources["Resources<br/>asset cache"]
  node_audio["Audio"]
  node_scenegraph["Scene graph<br/>world representation"]
  node_client_assets["Client assets<br/>bundled content"]
end

subgraph group_server["Server"]
  node_server_main["Server entry<br/>server binary<br/>[main.rs]"]
  node_server_game["Game flow<br/>match orchestration"]
  node_server_physics["Physics<br/>simulation"]
  node_server_progress["Progress<br/>match tracking<br/>[progress.rs]"]
end

subgraph group_core["Shared core"]
  node_core_lib["Core lib<br/>shared crate<br/>[lib.rs]"]
  node_core_network["Networking<br/>protocol layer"]
  node_core_player["Player data<br/>shared state"]
  node_core_rules["Rules data<br/>shared rules<br/>[settings.rs]"]
end

subgraph group_web["Web app"]
  node_web_app["Web app<br/>next.js app"]
  node_web_components["Components"]
  node_web_utils["Web utils<br/>client helpers"]
end

subgraph group_delivery["Delivery"]
  node_workflows["CI/CD<br/>github actions<br/>[workflows]"]
end

node_repo_root -->|"automates"| node_workflows
node_repo_root -->|"contains"| node_client_main
node_repo_root -->|"contains"| node_server_main
node_repo_root -->|"contains"| node_core_lib
node_repo_root -->|"contains"| node_web_app
node_client_main -->|"starts"| node_client_app
node_client_app -->|"drives"| node_client_game
node_client_app -->|"uses"| node_renderer
node_renderer -->|"executes"| node_techniques
node_renderer -->|"consumes"| node_resources
node_client_game -->|"reads"| node_scenegraph
node_client_app -->|"plays"| node_audio
node_client_app -->|"loads"| node_client_assets
node_server_main -->|"orchestrates"| node_server_game
node_server_game -->|"updates"| node_server_physics
node_server_game -->|"tracks"| node_server_progress
node_server_game -->|"receives"| node_core_network
node_server_game -->|"reads"| node_core_player
node_server_game -->|"uses"| node_core_rules
node_core_lib -->|"exposes"| node_core_network
node_core_lib -->|"exposes"| node_core_player
node_core_lib -->|"exposes"| node_core_rules
node_core_network -->|"serves"| node_server_main
node_core_network -->|"serves"| node_client_main
node_web_app -->|"composes"| node_web_components
node_web_app -->|"uses"| node_web_utils
node_web_app -.->|"may connect"| node_core_network

click node_workflows "https://github.com/ucsd-cse125-sp22/cse125-sp22-group1/blob/main/.github/workflows"
click node_client_main "https://github.com/ucsd-cse125-sp22/cse125-sp22-group1/blob/main/chariot-client/src/main.rs"
click node_client_app "https://github.com/ucsd-cse125-sp22/cse125-sp22-group1/blob/main/chariot-client/src/application.rs"
click node_client_game "https://github.com/ucsd-cse125-sp22/cse125-sp22-group1/blob/main/chariot-client/src/game.rs"
click node_renderer "https://github.com/ucsd-cse125-sp22/cse125-sp22-group1/tree/main/chariot-client/src/renderer"
click node_techniques "https://github.com/ucsd-cse125-sp22/cse125-sp22-group1/tree/main/chariot-client/src/drawable/technique"
click node_resources "https://github.com/ucsd-cse125-sp22/cse125-sp22-group1/tree/main/chariot-client/src/resources"
click node_audio "https://github.com/ucsd-cse125-sp22/cse125-sp22-group1/tree/main/chariot-client/src/audio"
click node_scenegraph "https://github.com/ucsd-cse125-sp22/cse125-sp22-group1/tree/main/chariot-client/src/scenegraph"
click node_client_assets "https://github.com/ucsd-cse125-sp22/cse125-sp22-group1/tree/main/chariot-client/src/assets"
click node_server_main "https://github.com/ucsd-cse125-sp22/cse125-sp22-group1/blob/main/chariot-server/src/main.rs"
click node_server_game "https://github.com/ucsd-cse125-sp22/cse125-sp22-group1/tree/main/chariot-server/src/game"
click node_server_physics "https://github.com/ucsd-cse125-sp22/cse125-sp22-group1/tree/main/chariot-server/src/physics"
click node_server_progress "https://github.com/ucsd-cse125-sp22/cse125-sp22-group1/blob/main/chariot-server/src/progress.rs"
click node_core_lib "https://github.com/ucsd-cse125-sp22/cse125-sp22-group1/blob/main/chariot-core/src/lib.rs"
click node_core_network "https://github.com/ucsd-cse125-sp22/cse125-sp22-group1/tree/main/chariot-core/src/networking"
click node_core_player "https://github.com/ucsd-cse125-sp22/cse125-sp22-group1/tree/main/chariot-core/src/player"
click node_core_rules "https://github.com/ucsd-cse125-sp22/cse125-sp22-group1/blob/main/chariot-core/src/settings.rs"
click node_web_app "https://github.com/ucsd-cse125-sp22/cse125-sp22-group1/tree/main/chariot-web/pages"
click node_web_components "https://github.com/ucsd-cse125-sp22/cse125-sp22-group1/tree/main/chariot-web/src/components"
click node_web_utils "https://github.com/ucsd-cse125-sp22/cse125-sp22-group1/tree/main/chariot-web/src/utils"

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_repo_root,node_workflows toneBlue
class node_client_main,node_client_app,node_client_game,node_renderer,node_techniques,node_resources,node_audio,node_scenegraph,node_client_assets toneMint
class node_server_main,node_server_game,node_server_physics,node_server_progress toneRose
class node_core_lib,node_core_network,node_core_player,node_core_rules toneIndigo
class node_web_app,node_web_components,node_web_utils toneTeal
```

## Components

### Monorepo

Top-level repository layout and delivery surfaces.

- **Repo root**: monorepo · Workspace root that ties the Rust crates, web app, and CI together.

### Client

Thick presentation runtime for the game.

- [Client entry](https://github.com/ucsd-cse125-sp22/cse125-sp22-group1/blob/main/chariot-client/src/main.rs): game binary · Application startup and game loop entry for the local player runtime. · `chariot-client/src/main.rs`
- [App loop](https://github.com/ucsd-cse125-sp22/cse125-sp22-group1/blob/main/chariot-client/src/application.rs): runtime orchestration · Windowing, main loop, input routing, and high-level client coordination. · `chariot-client/src/application.rs`
- [Client game](https://github.com/ucsd-cse125-sp22/cse125-sp22-group1/blob/main/chariot-client/src/game.rs): presentation state · Client-side game state and presentation logic. · `chariot-client/src/game.rs`
- [Renderer](https://github.com/ucsd-cse125-sp22/cse125-sp22-group1/tree/main/chariot-client/src/renderer): render system · Render context, jobs, reflections, and renderer utilities. · `chariot-client/src/renderer`
- [GPU passes](https://github.com/ucsd-cse125-sp22/cse125-sp22-group1/tree/main/chariot-client/src/drawable/technique): graphics pipeline · Multi-pass rendering techniques for geometry, shadowing, skybox, bloom, UI, and AA. · `chariot-client/src/drawable/technique`
- [Resources](https://github.com/ucsd-cse125-sp22/cse125-sp22-group1/tree/main/chariot-client/src/resources): asset cache · GPU and runtime resources such as meshes, materials, glyphs, and framebuffers. · `chariot-client/src/resources`
- [Audio](https://github.com/ucsd-cse125-sp22/cse125-sp22-group1/tree/main/chariot-client/src/audio): audio subsystem · Dedicated audio runtime with thread, fade, and playback options. · `chariot-client/src/audio`
- [Scene graph](https://github.com/ucsd-cse125-sp22/cse125-sp22-group1/tree/main/chariot-client/src/scenegraph): world representation · Entity/component scene data and particle system support. · `chariot-client/src/scenegraph`
- [Client assets](https://github.com/ucsd-cse125-sp22/cse125-sp22-group1/tree/main/chariot-client/src/assets): bundled content · In-tree shaders, models, fonts, sprites, UI art, and sound assets. · `chariot-client/src/assets`

### Server

Authoritative simulation and match flow.

- [Server entry](https://github.com/ucsd-cse125-sp22/cse125-sp22-group1/blob/main/chariot-server/src/main.rs): server binary · Authoritative game server startup and runtime entry. · `chariot-server/src/main.rs`
- [Game flow](https://github.com/ucsd-cse125-sp22/cse125-sp22-group1/tree/main/chariot-server/src/game): match orchestration · Phases, voting, interactions, map flow, and powerup orchestration. · `chariot-server/src/game`
- [Physics](https://github.com/ucsd-cse125-sp22/cse125-sp22-group1/tree/main/chariot-server/src/physics): simulation · Movement, collisions, ramps, triggers, and state changes. · `chariot-server/src/physics`
- [Progress](https://github.com/ucsd-cse125-sp22/cse125-sp22-group1/blob/main/chariot-server/src/progress.rs): match tracking · Race progress and server-side progression bookkeeping. · `chariot-server/src/progress.rs`

### Shared core

Networked data contract shared by client and server.

- [Core lib](https://github.com/ucsd-cse125-sp22/cse125-sp22-group1/blob/main/chariot-core/src/lib.rs): shared crate · Shared network contract and common game data. · `chariot-core/src/lib.rs`
- [Networking](https://github.com/ucsd-cse125-sp22/cse125-sp22-group1/tree/main/chariot-core/src/networking): protocol layer · Connection management, packets, and websocket transport helpers. · `chariot-core/src/networking`
- [Player data](https://github.com/ucsd-cse125-sp22/cse125-sp22-group1/tree/main/chariot-core/src/player): shared state · Player state, inputs, choices, and lap info. · `chariot-core/src/player`
- [Rules data](https://github.com/ucsd-cse125-sp22/cse125-sp22-group1/blob/main/chariot-core/src/settings.rs): shared rules · Shared settings, questions, sound effects, and entity location data. · `chariot-core/src/settings.rs`

### Web app

Separate Next.js companion interface.

- [Web app](https://github.com/ucsd-cse125-sp22/cse125-sp22-group1/tree/main/chariot-web/pages): next.js app · Separate React/TypeScript companion UI. · `chariot-web/pages`
- [Components](https://github.com/ucsd-cse125-sp22/cse125-sp22-group1/tree/main/chariot-web/src/components): ui components · Reusable UI building blocks such as buttons, grids, and standings. · `chariot-web/src/components`
- [Web utils](https://github.com/ucsd-cse125-sp22/cse125-sp22-group1/tree/main/chariot-web/src/utils): client helpers · Browser and networking utilities for the companion site. · `chariot-web/src/utils`

### Delivery

Build, test, lint, and release automation.

- [CI/CD](https://github.com/ucsd-cse125-sp22/cse125-sp22-group1/blob/main/.github/workflows): github actions · Build, test, lint, format, and release workflows. · `.github/workflows`

## Connections

- Repo root → CI/CD: automates · Repository-level build and release automation.
- Repo root → Client entry: contains · Primary client binary.
- Repo root → Server entry: contains · Primary server binary.
- Repo root → Core lib: contains · Shared crate used by client and server.
- Repo root → Web app: contains · Companion web frontend.
- Client entry → App loop: starts · Bootstraps the application loop.
- App loop → Client game: drives · Coordinates client-side game presentation.
- App loop → Renderer: uses · Delegates frame rendering.
- Renderer → GPU passes: executes · Runs the multi-pass graphics pipeline.
- Renderer → Resources: consumes · Uses cached GPU/runtime resources.
- Client game → Scene graph: reads · Consumes world and entity presentation data.
- App loop → Audio: plays · Triggers and manages audio playback.
- App loop → Client assets: loads · Uses bundled art, shaders, and sounds.
- Server entry → Game flow: orchestrates · Controls match flow and interactions.
- Game flow → Physics: updates · Simulation and authoritative movement changes.
- Game flow → Progress: tracks · Maintains progress and race state.
- Game flow → Networking: receives · Consumes client packets and connection events.
- Game flow → Player data: reads · Uses shared player and input state.
- Game flow → Rules data: uses · Depends on shared rules and settings.
- Core lib → Networking: exposes · Central networking definitions.
- Core lib → Player data: exposes · Shared player-facing state and inputs.
- Core lib → Rules data: exposes · Shared rules, questions, and settings.
- Networking → Server entry: serves · Server-side protocol transport.
- Networking → Client entry: serves · Client-side protocol transport.
- Web app → Components: composes · Pages assemble reusable components.
- Web app → Web utils: uses · Uses browser and networking helpers.
- Web app → Networking: may connect · Auxiliary UI can interact with the backend protocol.
