# mattmathbg/pendu_reseaux architecture

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

- Interactive diagram: https://gitdiagram.com/mattmathbg/pendu_reseaux
- Repository: https://github.com/mattmathbg/pendu_reseaux

## Overview

Pendu Réseau is a TCP client-server hangman game: a player uses the GUI or CLI, the client sends framed JSON requests, and the authoritative server manages the session and game rules before returning state or errors. The README documents concurrent clients, reconnect/resume, and idempotent retries. The graph includes both client interfaces and the protocol, session, and game layers. Relationships are limited to excerpted calls, SOURCE INDEX references, or README statements; unsampled capabilities are not expanded beyond documented links.

Main entry points: [`server/server.py`](https://github.com/mattmathbg/pendu_reseaux/blob/main/server/server.py) (TCP Server), [`client/connection.py`](https://github.com/mattmathbg/pendu_reseaux/blob/main/client/connection.py) (Game Client), [`core/session.py`](https://github.com/mattmathbg/pendu_reseaux/blob/main/core/session.py) (Session Manager), [`protocol/message.py`](https://github.com/mattmathbg/pendu_reseaux/blob/main/protocol/message.py) (JSON Messages)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["Player Clients"]
  node_gui["GUI<br/>[gui.py]"]
  node_cli["CLI<br/>[cli.py]"]
  node_client["Game Client<br/>[connection.py]"]
  node_saved_session["Saved Session<br/>[session.json]"]
end

subgraph group_wire["Wire Protocol"]
  node_framing["Stream Framing<br/>[framing.py]"]
  node_message["JSON Messages<br/>[message.py]"]
end

subgraph group_server["Server Runtime"]
  node_tcp_server["TCP Server<br/>[server.py]"]
  node_dispatcher["Message Dispatcher<br/>[dispatcher.py]"]
  node_sessions["Session Manager<br/>[session.py]"]
  node_handlers["Game Request Handlers<br/>[server.py]"]
end

subgraph group_game["Game Domain"]
  node_pendu["Hangman Engine<br/>[pendu.py]"]
  node_game_errors["Game Exceptions<br/>[exceptions.py]"]
end

node_player(("Player"))

node_player -->|"plays through"| node_gui
node_player -->|"plays through"| node_cli
node_gui -->|"calls"| node_client
node_cli -->|"calls"| node_client
node_client -->|"frames traffic"| node_framing
node_client -->|"serializes messages"| node_message
node_client -->|"saves session"| node_saved_session
node_client -->|"sends TCP requests"| node_tcp_server
node_tcp_server -->|"frames traffic"| node_framing
node_tcp_server -->|"parses messages"| node_message
node_tcp_server -->|"dispatches requests"| node_dispatcher
node_tcp_server -->|"manages sessions"| node_sessions
node_tcp_server -->|"registers handlers"| node_handlers
node_dispatcher -->|"accepts messages"| node_message
node_dispatcher -->|"accepts session"| node_sessions
node_handlers -->|"creates and resumes"| node_sessions
node_handlers -->|"starts and updates"| node_pendu
node_sessions -->|"holds game state"| node_pendu
node_sessions -->|"caches responses"| node_message
node_pendu -->|"raises errors"| node_game_errors

click node_gui "https://github.com/mattmathbg/pendu_reseaux/blob/main/client/gui.py"
click node_cli "https://github.com/mattmathbg/pendu_reseaux/blob/main/client/cli.py"
click node_client "https://github.com/mattmathbg/pendu_reseaux/blob/main/client/connection.py"
click node_saved_session "https://github.com/mattmathbg/pendu_reseaux/blob/main/session.json"
click node_framing "https://github.com/mattmathbg/pendu_reseaux/blob/main/protocol/framing.py"
click node_message "https://github.com/mattmathbg/pendu_reseaux/blob/main/protocol/message.py"
click node_tcp_server "https://github.com/mattmathbg/pendu_reseaux/blob/main/server/server.py"
click node_dispatcher "https://github.com/mattmathbg/pendu_reseaux/blob/main/server/dispatcher.py"
click node_sessions "https://github.com/mattmathbg/pendu_reseaux/blob/main/core/session.py"
click node_handlers "https://github.com/mattmathbg/pendu_reseaux/blob/main/server/server.py"
click node_pendu "https://github.com/mattmathbg/pendu_reseaux/blob/main/core/pendu.py"
click node_game_errors "https://github.com/mattmathbg/pendu_reseaux/blob/main/core/exceptions.py"

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_gui,node_cli,node_client,node_saved_session toneBlue
class node_framing,node_message toneAmber
class node_tcp_server,node_dispatcher,node_sessions,node_handlers toneMint
class node_pendu,node_game_errors toneRose
class node_player toneIndigo
```

## Components

### Player Clients

- [GUI](https://github.com/mattmathbg/pendu_reseaux/blob/main/client/gui.py): `client/gui.py`
- [CLI](https://github.com/mattmathbg/pendu_reseaux/blob/main/client/cli.py): `client/cli.py`
- [Game Client](https://github.com/mattmathbg/pendu_reseaux/blob/main/client/connection.py): `client/connection.py`
- [Saved Session](https://github.com/mattmathbg/pendu_reseaux/blob/main/session.json): `session.json`

### Wire Protocol

- [Stream Framing](https://github.com/mattmathbg/pendu_reseaux/blob/main/protocol/framing.py): `protocol/framing.py`
- [JSON Messages](https://github.com/mattmathbg/pendu_reseaux/blob/main/protocol/message.py): `protocol/message.py`

### Server Runtime

- [TCP Server](https://github.com/mattmathbg/pendu_reseaux/blob/main/server/server.py): `server/server.py`
- [Message Dispatcher](https://github.com/mattmathbg/pendu_reseaux/blob/main/server/dispatcher.py): `server/dispatcher.py`
- [Session Manager](https://github.com/mattmathbg/pendu_reseaux/blob/main/core/session.py): `core/session.py`
- [Game Request Handlers](https://github.com/mattmathbg/pendu_reseaux/blob/main/server/server.py): `server/server.py`

### Game Domain

- [Hangman Engine](https://github.com/mattmathbg/pendu_reseaux/blob/main/core/pendu.py): `core/pendu.py`
- [Game Exceptions](https://github.com/mattmathbg/pendu_reseaux/blob/main/core/exceptions.py): `core/exceptions.py`

### Other components

- **Player**

## Connections

- Player → GUI: plays through (evidence: `readme.md`)
- Player → CLI: plays through (evidence: `readme.md`)
- GUI → Game Client: calls (evidence: `client/gui.py`)
- CLI → Game Client: calls (evidence: `client/cli.py`)
- Game Client → Stream Framing: frames traffic (evidence: `client/connection.py`)
- Game Client → JSON Messages: serializes messages (evidence: `client/connection.py`)
- Game Client → Saved Session: saves session (evidence: `client/connection.py`)
- Game Client → TCP Server: sends TCP requests (evidence: `readme.md`)
- TCP Server → Stream Framing: frames traffic (evidence: `server/server.py`)
- TCP Server → JSON Messages: parses messages (evidence: `server/server.py`)
- TCP Server → Message Dispatcher: dispatches requests (evidence: `server/server.py`)
- TCP Server → Session Manager: manages sessions (evidence: `server/server.py`)
- TCP Server → Game Request Handlers: registers handlers (evidence: `server/server.py`)
- Message Dispatcher → JSON Messages: accepts messages (evidence: `server/dispatcher.py`)
- Message Dispatcher → Session Manager: accepts session (evidence: `server/dispatcher.py`)
- Game Request Handlers → Session Manager: creates and resumes (evidence: `server/server.py`)
- Game Request Handlers → Hangman Engine: starts and updates (evidence: `server/server.py`)
- Session Manager → Hangman Engine: holds game state (evidence: `core/session.py`)
- Session Manager → JSON Messages: caches responses (evidence: `core/session.py`)
- Hangman Engine → Game Exceptions: raises errors (evidence: `core/pendu.py`)
