# skrubzxd/net-programming-final architecture

> Architecture diagram of the GitHub repository skrubzxd/net-programming-final, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/skrubzxd/net-programming-final
- Repository: https://github.com/skrubzxd/net-programming-final

## Overview

##### Project type and purpose
- This is a Python-based client-server networked number-guessing game.
- The server manages game rooms (2–4 players each), generates secret numbers, enforces turn-based play with timeouts, tracks scoring and leaderboards, and relays chat messages.
- The client application connects to the server, registers the player, sends guesses and chat, and displays feedback.

##### File structure
- Top-level scripts:
- server.py – server entry point, socket listener, client-handler threads
- client.py – client entry point, connects to server, user I/O
- timer.py – implements timeout logic for turns
- Directory “classes” contains the core game logic / domain model:
- game_message.py, game_message_queue.py – define network message formats and a queue for inter-thread broadcast
- game_progress.py, player_progress.py – manage per-game and per-player state (guesses, attempts, scores)
- player.py, player_list.py – represent individual players and collections of them
- room_list.py – manages active game rooms and player assignments
- send_menu.py – defines server-to-client menu messages and prompts
- unique_random.py – generates the secret number, ensures no duplicates
- No external database; all state is in-memory.

##### README for additional insights
- Requirements: random secret 1–100, higher/lower hints, turn-based with timeout, scoring, chat, leaderboard, multiple rooms.
- Missing feature: reconnection support (future extension).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Client Tier"
        direction TB
        ClientApp["Client Application"]:::network
    end

    subgraph "Server Tier"
        direction TB

        subgraph "Network Layer"
            direction TB
            ServerListener["Network Listener / Connection Manager"]:::network
            HandlerThread["Client Handler Thread"]:::network
        end

        subgraph "Utility Layer"
            direction TB
            MsgQueue["Message Queue (Producer-Consumer)"]:::util
            TimerSvc["Timer Service"]:::util
        end

        subgraph "Domain Layer"
            direction TB
            RoomMgr["Room Manager"]:::domain
            PlayerMgr["Player Manager"]:::domain
            Player["Player Representation"]:::domain
            GameProg["Game Engine\n(Game Progress)"]:::domain
            PlayerProg["Game Engine\n(Player Progress)"]:::domain
            RandGen["Secret Number Generator"]:::domain
            MsgFormats["Network Message Formats"]:::domain
            MenuGen["Menu / Prompt Generator"]:::domain
        end
    end

    ClientApp -->|"register/guess/chat"| ServerListener
    ServerListener --> HandlerThread
    HandlerThread -->|"enqueue message"| MsgQueue
    MsgQueue -->|"dequeue message"| RoomMgr
    RoomMgr --> PlayerMgr
    PlayerMgr --> Player
    RoomMgr --> GameProg
    GameProg --> PlayerProg
    GameProg --> RandGen
    GameProg --> TimerSvc
    GameProg --> MenuGen
    MenuGen --> HandlerThread
    HandlerThread -->|"send menus/hints/chat"| ClientApp

    %% Click Events
    click ClientApp "https://github.com/skrubzxd/net-programming-final/blob/main/client.py"
    click ServerListener "https://github.com/skrubzxd/net-programming-final/blob/main/server.py"
    click TimerSvc "https://github.com/skrubzxd/net-programming-final/blob/main/timer.py"
    click RoomMgr "https://github.com/skrubzxd/net-programming-final/blob/main/classes/room_list.py"
    click PlayerMgr "https://github.com/skrubzxd/net-programming-final/blob/main/classes/player_list.py"
    click Player "https://github.com/skrubzxd/net-programming-final/blob/main/classes/player.py"
    click GameProg "https://github.com/skrubzxd/net-programming-final/blob/main/classes/game_progress.py"
    click PlayerProg "https://github.com/skrubzxd/net-programming-final/blob/main/classes/player_progress.py"
    click RandGen "https://github.com/skrubzxd/net-programming-final/blob/main/classes/unique_random.py"
    click MsgQueue "https://github.com/skrubzxd/net-programming-final/blob/main/classes/game_message_queue.py"
    click MsgFormats "https://github.com/skrubzxd/net-programming-final/blob/main/classes/game_message.py"
    click MenuGen "https://github.com/skrubzxd/net-programming-final/blob/main/classes/send_menu.py"

    %% Styles
    classDef network fill:#f9f,stroke:#333,stroke-width:1px
    classDef domain fill:#9f9,stroke:#333,stroke-width:1px
    classDef util fill:#99f,stroke:#333,stroke-width:1px
```
