# bilaharivp/quiz architecture

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

- Interactive diagram: https://gitdiagram.com/bilaharivp/quiz
- Repository: https://github.com/bilaharivp/quiz

## Overview

This is a NiceGUI multiplayer quiz application with separate player and administrator pages. Players register, answer timed questions, and earn points; administrators add questions, control quiz progression, and show or hide rankings. MongoDB persists questions, player scores, answers, and shared game state. The sampled code shows the main calls between these components; the README provides no additional capability detail. The standalone leaderboard helper is included, but no caller for it is shown.

Main entry points: [`main.py`](https://github.com/bilaharivp/quiz/blob/main/main.py) (Player page), [`admin.py`](https://github.com/bilaharivp/quiz/blob/main/admin.py) (Admin panel), [`modules/game_state.py`](https://github.com/bilaharivp/quiz/blob/main/modules/game_state.py) (Game state), [`modules/quiz.py`](https://github.com/bilaharivp/quiz/blob/main/modules/quiz.py) (Questions and answers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["Quiz interfaces"]
  node_player["Player page<br/>[main.py]"]
  node_admin["Admin panel<br/>[admin.py]"]
end

subgraph group_game["Quiz gameplay"]
  node_game_state["Game state<br/>[game_state.py]"]
  node_quiz["Questions and answers<br/>[quiz.py]"]
end

subgraph group_data["Persistence and results"]
  node_users["Player profiles and scores<br/>[users.py]"]
  node_leaderboard["Leaderboard queries<br/>[leaderboard.py]"]
  node_mongo[("MongoDB<br/>[db.py]")]
end

node_player_actor(("Player"))
node_admin_actor(("Administrator"))

node_player_actor -->|"uses"| node_player
node_admin_actor -->|"uses"| node_admin
node_player -->|"registers and scores"| node_users
node_player -->|"checks and saves answers"| node_quiz
node_player -->|"reads quiz status"| node_game_state
node_player -->|"reads rankings"| node_users
node_admin -->|"controls quiz"| node_game_state
node_admin -->|"adds questions"| node_quiz
node_admin -->|"reads rankings"| node_users
node_game_state -->|"reads questions"| node_quiz
node_game_state -->|"reads and writes state"| node_mongo
node_quiz -->|"reads and writes questions and answers"| node_mongo
node_users -->|"reads and writes players"| node_mongo
node_leaderboard -->|"reads and updates scores"| node_mongo

click node_player "https://github.com/bilaharivp/quiz/blob/main/main.py"
click node_admin "https://github.com/bilaharivp/quiz/blob/main/admin.py"
click node_game_state "https://github.com/bilaharivp/quiz/blob/main/modules/game_state.py"
click node_quiz "https://github.com/bilaharivp/quiz/blob/main/modules/quiz.py"
click node_users "https://github.com/bilaharivp/quiz/blob/main/modules/users.py"
click node_leaderboard "https://github.com/bilaharivp/quiz/blob/main/modules/leaderboard.py"
click node_mongo "https://github.com/bilaharivp/quiz/blob/main/database/db.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_player,node_admin toneBlue
class node_game_state,node_quiz toneAmber
class node_users,node_leaderboard,node_mongo toneMint
class node_player_actor,node_admin_actor toneIndigo
```

## Components

### Quiz interfaces

- [Player page](https://github.com/bilaharivp/quiz/blob/main/main.py): `main.py`
- [Admin panel](https://github.com/bilaharivp/quiz/blob/main/admin.py): `admin.py`

### Quiz gameplay

- [Game state](https://github.com/bilaharivp/quiz/blob/main/modules/game_state.py): `modules/game_state.py`
- [Questions and answers](https://github.com/bilaharivp/quiz/blob/main/modules/quiz.py): `modules/quiz.py`

### Persistence and results

- [Player profiles and scores](https://github.com/bilaharivp/quiz/blob/main/modules/users.py): `modules/users.py`
- [Leaderboard queries](https://github.com/bilaharivp/quiz/blob/main/modules/leaderboard.py): `modules/leaderboard.py`
- [MongoDB](https://github.com/bilaharivp/quiz/blob/main/database/db.py): `database/db.py`

### Other components

- **Player**
- **Administrator**

## Connections

- Player → Player page: uses (evidence: `main.py`)
- Administrator → Admin panel: uses (evidence: `admin.py`)
- Player page → Player profiles and scores: registers and scores (evidence: `main.py`)
- Player page → Questions and answers: checks and saves answers (evidence: `main.py`)
- Player page → Game state: reads quiz status (evidence: `main.py`)
- Player page → Player profiles and scores: reads rankings (evidence: `main.py`)
- Admin panel → Game state: controls quiz (evidence: `admin.py`)
- Admin panel → Questions and answers: adds questions (evidence: `admin.py`)
- Admin panel → Player profiles and scores: reads rankings (evidence: `admin.py`)
- Game state → Questions and answers: reads questions (evidence: `modules/game_state.py`)
- Game state → MongoDB: reads and writes state (evidence: `modules/game_state.py`)
- Questions and answers → MongoDB: reads and writes questions and answers (evidence: `modules/quiz.py`)
- Player profiles and scores → MongoDB: reads and writes players (evidence: `modules/users.py`)
- Leaderboard queries → MongoDB: reads and updates scores (evidence: `modules/leaderboard.py`)
