# trewrightserves/homegames architecture

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

- Interactive diagram: https://gitdiagram.com/trewrightserves/homegames
- Repository: https://github.com/trewrightserves/homegames

## Overview

HomeGames Voxel is a browser-based multiplayer voxel game for a home LAN. A player opens the hosted client, joins through the network client, and receives world state; the client renders the world and handles movement and interaction, while the server coordinates multiplayer state and gameplay requests. The README documents chunked terrain, block editing, chat commands, and multiplayer sync; sampled server code also indicates inventory, crafting, entities, quests, and appearance features. The server is a substantial monolith, so these are logical responsibilities at one source path; unsampled wiring is omitted.

Main entry points: [`public/js/main.js`](https://github.com/trewrightserves/homegames/blob/main/public/js/main.js) (Client coordinator), [`public/js/network/Network.js`](https://github.com/trewrightserves/homegames/blob/main/public/js/network/Network.js) (Socket client), [`server.js`](https://github.com/trewrightserves/homegames/blob/main/server.js) (HTTP and game server), [`public/js/player/Inventory.js`](https://github.com/trewrightserves/homegames/blob/main/public/js/player/Inventory.js) (Inventory and crafting UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Browser Client"]
  node_main["Client coordinator<br/>[main.js]"]
  node_renderer["Voxel renderer<br/>[Render.js]"]
  node_localplayer["Input and controls<br/>[Player.js]"]
end

subgraph group_world["World Simulation"]
  node_physics["Movement physics<br/>[Physics.js]"]
  node_worldmgr["Chunk world<br/>[World.js]"]
  node_serverworld["Authoritative world<br/>[server.js]"]
end

subgraph group_multiplayer["Multiplayer Services"]
  node_network["Socket client<br/>[Network.js]"]
  node_server["HTTP and game server<br/>[server.js]"]
  node_serverplayers["Player sync and commands<br/>[server.js]"]
end

subgraph group_gameplay["Player Features"]
  node_chat["Chat console<br/>[Chat.js]"]
  node_inventory["Inventory and crafting UI<br/>[Inventory.js]"]
  node_items["Item registry<br/>[ItemRegistry.js]"]
  node_servergameplay["Items, entities, quests<br/>[server.js]"]
end

node_player(("LAN player"))

node_player -->|"opens client"| node_main
node_main -->|"creates controls"| node_localplayer
node_main -->|"creates world"| node_worldmgr
node_main -->|"creates physics"| node_physics
node_main -->|"creates renderer"| node_renderer
node_main -->|"creates client"| node_network
node_main -->|"creates console"| node_chat
node_main -->|"creates UI"| node_inventory
node_physics -->|"checks collisions"| node_worldmgr
node_renderer -->|"renders chunks"| node_worldmgr
node_inventory -->|"reads item data"| node_items
node_main -->|"maps hotbar items"| node_items
node_network -->|"exchanges socket events"| node_server
node_server -->|"generates and reads chunks"| node_serverworld
node_server -->|"handles player updates and commands"| node_serverplayers
node_server -->|"handles crafting and interactions"| node_servergameplay
node_chat -->|"submits chat"| node_main
node_inventory -->|"sends craft requests"| node_network
node_serverworld -->|"sends world state"| node_network
node_serverplayers -->|"sends player and command events"| node_network
node_servergameplay -->|"sends gameplay events"| node_network

click node_main "https://github.com/trewrightserves/homegames/blob/main/public/js/main.js"
click node_renderer "https://github.com/trewrightserves/homegames/blob/main/public/js/render/Render.js"
click node_localplayer "https://github.com/trewrightserves/homegames/blob/main/public/js/player/Player.js"
click node_physics "https://github.com/trewrightserves/homegames/blob/main/public/js/physics/Physics.js"
click node_worldmgr "https://github.com/trewrightserves/homegames/blob/main/public/js/world/World.js"
click node_network "https://github.com/trewrightserves/homegames/blob/main/public/js/network/Network.js"
click node_server "https://github.com/trewrightserves/homegames/blob/main/server.js"
click node_chat "https://github.com/trewrightserves/homegames/blob/main/public/js/chat/Chat.js"
click node_inventory "https://github.com/trewrightserves/homegames/blob/main/public/js/player/Inventory.js"
click node_items "https://github.com/trewrightserves/homegames/blob/main/public/js/data/ItemRegistry.js"
click node_serverworld "https://github.com/trewrightserves/homegames/blob/main/server.js"
click node_serverplayers "https://github.com/trewrightserves/homegames/blob/main/server.js"
click node_servergameplay "https://github.com/trewrightserves/homegames/blob/main/server.js"

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_renderer,node_localplayer toneBlue
class node_physics,node_worldmgr,node_serverworld toneAmber
class node_network,node_server,node_serverplayers toneMint
class node_chat,node_inventory,node_items,node_servergameplay toneRose
class node_player toneIndigo
```

## Components

### Browser Client

- [Client coordinator](https://github.com/trewrightserves/homegames/blob/main/public/js/main.js): `public/js/main.js`
- [Voxel renderer](https://github.com/trewrightserves/homegames/blob/main/public/js/render/Render.js): `public/js/render/Render.js`
- [Input and controls](https://github.com/trewrightserves/homegames/blob/main/public/js/player/Player.js): `public/js/player/Player.js`

### World Simulation

- [Movement physics](https://github.com/trewrightserves/homegames/blob/main/public/js/physics/Physics.js): `public/js/physics/Physics.js`
- [Chunk world](https://github.com/trewrightserves/homegames/blob/main/public/js/world/World.js): `public/js/world/World.js`
- [Authoritative world](https://github.com/trewrightserves/homegames/blob/main/server.js): `server.js`

### Multiplayer Services

- [Socket client](https://github.com/trewrightserves/homegames/blob/main/public/js/network/Network.js): `public/js/network/Network.js`
- [HTTP and game server](https://github.com/trewrightserves/homegames/blob/main/server.js): `server.js`
- [Player sync and commands](https://github.com/trewrightserves/homegames/blob/main/server.js): `server.js`

### Player Features

- [Chat console](https://github.com/trewrightserves/homegames/blob/main/public/js/chat/Chat.js): `public/js/chat/Chat.js`
- [Inventory and crafting UI](https://github.com/trewrightserves/homegames/blob/main/public/js/player/Inventory.js): `public/js/player/Inventory.js`
- [Item registry](https://github.com/trewrightserves/homegames/blob/main/public/js/data/ItemRegistry.js): `public/js/data/ItemRegistry.js`
- [Items, entities, quests](https://github.com/trewrightserves/homegames/blob/main/server.js): `server.js`

### Other components

- **LAN player**

## Connections

- LAN player → Client coordinator: opens client
- Client coordinator → Input and controls: creates controls
- Client coordinator → Chunk world: creates world
- Client coordinator → Movement physics: creates physics
- Client coordinator → Voxel renderer: creates renderer
- Client coordinator → Socket client: creates client
- Client coordinator → Chat console: creates console
- Client coordinator → Inventory and crafting UI: creates UI
- Movement physics → Chunk world: checks collisions
- Voxel renderer → Chunk world: renders chunks
- Inventory and crafting UI → Item registry: reads item data
- Client coordinator → Item registry: maps hotbar items
- Socket client → HTTP and game server: exchanges socket events
- HTTP and game server → Authoritative world: generates and reads chunks
- HTTP and game server → Player sync and commands: handles player updates and commands
- HTTP and game server → Items, entities, quests: handles crafting and interactions
- Chat console → Client coordinator: submits chat
- Inventory and crafting UI → Socket client: sends craft requests
- Authoritative world → Socket client: sends world state
- Player sync and commands → Socket client: sends player and command events
- Items, entities, quests → Socket client: sends gameplay events
