# nathanndasilva/carcassonne-multiplayer architecture

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

- Interactive diagram: https://gitdiagram.com/nathanndasilva/carcassonne-multiplayer
- Repository: https://github.com/nathanndasilva/carcassonne-multiplayer

## Overview

Carcassonne Multiplayer Web is a real-time, up-to-six-player web board game with online rooms, local play, bots, chat, and a shared rules engine. Players join or create a lobby, start a match, draw and place tiles, optionally place meeples, score features, and see final standings; server events synchronize online games. The graph preserves the documented visual board, HUD, and synthesized audio capabilities. Evidence is limited to README statements and indexed excerpts; unsampled subsystem links are omitted where the caller is not shown.

Main entry points: [`client/src/store/gameStore.ts`](https://github.com/nathanndasilva/carcassonne-multiplayer/blob/main/client/src/store/gameStore.ts) (Client game state), [`client/src/socket/socketClient.ts`](https://github.com/nathanndasilva/carcassonne-multiplayer/blob/main/client/src/socket/socketClient.ts) (Socket client), [`client/src/App.tsx`](https://github.com/nathanndasilva/carcassonne-multiplayer/blob/main/client/src/App.tsx) (Application shell), [`client/src/components/Board/GameBoard.tsx`](https://github.com/nathanndasilva/carcassonne-multiplayer/blob/main/client/src/components/Board/GameBoard.tsx) (Interactive board)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Game client"]
  node_app["Application shell<br/>[App.tsx]"]
  node_lobby["Room lobby<br/>[RoomLobby.tsx]"]
  node_board["Interactive board<br/>[GameBoard.tsx]"]
  node_chat["Game chat<br/>[ChatDrawer.tsx]"]
  node_store["Client game state<br/>[gameStore.ts]"]
  node_socketclient["Socket client<br/>[socketClient.ts]"]
end

subgraph group_server["Realtime server"]
  node_socketserver["Socket server<br/>[index.ts]"]
  node_rooms["Room and turn manager<br/>[roomManager.ts]"]
end

subgraph group_rules["Game rules"]
  node_bot["Bot decisions<br/>[bot.ts]"]
  node_engine["Rules and scoring engine<br/>[engine.ts]"]
  node_deck["Tile deck<br/>[tileDeck.ts]"]
  node_types["Game domain types<br/>[types.ts]"]
end

subgraph group_experience["Game presentation"]
  node_hud["Game HUD"]
  node_tileview["Tile and meeple SVG<br/>[TileSVG.tsx]"]
  node_gameover["Results and menu<br/>[GameOverModal.tsx]"]
  node_audio["Synthesized audio<br/>[audioEffects.ts]"]
end

node_player(("Players"))
node_network["Socket.io transport"]
node_browser(("Web browser"))

node_player -->|"joins or configures"| node_lobby
node_app -->|"shows before game"| node_lobby
node_app -->|"shows during game"| node_board
node_app -->|"shows game panels"| node_hud
node_app -->|"shows chat"| node_chat
node_app -->|"shows results"| node_gameover
node_lobby -->|"emits room actions"| node_socketclient
node_lobby -.->|"updates local game"| node_store
node_board -->|"reads and updates"| node_store
node_board -->|"checks placements"| node_engine
node_board -->|"submits tile moves"| node_socketclient
node_board -->|"renders tiles"| node_tileview
node_hud -->|"reads game state"| node_store
node_hud -->|"renders meeples"| node_tileview
node_chat -->|"sends messages"| node_socketclient
node_chat -->|"reads messages"| node_store
node_gameover -->|"reads final state"| node_store
node_socketclient -->|"applies server events"| node_store
node_store -->|"plays turn and score cues"| node_audio
node_browser -.->|"runs connection"| node_socketclient
node_socketclient -->|"exchanges events"| node_network
node_network -->|"delivers events"| node_socketserver
node_socketserver -->|"handles room actions"| node_rooms
node_socketserver -->|"requests bot move"| node_bot
node_rooms -->|"validates and scores"| node_engine
node_bot -->|"evaluates candidate moves"| node_engine
node_engine -.->|"uses tile definitions"| node_deck
node_socketserver -.->|"broadcasts game updates"| node_network
node_rooms -.->|"uses game state types"| node_types
node_engine -.->|"uses domain types"| node_types

click node_app "https://github.com/nathanndasilva/carcassonne-multiplayer/blob/main/client/src/App.tsx"
click node_lobby "https://github.com/nathanndasilva/carcassonne-multiplayer/blob/main/client/src/components/Lobby/RoomLobby.tsx"
click node_board "https://github.com/nathanndasilva/carcassonne-multiplayer/blob/main/client/src/components/Board/GameBoard.tsx"
click node_hud "https://github.com/nathanndasilva/carcassonne-multiplayer/tree/main/client/src/components/HUD"
click node_tileview "https://github.com/nathanndasilva/carcassonne-multiplayer/blob/main/client/src/components/TileRenderer/TileSVG.tsx"
click node_chat "https://github.com/nathanndasilva/carcassonne-multiplayer/blob/main/client/src/components/Chat/ChatDrawer.tsx"
click node_gameover "https://github.com/nathanndasilva/carcassonne-multiplayer/blob/main/client/src/components/Modals/GameOverModal.tsx"
click node_store "https://github.com/nathanndasilva/carcassonne-multiplayer/blob/main/client/src/store/gameStore.ts"
click node_socketclient "https://github.com/nathanndasilva/carcassonne-multiplayer/blob/main/client/src/socket/socketClient.ts"
click node_audio "https://github.com/nathanndasilva/carcassonne-multiplayer/blob/main/client/src/sound/audioEffects.ts"
click node_socketserver "https://github.com/nathanndasilva/carcassonne-multiplayer/blob/main/server/index.ts"
click node_rooms "https://github.com/nathanndasilva/carcassonne-multiplayer/blob/main/server/roomManager.ts"
click node_bot "https://github.com/nathanndasilva/carcassonne-multiplayer/blob/main/shared/bot.ts"
click node_engine "https://github.com/nathanndasilva/carcassonne-multiplayer/blob/main/shared/engine.ts"
click node_deck "https://github.com/nathanndasilva/carcassonne-multiplayer/blob/main/shared/tileDeck.ts"
click node_types "https://github.com/nathanndasilva/carcassonne-multiplayer/blob/main/shared/types.ts"

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_app,node_lobby,node_board,node_chat,node_store,node_socketclient,node_browser toneBlue
class node_socketserver,node_rooms toneAmber
class node_bot,node_engine,node_deck,node_types toneMint
class node_hud,node_tileview,node_gameover,node_audio toneRose
class node_player,node_network toneIndigo
```

## Components

### Game client

- [Application shell](https://github.com/nathanndasilva/carcassonne-multiplayer/blob/main/client/src/App.tsx): `client/src/App.tsx`
- [Room lobby](https://github.com/nathanndasilva/carcassonne-multiplayer/blob/main/client/src/components/Lobby/RoomLobby.tsx): `client/src/components/Lobby/RoomLobby.tsx`
- [Interactive board](https://github.com/nathanndasilva/carcassonne-multiplayer/blob/main/client/src/components/Board/GameBoard.tsx): `client/src/components/Board/GameBoard.tsx`
- [Game chat](https://github.com/nathanndasilva/carcassonne-multiplayer/blob/main/client/src/components/Chat/ChatDrawer.tsx): `client/src/components/Chat/ChatDrawer.tsx`
- [Client game state](https://github.com/nathanndasilva/carcassonne-multiplayer/blob/main/client/src/store/gameStore.ts): `client/src/store/gameStore.ts`
- [Socket client](https://github.com/nathanndasilva/carcassonne-multiplayer/blob/main/client/src/socket/socketClient.ts): `client/src/socket/socketClient.ts`

### Realtime server

- [Socket server](https://github.com/nathanndasilva/carcassonne-multiplayer/blob/main/server/index.ts): `server/index.ts`
- [Room and turn manager](https://github.com/nathanndasilva/carcassonne-multiplayer/blob/main/server/roomManager.ts): `server/roomManager.ts`

### Game rules

- [Bot decisions](https://github.com/nathanndasilva/carcassonne-multiplayer/blob/main/shared/bot.ts): `shared/bot.ts`
- [Rules and scoring engine](https://github.com/nathanndasilva/carcassonne-multiplayer/blob/main/shared/engine.ts): `shared/engine.ts`
- [Tile deck](https://github.com/nathanndasilva/carcassonne-multiplayer/blob/main/shared/tileDeck.ts): `shared/tileDeck.ts`
- [Game domain types](https://github.com/nathanndasilva/carcassonne-multiplayer/blob/main/shared/types.ts): `shared/types.ts`

### Game presentation

- [Game HUD](https://github.com/nathanndasilva/carcassonne-multiplayer/tree/main/client/src/components/HUD): `client/src/components/HUD`
- [Tile and meeple SVG](https://github.com/nathanndasilva/carcassonne-multiplayer/blob/main/client/src/components/TileRenderer/TileSVG.tsx): `client/src/components/TileRenderer/TileSVG.tsx`
- [Results and menu](https://github.com/nathanndasilva/carcassonne-multiplayer/blob/main/client/src/components/Modals/GameOverModal.tsx): `client/src/components/Modals/GameOverModal.tsx`
- [Synthesized audio](https://github.com/nathanndasilva/carcassonne-multiplayer/blob/main/client/src/sound/audioEffects.ts): `client/src/sound/audioEffects.ts`

### Other components

- **Players**
- **Socket.io transport**
- **Web browser**

## Connections

- Players → Room lobby: joins or configures (evidence: `README.md`)
- Application shell → Room lobby: shows before game (evidence: `client/src/App.tsx`)
- Application shell → Interactive board: shows during game (evidence: `client/src/App.tsx`)
- Application shell → Game HUD: shows game panels (evidence: `client/src/App.tsx`)
- Application shell → Game chat: shows chat (evidence: `client/src/App.tsx`)
- Application shell → Results and menu: shows results (evidence: `client/src/App.tsx`)
- Room lobby → Socket client: emits room actions (evidence: `client/src/components/Lobby/RoomLobby.tsx`)
- Room lobby → Client game state: updates local game (evidence: `client/src/components/Lobby/RoomLobby.tsx`)
- Interactive board → Client game state: reads and updates (evidence: `client/src/components/Board/GameBoard.tsx`)
- Interactive board → Rules and scoring engine: checks placements (evidence: `client/src/components/Board/GameBoard.tsx`)
- Interactive board → Socket client: submits tile moves (evidence: `client/src/components/Board/GameBoard.tsx`)
- Interactive board → Tile and meeple SVG: renders tiles (evidence: `client/src/components/Board/GameBoard.tsx`)
- Game HUD → Client game state: reads game state (evidence: `client/src/components/HUD/PlayerScoreboard.tsx`)
- Game HUD → Tile and meeple SVG: renders meeples (evidence: `client/src/components/HUD/PlayerScoreboard.tsx`)
- Game chat → Socket client: sends messages (evidence: `client/src/components/Chat/ChatDrawer.tsx`)
- Game chat → Client game state: reads messages (evidence: `client/src/components/Chat/ChatDrawer.tsx`)
- Results and menu → Client game state: reads final state (evidence: `client/src/components/Modals/GameOverModal.tsx`)
- Socket client → Client game state: applies server events (evidence: `client/src/socket/socketClient.ts`)
- Client game state → Synthesized audio: plays turn and score cues (evidence: `client/src/store/gameStore.ts`)
- Web browser → Socket client: runs connection
- Socket client → Socket.io transport: exchanges events (evidence: `client/src/socket/socketClient.ts`)
- Socket.io transport → Socket server: delivers events (evidence: `README.md`)
- Socket server → Room and turn manager: handles room actions (evidence: `server/index.ts`)
- Socket server → Bot decisions: requests bot move (evidence: `server/index.ts`)
- Room and turn manager → Rules and scoring engine: validates and scores (evidence: `server/roomManager.ts`)
- Bot decisions → Rules and scoring engine: evaluates candidate moves (evidence: `shared/bot.ts`)
- Rules and scoring engine → Tile deck: uses tile definitions (evidence: `shared/engine.ts`)
- Socket server → Socket.io transport: broadcasts game updates
- Room and turn manager → Game domain types: uses game state types (evidence: `server/roomManager.ts`)
- Rules and scoring engine → Game domain types: uses domain types (evidence: `shared/engine.ts`)
