# josephamuasi001/number-guessing-game architecture

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

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

## Overview

NumGenius is a PHP number-guessing game with account sessions, single-player and daily play, progression rewards, and multiplayer rooms. The main workflow is a player entering the web app, playing a round, and reaching results; the game class also defines difficulty, achievements, themes, and power-ups. JSON files provide apparent user, daily, and room state. The README gives no architectural detail, and the PHP excerpt is partial, so several subsystem connections are shown as unverified rather than asserted.

Main entry points: [`index.php`](https://github.com/josephamuasi001/number-guessing-game/blob/main/index.php) (Game rules), [`ng_users.json`](https://github.com/josephamuasi001/number-guessing-game/blob/main/ng_users.json) (User data), [`ng_daily.json`](https://github.com/josephamuasi001/number-guessing-game/blob/main/ng_daily.json) (Daily data), [`ng_rooms.json`](https://github.com/josephamuasi001/number-guessing-game/blob/main/ng_rooms.json) (Room data)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Web entry"]
  node_web["Request and UI<br/>[index.php]"]
  node_sessions["Session auth<br/>[index.php]"]
end

subgraph group_gameplay["Game modes"]
  node_game["Game rules<br/>[index.php]"]
  node_single["Single-player rounds<br/>[index.php]"]
  node_daily["Daily challenge<br/>[index.php]"]
  node_multi["Multiplayer rooms<br/>[index.php]"]
  node_results["Round results<br/>[index.php]"]
end

subgraph group_progression["Player progression"]
  node_rewards["XP and coins<br/>[index.php]"]
  node_achievements["Achievements<br/>[index.php]"]
  node_themes["Themes<br/>[index.php]"]
  node_powerups["Power-ups<br/>[index.php]"]
end

subgraph group_state["JSON state"]
  node_users[("User data<br/>[ng_users.json]")]
  node_dailydata[("Daily data<br/>[ng_daily.json]")]
  node_roomsdata[("Room data<br/>[ng_rooms.json]")]
end

node_player(("Player"))

node_player -.->|"uses"| node_web
node_web -->|"checks session"| node_sessions
node_web -.->|"routes actions"| node_single
node_web -.->|"routes actions"| node_daily
node_web -.->|"routes actions"| node_multi
node_single -.->|"uses rules"| node_game
node_daily -.->|"uses rules"| node_game
node_multi -.->|"uses rules"| node_game
node_single -.->|"shows outcome"| node_results
node_results -.->|"shows rewards"| node_rewards
node_game -.->|"tracks progress"| node_achievements
node_web -.->|"offers themes"| node_themes
node_single -.->|"uses power-ups"| node_powerups
node_game -.->|"references file"| node_users
node_game -.->|"references file"| node_dailydata
node_game -.->|"references file"| node_roomsdata

click node_web "https://github.com/josephamuasi001/number-guessing-game/blob/main/index.php"
click node_sessions "https://github.com/josephamuasi001/number-guessing-game/blob/main/index.php"
click node_game "https://github.com/josephamuasi001/number-guessing-game/blob/main/index.php"
click node_single "https://github.com/josephamuasi001/number-guessing-game/blob/main/index.php"
click node_daily "https://github.com/josephamuasi001/number-guessing-game/blob/main/index.php"
click node_multi "https://github.com/josephamuasi001/number-guessing-game/blob/main/index.php"
click node_results "https://github.com/josephamuasi001/number-guessing-game/blob/main/index.php"
click node_rewards "https://github.com/josephamuasi001/number-guessing-game/blob/main/index.php"
click node_achievements "https://github.com/josephamuasi001/number-guessing-game/blob/main/index.php"
click node_themes "https://github.com/josephamuasi001/number-guessing-game/blob/main/index.php"
click node_powerups "https://github.com/josephamuasi001/number-guessing-game/blob/main/index.php"
click node_users "https://github.com/josephamuasi001/number-guessing-game/blob/main/ng_users.json"
click node_dailydata "https://github.com/josephamuasi001/number-guessing-game/blob/main/ng_daily.json"
click node_roomsdata "https://github.com/josephamuasi001/number-guessing-game/blob/main/ng_rooms.json"

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_web,node_sessions toneBlue
class node_game,node_single,node_daily,node_multi,node_results toneAmber
class node_rewards,node_achievements,node_themes,node_powerups toneMint
class node_users,node_dailydata,node_roomsdata toneRose
class node_player toneIndigo
```

## Components

### Web entry

- [Request and UI](https://github.com/josephamuasi001/number-guessing-game/blob/main/index.php): `index.php`
- [Session auth](https://github.com/josephamuasi001/number-guessing-game/blob/main/index.php): `index.php`

### Game modes

- [Game rules](https://github.com/josephamuasi001/number-guessing-game/blob/main/index.php): `index.php`
- [Single-player rounds](https://github.com/josephamuasi001/number-guessing-game/blob/main/index.php): `index.php`
- [Daily challenge](https://github.com/josephamuasi001/number-guessing-game/blob/main/index.php): `index.php`
- [Multiplayer rooms](https://github.com/josephamuasi001/number-guessing-game/blob/main/index.php): `index.php`
- [Round results](https://github.com/josephamuasi001/number-guessing-game/blob/main/index.php): `index.php`

### Player progression

- [XP and coins](https://github.com/josephamuasi001/number-guessing-game/blob/main/index.php): `index.php`
- [Achievements](https://github.com/josephamuasi001/number-guessing-game/blob/main/index.php): `index.php`
- [Themes](https://github.com/josephamuasi001/number-guessing-game/blob/main/index.php): `index.php`
- [Power-ups](https://github.com/josephamuasi001/number-guessing-game/blob/main/index.php): `index.php`

### JSON state

- [User data](https://github.com/josephamuasi001/number-guessing-game/blob/main/ng_users.json): `ng_users.json`
- [Daily data](https://github.com/josephamuasi001/number-guessing-game/blob/main/ng_daily.json): `ng_daily.json`
- [Room data](https://github.com/josephamuasi001/number-guessing-game/blob/main/ng_rooms.json): `ng_rooms.json`

### Other components

- **Player**

## Connections

- Player → Request and UI: uses
- Request and UI → Session auth: checks session (evidence: `index.php`)
- Request and UI → Single-player rounds: routes actions (evidence: `index.php`)
- Request and UI → Daily challenge: routes actions (evidence: `index.php`)
- Request and UI → Multiplayer rooms: routes actions (evidence: `index.php`)
- Single-player rounds → Game rules: uses rules (evidence: `index.php`)
- Daily challenge → Game rules: uses rules (evidence: `index.php`)
- Multiplayer rooms → Game rules: uses rules (evidence: `index.php`)
- Single-player rounds → Round results: shows outcome (evidence: `index.php`)
- Round results → XP and coins: shows rewards (evidence: `index.php`)
- Game rules → Achievements: tracks progress (evidence: `index.php`)
- Request and UI → Themes: offers themes (evidence: `index.php`)
- Single-player rounds → Power-ups: uses power-ups (evidence: `index.php`)
- Game rules → User data: references file
- Game rules → Daily data: references file
- Game rules → Room data: references file
