# marmargames/guessing-game architecture

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

- Interactive diagram: https://gitdiagram.com/marmargames/guessing-game
- Repository: https://github.com/marmargames/guessing-game

## Overview

This is a small Rust web server for a browser-based number-guessing game. A player loads the game page, starts a game to receive an ID, then submits guesses; the server keeps each game's secret and progress in mutex-protected in-memory state and returns results and updated bounds. The source excerpt establishes routes, handlers, and embedded HTML, but the HTML contents were not provided, so browser-side interactions are not mapped in detail.

Main entry points: [`project/guessing_game_server/src/main.rs`](https://github.com/marmargames/guessing-game/blob/main/project/guessing_game_server/src/main.rs) (HTTP server and routes), [`project/guessing_game_server/src/index.html`](https://github.com/marmargames/guessing-game/blob/main/project/guessing_game_server/src/index.html) (Game page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_server["HTTP server and routes<br/>[main.rs]"]
  node_page["Game page<br/>[index.html]"]
end

subgraph group_game["Game runtime"]
  node_handlers["Game API handlers<br/>[main.rs]"]
  node_state[("In-memory game state<br/>[main.rs]")]
end

node_player(("Player"))

node_player -->|"sends requests"| node_server
node_server -->|"serves embedded"| node_page
node_server -->|"routes API"| node_handlers
node_handlers -->|"reads and updates"| node_state
node_handlers -->|"returns JSON"| node_player

click node_server "https://github.com/marmargames/guessing-game/blob/main/project/guessing_game_server/src/main.rs"
click node_page "https://github.com/marmargames/guessing-game/blob/main/project/guessing_game_server/src/index.html"
click node_handlers "https://github.com/marmargames/guessing-game/blob/main/project/guessing_game_server/src/main.rs"
click node_state "https://github.com/marmargames/guessing-game/blob/main/project/guessing_game_server/src/main.rs"

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_server,node_page toneBlue
class node_handlers,node_state toneAmber
class node_player toneIndigo
```

## Components

### Web interface

- [HTTP server and routes](https://github.com/marmargames/guessing-game/blob/main/project/guessing_game_server/src/main.rs): `project/guessing_game_server/src/main.rs`
- [Game page](https://github.com/marmargames/guessing-game/blob/main/project/guessing_game_server/src/index.html): `project/guessing_game_server/src/index.html`

### Game runtime

- [Game API handlers](https://github.com/marmargames/guessing-game/blob/main/project/guessing_game_server/src/main.rs): `project/guessing_game_server/src/main.rs`
- [In-memory game state](https://github.com/marmargames/guessing-game/blob/main/project/guessing_game_server/src/main.rs): `project/guessing_game_server/src/main.rs`

### Other components

- **Player**

## Connections

- Player → HTTP server and routes: sends requests (evidence: `project/guessing_game_server/src/main.rs`)
- HTTP server and routes → Game page: serves embedded (evidence: `project/guessing_game_server/src/main.rs`)
- HTTP server and routes → Game API handlers: routes API (evidence: `project/guessing_game_server/src/main.rs`)
- Game API handlers → In-memory game state: reads and updates (evidence: `project/guessing_game_server/src/main.rs`)
- Game API handlers → Player: returns JSON (evidence: `project/guessing_game_server/src/main.rs`)
