# momenabdelhady16/choice-or-chance architecture

> Architecture diagram of the GitHub repository momenabdelhady16/choice-or-chance, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/momenabdelhady16/choice-or-chance
- Repository: https://github.com/momenabdelhady16/choice-or-chance

## Overview

Choose Your Story is a small browser-based randomized quiz. The player answers a sequence of everyday questions through confirm dialogs; each answer receives a randomized outcome in an alert. The game removes asked questions, tracks bad outcomes, and ends when questions run out or three mistakes occur. The runtime is implemented in one file, so nodes represent responsibilities within that file rather than separate modules.

Main entry points: [`main.js`](https://github.com/momenabdelhady16/choice-or-chance/blob/main/main.js) (Quiz state)

## Diagram (Mermaid)

```mermaid
flowchart TD

node_player(("Player"))
node_entry["Game start<br/>[main.js]"]
node_game["Quiz state<br/>[main.js]"]
node_question_pool["Question pool<br/>[main.js]"]
node_random["Random choice<br/>[main.js]"]
node_confirm["Answer dialog"]
node_outcome["Outcome dialog"]
node_finish["Game endings<br/>[main.js]"]

node_entry -->|"starts"| node_game
node_game -->|"selects and removes"| node_question_pool
node_game -->|"chooses question"| node_random
node_random -->|"returns index"| node_game
node_game -->|"asks question"| node_confirm
node_player -->|"answers"| node_confirm
node_game -->|"chooses outcome"| node_random
node_game -->|"shows result"| node_outcome
node_outcome -->|"reveals outcome"| node_player
node_game -->|"ends on condition"| node_finish
node_game -->|"recurses"| node_game

click node_entry "https://github.com/momenabdelhady16/choice-or-chance/blob/main/main.js"
click node_game "https://github.com/momenabdelhady16/choice-or-chance/blob/main/main.js"
click node_question_pool "https://github.com/momenabdelhady16/choice-or-chance/blob/main/main.js"
click node_random "https://github.com/momenabdelhady16/choice-or-chance/blob/main/main.js"
click node_finish "https://github.com/momenabdelhady16/choice-or-chance/blob/main/main.js"

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_confirm,node_outcome toneIndigo
class node_entry,node_game,node_question_pool,node_random,node_finish toneTeal
```

## Components

### Other components

- **Player**
- [Game start](https://github.com/momenabdelhady16/choice-or-chance/blob/main/main.js): `main.js`
- [Quiz state](https://github.com/momenabdelhady16/choice-or-chance/blob/main/main.js): `main.js`
- [Question pool](https://github.com/momenabdelhady16/choice-or-chance/blob/main/main.js): `main.js`
- [Random choice](https://github.com/momenabdelhady16/choice-or-chance/blob/main/main.js): `main.js`
- **Answer dialog**
- **Outcome dialog**
- [Game endings](https://github.com/momenabdelhady16/choice-or-chance/blob/main/main.js): `main.js`

## Connections

- Game start → Quiz state: starts (evidence: `main.js`)
- Quiz state → Question pool: selects and removes (evidence: `main.js`)
- Quiz state → Random choice: chooses question (evidence: `main.js`)
- Random choice → Quiz state: returns index (evidence: `main.js`)
- Quiz state → Answer dialog: asks question (evidence: `main.js`)
- Player → Answer dialog: answers (evidence: `README.MD`)
- Quiz state → Random choice: chooses outcome (evidence: `main.js`)
- Quiz state → Outcome dialog: shows result (evidence: `main.js`)
- Outcome dialog → Player: reveals outcome (evidence: `README.MD`)
- Quiz state → Game endings: ends on condition (evidence: `main.js`)
- Quiz state → Quiz state: recurses (evidence: `main.js`)
