# algis99/tron architecture

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

- Interactive diagram: https://gitdiagram.com/algis99/tron
- Repository: https://github.com/algis99/tron

## Overview

This is a first-draft multiplayer Tron game: a player connects, receives an initial game state, issues serialized commands, and receives state updates for rendering. The backend manages connections and a game session that parses commands and applies actions to a world; shared protocol and structures support the client/server exchange. The README mentions shooting, though it describes it as a TODO; the action/parser and client command modules indicate partial shooting support. Some runtime links are based on the SOURCE INDEX rather than sampled implementation excerpts.

Main entry points: [`frontend/src/Client.cs`](https://github.com/algis99/tron/blob/main/frontend/src/Client.cs) (Client), [`backend/src/session/GameSession.cs`](https://github.com/algis99/tron/blob/main/backend/src/session/GameSession.cs) (Game Session), [`shared/src/structures`](https://github.com/algis99/tron/tree/main/shared/src/structures) (Shared State Models), [`frontend/src/manager/GameManager.cs`](https://github.com/algis99/tron/blob/main/frontend/src/manager/GameManager.cs) (Game Manager)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Player Client"]
  node_client_app["Client<br/>[Client.cs]"]
  node_manager["Game Manager<br/>[GameManager.cs]"]
  node_client_game["Client Game<br/>[Game.cs]"]
  node_commands["Commands<br/>[Command.cs]"]
  node_serializer["Command Serializer"]
  node_renderer["Renderer<br/>[Renderer.cs]"]
  node_drawers["Grid Drawers<br/>[GridDrawer.cs]"]
end

subgraph group_backend["Game Server"]
  node_server["Server<br/>[Server.cs]"]
  node_session["Game Session<br/>[GameSession.cs]"]
  node_lexer["Command Lexer<br/>[Lexer.cs]"]
  node_parser["Command Parser<br/>[Parser.cs]"]
end

subgraph group_shared["Shared Runtime"]
  node_connection["Client Connection"]
  node_packet_sender["Packet Sender<br/>[PacketSender.cs]"]
  node_packet_receiver["Packet Receiver<br/>[PacketReceiver.cs]"]
  node_models["Shared State Models"]
  node_thread_queue["Thread-Safe Queue<br/>[ThreadSafeQueue.cs]"]
end

subgraph group_domain["Game Domain"]
  node_game["Game Engine<br/>[Game.cs]"]
  node_world["World<br/>[World.cs]"]
  node_player_state["Player State<br/>[Player.cs]"]
  node_actions["Game Actions<br/>[GameAction.cs]"]
  node_results["Action Results"]
end

node_player(("Player"))

node_player -->|"starts"| node_client_app
node_client_app -->|"creates"| node_manager
node_client_app -->|"receives state"| node_packet_receiver
node_client_app -->|"sends commands"| node_packet_sender
node_client_app -->|"exchanges state"| node_models
node_manager -->|"runs and updates"| node_client_game
node_manager -->|"serializes commands"| node_serializer
node_manager -->|"uses queue"| node_thread_queue
node_client_game -->|"renders"| node_renderer
node_client_game -->|"creates"| node_commands
node_client_game -->|"queues commands"| node_thread_queue
node_renderer -->|"delegates drawing"| node_drawers
node_renderer -->|"renders state"| node_models
node_server -->|"runs session"| node_session
node_server -->|"manages connections"| node_connection
node_server -->|"broadcasts state"| node_models
node_session -->|"tokenizes commands"| node_lexer
node_session -->|"parses commands"| node_parser
node_session -->|"submits actions"| node_game
node_session -->|"returns game state"| node_models
node_parser -->|"creates actions"| node_actions
node_game -->|"updates world"| node_world
node_game -->|"dispatches actions"| node_actions
node_game -->|"produces results"| node_results
node_world -->|"tracks players"| node_player_state
node_world -->|"uses grid and positions"| node_models
node_connection -->|"sends packets"| node_packet_sender
node_connection -->|"receives packets"| node_packet_receiver

click node_client_app "https://github.com/algis99/tron/blob/main/frontend/src/Client.cs"
click node_manager "https://github.com/algis99/tron/blob/main/frontend/src/manager/GameManager.cs"
click node_client_game "https://github.com/algis99/tron/blob/main/frontend/src/game/Game.cs"
click node_commands "https://github.com/algis99/tron/blob/main/frontend/src/commands/Command.cs"
click node_serializer "https://github.com/algis99/tron/blob/main/frontend/src/serializer/CommandSerializer.cs"
click node_renderer "https://github.com/algis99/tron/blob/main/frontend/src/game/Renderer.cs"
click node_drawers "https://github.com/algis99/tron/blob/main/frontend/src/drawers/GridDrawer.cs"
click node_server "https://github.com/algis99/tron/blob/main/backend/src/Server.cs"
click node_session "https://github.com/algis99/tron/blob/main/backend/src/session/GameSession.cs"
click node_lexer "https://github.com/algis99/tron/blob/main/backend/src/parser/Lexer.cs"
click node_parser "https://github.com/algis99/tron/blob/main/backend/src/parser/Parser.cs"
click node_game "https://github.com/algis99/tron/blob/main/backend/src/game/Game.cs"
click node_world "https://github.com/algis99/tron/blob/main/backend/src/game/World.cs"
click node_player_state "https://github.com/algis99/tron/blob/main/backend/src/game/Player.cs"
click node_actions "https://github.com/algis99/tron/blob/main/backend/src/actions/GameAction.cs"
click node_results "https://github.com/algis99/tron/blob/main/backend/src/results/GameActionResult.cs"
click node_connection "https://github.com/algis99/tron/blob/main/shared/src/protocol/ClientConnection.cs"
click node_packet_sender "https://github.com/algis99/tron/blob/main/shared/src/protocol/PacketSender.cs"
click node_packet_receiver "https://github.com/algis99/tron/blob/main/shared/src/protocol/PacketReceiver.cs"
click node_models "https://github.com/algis99/tron/tree/main/shared/src/structures"
click node_thread_queue "https://github.com/algis99/tron/blob/main/shared/src/queue/ThreadSafeQueue.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_app,node_manager,node_client_game,node_commands,node_serializer,node_renderer,node_drawers toneBlue
class node_server,node_session,node_lexer,node_parser toneAmber
class node_connection,node_packet_sender,node_packet_receiver,node_models,node_thread_queue toneMint
class node_game,node_world,node_player_state,node_actions,node_results toneRose
class node_player toneIndigo
```

## Components

### Player Client

- [Client](https://github.com/algis99/tron/blob/main/frontend/src/Client.cs): `frontend/src/Client.cs`
- [Game Manager](https://github.com/algis99/tron/blob/main/frontend/src/manager/GameManager.cs): `frontend/src/manager/GameManager.cs`
- [Client Game](https://github.com/algis99/tron/blob/main/frontend/src/game/Game.cs): `frontend/src/game/Game.cs`
- [Commands](https://github.com/algis99/tron/blob/main/frontend/src/commands/Command.cs): `frontend/src/commands/Command.cs`
- [Command Serializer](https://github.com/algis99/tron/blob/main/frontend/src/serializer/CommandSerializer.cs): `frontend/src/serializer/CommandSerializer.cs`
- [Renderer](https://github.com/algis99/tron/blob/main/frontend/src/game/Renderer.cs): `frontend/src/game/Renderer.cs`
- [Grid Drawers](https://github.com/algis99/tron/blob/main/frontend/src/drawers/GridDrawer.cs): `frontend/src/drawers/GridDrawer.cs`

### Game Server

- [Server](https://github.com/algis99/tron/blob/main/backend/src/Server.cs): `backend/src/Server.cs`
- [Game Session](https://github.com/algis99/tron/blob/main/backend/src/session/GameSession.cs): `backend/src/session/GameSession.cs`
- [Command Lexer](https://github.com/algis99/tron/blob/main/backend/src/parser/Lexer.cs): `backend/src/parser/Lexer.cs`
- [Command Parser](https://github.com/algis99/tron/blob/main/backend/src/parser/Parser.cs): `backend/src/parser/Parser.cs`

### Shared Runtime

- [Client Connection](https://github.com/algis99/tron/blob/main/shared/src/protocol/ClientConnection.cs): `shared/src/protocol/ClientConnection.cs`
- [Packet Sender](https://github.com/algis99/tron/blob/main/shared/src/protocol/PacketSender.cs): `shared/src/protocol/PacketSender.cs`
- [Packet Receiver](https://github.com/algis99/tron/blob/main/shared/src/protocol/PacketReceiver.cs): `shared/src/protocol/PacketReceiver.cs`
- [Shared State Models](https://github.com/algis99/tron/tree/main/shared/src/structures): `shared/src/structures`
- [Thread-Safe Queue](https://github.com/algis99/tron/blob/main/shared/src/queue/ThreadSafeQueue.cs): `shared/src/queue/ThreadSafeQueue.cs`

### Game Domain

- [Game Engine](https://github.com/algis99/tron/blob/main/backend/src/game/Game.cs): `backend/src/game/Game.cs`
- [World](https://github.com/algis99/tron/blob/main/backend/src/game/World.cs): `backend/src/game/World.cs`
- [Player State](https://github.com/algis99/tron/blob/main/backend/src/game/Player.cs): `backend/src/game/Player.cs`
- [Game Actions](https://github.com/algis99/tron/blob/main/backend/src/actions/GameAction.cs): `backend/src/actions/GameAction.cs`
- [Action Results](https://github.com/algis99/tron/blob/main/backend/src/results/GameActionResult.cs): `backend/src/results/GameActionResult.cs`

### Other components

- **Player**

## Connections

- Player → Client: starts
- Client → Game Manager: creates (evidence: `frontend/src/Client.cs`)
- Client → Packet Receiver: receives state (evidence: `frontend/src/Client.cs`)
- Client → Packet Sender: sends commands (evidence: `frontend/src/Client.cs`)
- Client → Shared State Models: exchanges state (evidence: `frontend/src/Client.cs`)
- Game Manager → Client Game: runs and updates (evidence: `frontend/src/manager/GameManager.cs`)
- Game Manager → Command Serializer: serializes commands (evidence: `frontend/src/manager/GameManager.cs`)
- Game Manager → Thread-Safe Queue: uses queue
- Client Game → Renderer: renders (evidence: `frontend/src/game/Game.cs`)
- Client Game → Commands: creates (evidence: `frontend/src/game/Game.cs`)
- Client Game → Thread-Safe Queue: queues commands
- Renderer → Grid Drawers: delegates drawing (evidence: `frontend/src/game/Renderer.cs`)
- Renderer → Shared State Models: renders state (evidence: `frontend/src/game/Renderer.cs`)
- Server → Game Session: runs session (evidence: `backend/src/Server.cs`)
- Server → Client Connection: manages connections (evidence: `backend/src/Server.cs`)
- Server → Shared State Models: broadcasts state (evidence: `backend/src/Server.cs`)
- Game Session → Command Lexer: tokenizes commands (evidence: `backend/src/session/GameSession.cs`)
- Game Session → Command Parser: parses commands (evidence: `backend/src/session/GameSession.cs`)
- Game Session → Game Engine: submits actions (evidence: `backend/src/session/GameSession.cs`)
- Game Session → Shared State Models: returns game state (evidence: `backend/src/session/GameSession.cs`)
- Command Parser → Game Actions: creates actions (evidence: `backend/src/parser/Parser.cs`)
- Game Engine → World: updates world (evidence: `backend/src/game/Game.cs`)
- Game Engine → Game Actions: dispatches actions (evidence: `backend/src/game/Game.cs`)
- Game Engine → Action Results: produces results (evidence: `backend/src/game/Game.cs`)
- World → Player State: tracks players (evidence: `backend/src/game/World.cs`)
- World → Shared State Models: uses grid and positions (evidence: `backend/src/game/World.cs`)
- Client Connection → Packet Sender: sends packets (evidence: `shared/src/protocol/ClientConnection.cs`)
- Client Connection → Packet Receiver: receives packets (evidence: `shared/src/protocol/ClientConnection.cs`)
