# ahcej/simple-game architecture

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

- Interactive diagram: https://gitdiagram.com/ahcej/simple-game
- Repository: https://github.com/ahcej/simple-game

## Overview

This is a small browser-based multiplayer RPG: players use a canvas client, connect over WebSockets, and receive world and personal state while sending movement, action, and chat input. The server session translates those messages into calls on a shared, tick-driven world that maintains players, mobs, NPCs, quests, and chat. The excerpts establish server-side wiring and game-state responsibilities; the client’s complete connection and message flow is not shown, so those links are left unverified.

Main entry points: [`Games/Program.cs`](https://github.com/ahcej/simple-game/blob/main/Games/Program.cs) (WebSocket route), [`Games/Game/World.cs`](https://github.com/ahcej/simple-game/blob/main/Games/Game/World.cs) (World simulation), [`Games/Game/Session.cs`](https://github.com/ahcej/simple-game/blob/main/Games/Game/Session.cs) (Player session), [`Games/wwwroot/mmo.js`](https://github.com/ahcej/simple-game/blob/main/Games/wwwroot/mmo.js) (Canvas client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Browser client"]
  node_client_ui["Canvas client<br/>[mmo.js]"]
end

subgraph group_server["WebSocket server"]
  node_ws_route["WebSocket route<br/>[Program.cs]"]
  node_session["Player session<br/>[Session.cs]"]
end

subgraph group_game["Game runtime"]
  node_world["World simulation<br/>[World.cs]"]
  node_entities["Game entities<br/>[Entities.cs]"]
end

subgraph group_contracts["Game contracts"]
  node_protocol["Message contracts<br/>[Protocol.cs]"]
end

node_player(("Player"))

node_player -->|"plays through"| node_client_ui
node_client_ui -.->|"exchanges messages"| node_ws_route
node_ws_route -->|"adds player"| node_world
node_ws_route -->|"runs session"| node_session
node_ws_route -->|"starts and stops"| node_world
node_session -->|"reads and updates"| node_world
node_session -->|"serializes messages"| node_protocol
node_world -->|"uses game state"| node_entities

click node_client_ui "https://github.com/ahcej/simple-game/blob/main/Games/wwwroot/mmo.js"
click node_ws_route "https://github.com/ahcej/simple-game/blob/main/Games/Program.cs"
click node_session "https://github.com/ahcej/simple-game/blob/main/Games/Game/Session.cs"
click node_world "https://github.com/ahcej/simple-game/blob/main/Games/Game/World.cs"
click node_entities "https://github.com/ahcej/simple-game/blob/main/Games/Game/Entities.cs"
click node_protocol "https://github.com/ahcej/simple-game/blob/main/Games/Game/Protocol.cs"

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_client_ui toneBlue
class node_ws_route,node_session toneAmber
class node_world,node_entities toneMint
class node_protocol toneRose
class node_player toneIndigo
```

## Components

### Browser client

- [Canvas client](https://github.com/ahcej/simple-game/blob/main/Games/wwwroot/mmo.js): `Games/wwwroot/mmo.js`

### WebSocket server

- [WebSocket route](https://github.com/ahcej/simple-game/blob/main/Games/Program.cs): `Games/Program.cs`
- [Player session](https://github.com/ahcej/simple-game/blob/main/Games/Game/Session.cs): `Games/Game/Session.cs`

### Game runtime

- [World simulation](https://github.com/ahcej/simple-game/blob/main/Games/Game/World.cs): `Games/Game/World.cs`
- [Game entities](https://github.com/ahcej/simple-game/blob/main/Games/Game/Entities.cs): `Games/Game/Entities.cs`

### Game contracts

- [Message contracts](https://github.com/ahcej/simple-game/blob/main/Games/Game/Protocol.cs): `Games/Game/Protocol.cs`

### Other components

- **Player**

## Connections

- Player → Canvas client: plays through (evidence: `Games/wwwroot/mmo.js`)
- Canvas client → WebSocket route: exchanges messages
- WebSocket route → World simulation: adds player (evidence: `Games/Program.cs`)
- WebSocket route → Player session: runs session (evidence: `Games/Program.cs`)
- WebSocket route → World simulation: starts and stops (evidence: `Games/Program.cs`)
- Player session → World simulation: reads and updates (evidence: `Games/Game/Session.cs`)
- Player session → Message contracts: serializes messages (evidence: `Games/Game/Session.cs`)
- World simulation → Game entities: uses game state (evidence: `Games/Game/World.cs`)
