# ibrahimsarran/mathgame-cpp architecture

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

- Interactive diagram: https://gitdiagram.com/ibrahimsarran/mathgame-cpp
- Repository: https://github.com/ibrahimsarran/mathgame-cpp

## Overview

A single-file console math quiz: the player configures a quiz, receives randomly generated arithmetic questions, answers them with immediate correctness and color feedback, then sees a pass/fail summary and can replay. The graph separates the user interaction, question generation, and answer/reporting stages, plus the internal arithmetic helper. All implementation is in Math Game.cpp; edges reflect calls visible in that excerpt. The README documents these same capabilities, so no unsampled subsystems are required.

Main entry points: [`Math Game.cpp`](https://github.com/ibrahimsarran/mathgame-cpp/blob/main/Math%20Game.cpp) (Quiz Setup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["Quiz Interaction"]
  node_replay["Replay Loop<br/>[Math Game.cpp]"]
  node_quiz_setup["Quiz Setup<br/>[Math Game.cpp]"]
  node_question_count["Question Count Input<br/>[Math Game.cpp]"]
  node_level_choice["Level Selection<br/>[Math Game.cpp]"]
  node_operation_choice["Operation Selection<br/>[Math Game.cpp]"]
end

subgraph group_generation["Question Generation"]
  node_quiz_state["Quiz State<br/>[Math Game.cpp]"]
  node_question_generation["Question Generation<br/>[Math Game.cpp]"]
  node_random_values["Random Values<br/>[Math Game.cpp]"]
end

subgraph group_results["Answering &amp; Results"]
  node_question_loop["Question Loop<br/>[Math Game.cpp]"]
  node_question_display["Question Display<br/>[Math Game.cpp]"]
  node_answer_input["Answer Input<br/>[Math Game.cpp]"]
  node_answer_check["Answer Check<br/>[Math Game.cpp]"]
  node_color_feedback["Color Feedback<br/>[Math Game.cpp]"]
  node_final_report["Final Report<br/>[Math Game.cpp]"]
end

subgraph group_calculation["Arithmetic"]
  node_arithmetic["Arithmetic Calculator<br/>[Math Game.cpp]"]
end

node_player(("Player"))
node_console["Console"]

node_player -->|"starts and replays"| node_replay
node_replay -->|"starts quiz"| node_quiz_setup
node_quiz_setup -->|"reads count"| node_question_count
node_quiz_setup -->|"reads level"| node_level_choice
node_quiz_setup -->|"reads operation"| node_operation_choice
node_quiz_setup -->|"sets preferences"| node_quiz_state
node_quiz_setup -->|"generates quiz"| node_question_generation
node_question_generation -->|"draws operands"| node_random_values
node_question_generation -->|"calculates answer"| node_arithmetic
node_question_generation -->|"stores questions"| node_quiz_state
node_quiz_setup -->|"runs questions"| node_question_loop
node_question_loop -->|"prints question"| node_question_display
node_question_loop -->|"reads response"| node_answer_input
node_question_loop -->|"checks response"| node_answer_check
node_answer_check -->|"updates score"| node_quiz_state
node_answer_check -->|"sets feedback"| node_color_feedback
node_color_feedback -->|"changes color"| node_console
node_question_display -->|"prints prompt"| node_console
node_answer_input -->|"reads input"| node_console
node_answer_check -->|"prints result"| node_console
node_quiz_setup -->|"prints summary"| node_final_report
node_final_report -->|"reads totals"| node_quiz_state
node_final_report -->|"prints report"| node_console

click node_replay "https://github.com/ibrahimsarran/mathgame-cpp/blob/main/Math%20Game.cpp"
click node_quiz_setup "https://github.com/ibrahimsarran/mathgame-cpp/blob/main/Math%20Game.cpp"
click node_question_count "https://github.com/ibrahimsarran/mathgame-cpp/blob/main/Math%20Game.cpp"
click node_level_choice "https://github.com/ibrahimsarran/mathgame-cpp/blob/main/Math%20Game.cpp"
click node_operation_choice "https://github.com/ibrahimsarran/mathgame-cpp/blob/main/Math%20Game.cpp"
click node_quiz_state "https://github.com/ibrahimsarran/mathgame-cpp/blob/main/Math%20Game.cpp"
click node_question_generation "https://github.com/ibrahimsarran/mathgame-cpp/blob/main/Math%20Game.cpp"
click node_random_values "https://github.com/ibrahimsarran/mathgame-cpp/blob/main/Math%20Game.cpp"
click node_arithmetic "https://github.com/ibrahimsarran/mathgame-cpp/blob/main/Math%20Game.cpp"
click node_question_loop "https://github.com/ibrahimsarran/mathgame-cpp/blob/main/Math%20Game.cpp"
click node_question_display "https://github.com/ibrahimsarran/mathgame-cpp/blob/main/Math%20Game.cpp"
click node_answer_input "https://github.com/ibrahimsarran/mathgame-cpp/blob/main/Math%20Game.cpp"
click node_answer_check "https://github.com/ibrahimsarran/mathgame-cpp/blob/main/Math%20Game.cpp"
click node_color_feedback "https://github.com/ibrahimsarran/mathgame-cpp/blob/main/Math%20Game.cpp"
click node_final_report "https://github.com/ibrahimsarran/mathgame-cpp/blob/main/Math%20Game.cpp"

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_replay,node_quiz_setup,node_question_count,node_level_choice,node_operation_choice toneBlue
class node_quiz_state,node_question_generation,node_random_values toneAmber
class node_question_loop,node_question_display,node_answer_input,node_answer_check,node_color_feedback,node_final_report toneMint
class node_arithmetic toneRose
class node_player,node_console toneIndigo
```

## Components

### Quiz Interaction

- [Replay Loop](https://github.com/ibrahimsarran/mathgame-cpp/blob/main/Math%20Game.cpp): `Math Game.cpp`
- [Quiz Setup](https://github.com/ibrahimsarran/mathgame-cpp/blob/main/Math%20Game.cpp): `Math Game.cpp`
- [Question Count Input](https://github.com/ibrahimsarran/mathgame-cpp/blob/main/Math%20Game.cpp): `Math Game.cpp`
- [Level Selection](https://github.com/ibrahimsarran/mathgame-cpp/blob/main/Math%20Game.cpp): `Math Game.cpp`
- [Operation Selection](https://github.com/ibrahimsarran/mathgame-cpp/blob/main/Math%20Game.cpp): `Math Game.cpp`

### Question Generation

- [Quiz State](https://github.com/ibrahimsarran/mathgame-cpp/blob/main/Math%20Game.cpp): `Math Game.cpp`
- [Question Generation](https://github.com/ibrahimsarran/mathgame-cpp/blob/main/Math%20Game.cpp): `Math Game.cpp`
- [Random Values](https://github.com/ibrahimsarran/mathgame-cpp/blob/main/Math%20Game.cpp): `Math Game.cpp`

### Answering & Results

- [Question Loop](https://github.com/ibrahimsarran/mathgame-cpp/blob/main/Math%20Game.cpp): `Math Game.cpp`
- [Question Display](https://github.com/ibrahimsarran/mathgame-cpp/blob/main/Math%20Game.cpp): `Math Game.cpp`
- [Answer Input](https://github.com/ibrahimsarran/mathgame-cpp/blob/main/Math%20Game.cpp): `Math Game.cpp`
- [Answer Check](https://github.com/ibrahimsarran/mathgame-cpp/blob/main/Math%20Game.cpp): `Math Game.cpp`
- [Color Feedback](https://github.com/ibrahimsarran/mathgame-cpp/blob/main/Math%20Game.cpp): `Math Game.cpp`
- [Final Report](https://github.com/ibrahimsarran/mathgame-cpp/blob/main/Math%20Game.cpp): `Math Game.cpp`

### Arithmetic

- [Arithmetic Calculator](https://github.com/ibrahimsarran/mathgame-cpp/blob/main/Math%20Game.cpp): `Math Game.cpp`

### Other components

- **Player**
- **Console**

## Connections

- Player → Replay Loop: starts and replays (evidence: `README.md`)
- Replay Loop → Quiz Setup: starts quiz (evidence: `Math Game.cpp`)
- Quiz Setup → Question Count Input: reads count (evidence: `Math Game.cpp`)
- Quiz Setup → Level Selection: reads level (evidence: `Math Game.cpp`)
- Quiz Setup → Operation Selection: reads operation (evidence: `Math Game.cpp`)
- Quiz Setup → Quiz State: sets preferences (evidence: `Math Game.cpp`)
- Quiz Setup → Question Generation: generates quiz (evidence: `Math Game.cpp`)
- Question Generation → Random Values: draws operands (evidence: `Math Game.cpp`)
- Question Generation → Arithmetic Calculator: calculates answer (evidence: `Math Game.cpp`)
- Question Generation → Quiz State: stores questions (evidence: `Math Game.cpp`)
- Quiz Setup → Question Loop: runs questions (evidence: `Math Game.cpp`)
- Question Loop → Question Display: prints question (evidence: `Math Game.cpp`)
- Question Loop → Answer Input: reads response (evidence: `Math Game.cpp`)
- Question Loop → Answer Check: checks response (evidence: `Math Game.cpp`)
- Answer Check → Quiz State: updates score (evidence: `Math Game.cpp`)
- Answer Check → Color Feedback: sets feedback (evidence: `Math Game.cpp`)
- Color Feedback → Console: changes color (evidence: `Math Game.cpp`)
- Question Display → Console: prints prompt (evidence: `Math Game.cpp`)
- Answer Input → Console: reads input (evidence: `Math Game.cpp`)
- Answer Check → Console: prints result (evidence: `Math Game.cpp`)
- Quiz Setup → Final Report: prints summary (evidence: `Math Game.cpp`)
- Final Report → Quiz State: reads totals (evidence: `Math Game.cpp`)
- Final Report → Console: prints report (evidence: `Math Game.cpp`)
