# danieltheparasite/quantum-coin-flip architecture

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

- Interactive diagram: https://gitdiagram.com/danieltheparasite/quantum-coin-flip
- Repository: https://github.com/danieltheparasite/quantum-coin-flip

## Overview

Quantum Coin Lab combines a browser-based quantum-coin learning experience with an optional Python simulator and seven experiments. The main user journey is to explore the 3D room, click the coins in sequence to complete the eight-qubit tour, then unlock experiments and a glossary; users can also compare outcomes with ordinary coin flips or request plain-language explanations of selected text. README statements establish the website capabilities and tour, while the Python source excerpts show the command-line experiment runner, simulator layers, and plotting. Browser implementation details are not sampled, so those internal links are omitted.

Main entry points: [`python/main.py`](https://github.com/danieltheparasite/quantum-coin-flip/blob/main/python/main.py) (Experiment runner), [`python/qsim/register.py`](https://github.com/danieltheparasite/quantum-coin-flip/blob/main/python/qsim/register.py) (State-vector register), [`python/qsim/visualize.py`](https://github.com/danieltheparasite/quantum-coin-flip/blob/main/python/qsim/visualize.py) (Plot generation), [`index.html`](https://github.com/danieltheparasite/quantum-coin-flip/blob/main/index.html) (Learning interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Learning website"]
  node_site["Learning interface<br/>[index.html]"]
  node_room["3D coin room<br/>[index.html]"]
  node_experiment_ui["Experiment explorer<br/>[index.html]"]
  node_coin_compare["Coin comparison<br/>[index.html]"]
  node_glossary["Plain-words glossary<br/>[index.html]"]
end

subgraph group_tour["Quantum tour"]
  node_tour_circuit["Eight-qubit tour<br/>[qiskit_ghz_coin.py]"]
end

subgraph group_sim["Python simulator"]
  node_register["State-vector register<br/>[register.py]"]
  node_gates["Quantum gates<br/>[gates.py]"]
  node_noise["Noise models<br/>[noise.py]"]
  node_visualize["Plot generation<br/>[visualize.py]"]
end

subgraph group_experiments["Experiments and results"]
  node_runner["Experiment runner<br/>[main.py]"]
  node_fair["Fair coin<br/>[exp1_fair_coin.py]"]
  node_biased["Biased coin"]
  node_eight["Eight coins"]
  node_entangled["Entangled coins"]
  node_walk["Quantum walk"]
  node_penny["Penny flip game"]
  node_interference["Interference and noise"]
end

subgraph group_explain["Text explanations"]
  node_hand["Floating hand<br/>[index.html]"]
  node_ai_helper["Gemini helper<br/>[ai.js]"]
  node_explain_api["Explanation endpoint<br/>[explain.js]"]
end

node_visitor(("Learner"))
node_gemini["Gemini API"]

node_visitor -->|"uses"| node_site
node_site -->|"presents"| node_room
node_visitor -->|"clicks coins"| node_room
node_room -->|"guides through"| node_tour_circuit
node_site -->|"unlocks"| node_experiment_ui
node_experiment_ui -->|"offers comparison"| node_coin_compare
node_site -->|"unlocks"| node_glossary
node_visitor -->|"selects text"| node_hand
node_hand -->|"requests explanation"| node_ai_helper
node_ai_helper -.->|"calls when deployed"| node_explain_api
node_explain_api -.->|"requests answer"| node_gemini
node_runner -->|"runs"| node_fair
node_runner -->|"runs"| node_biased
node_runner -->|"runs"| node_eight
node_runner -->|"runs"| node_entangled
node_runner -->|"runs"| node_walk
node_runner -->|"runs"| node_penny
node_runner -->|"runs"| node_interference
node_fair -->|"uses"| node_register
node_biased -->|"uses"| node_register
node_eight -->|"uses"| node_register
node_entangled -->|"uses"| node_register
node_penny -->|"uses"| node_register
node_interference -->|"uses"| node_register
node_walk -->|"plots results"| node_visualize
node_fair -->|"plots results"| node_visualize
node_biased -->|"plots results"| node_visualize
node_eight -->|"plots results"| node_visualize
node_entangled -->|"plots results"| node_visualize
node_penny -->|"plots results"| node_visualize
node_interference -->|"plots results"| node_visualize
node_register -->|"applies matrices from"| node_gates
node_interference -->|"runs noisy circuits"| node_noise
node_noise -->|"creates registers"| node_register
node_noise -->|"applies errors from"| node_gates

click node_site "https://github.com/danieltheparasite/quantum-coin-flip/blob/main/index.html"
click node_room "https://github.com/danieltheparasite/quantum-coin-flip/blob/main/index.html"
click node_experiment_ui "https://github.com/danieltheparasite/quantum-coin-flip/blob/main/index.html"
click node_coin_compare "https://github.com/danieltheparasite/quantum-coin-flip/blob/main/index.html"
click node_glossary "https://github.com/danieltheparasite/quantum-coin-flip/blob/main/index.html"
click node_tour_circuit "https://github.com/danieltheparasite/quantum-coin-flip/blob/main/python/qiskit_ghz_coin.py"
click node_runner "https://github.com/danieltheparasite/quantum-coin-flip/blob/main/python/main.py"
click node_fair "https://github.com/danieltheparasite/quantum-coin-flip/blob/main/python/experiments/exp1_fair_coin.py"
click node_biased "https://github.com/danieltheparasite/quantum-coin-flip/blob/main/python/experiments/exp2_biased_coin.py"
click node_eight "https://github.com/danieltheparasite/quantum-coin-flip/blob/main/python/experiments/exp3_eight_coins.py"
click node_entangled "https://github.com/danieltheparasite/quantum-coin-flip/blob/main/python/experiments/exp4_entangled_coins.py"
click node_walk "https://github.com/danieltheparasite/quantum-coin-flip/blob/main/python/experiments/exp5_quantum_walk.py"
click node_penny "https://github.com/danieltheparasite/quantum-coin-flip/blob/main/python/experiments/exp6_penny_flip_game.py"
click node_interference "https://github.com/danieltheparasite/quantum-coin-flip/blob/main/python/experiments/exp7_interference_noise.py"
click node_register "https://github.com/danieltheparasite/quantum-coin-flip/blob/main/python/qsim/register.py"
click node_gates "https://github.com/danieltheparasite/quantum-coin-flip/blob/main/python/qsim/gates.py"
click node_noise "https://github.com/danieltheparasite/quantum-coin-flip/blob/main/python/qsim/noise.py"
click node_visualize "https://github.com/danieltheparasite/quantum-coin-flip/blob/main/python/qsim/visualize.py"
click node_hand "https://github.com/danieltheparasite/quantum-coin-flip/blob/main/index.html"
click node_ai_helper "https://github.com/danieltheparasite/quantum-coin-flip/blob/main/ai.js"
click node_explain_api "https://github.com/danieltheparasite/quantum-coin-flip/blob/main/api/explain.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_site,node_room,node_experiment_ui,node_coin_compare,node_glossary toneBlue
class node_tour_circuit toneAmber
class node_register,node_gates,node_noise,node_visualize,node_gemini toneMint
class node_runner,node_fair,node_biased,node_eight,node_entangled,node_walk,node_penny,node_interference toneRose
class node_hand,node_ai_helper,node_explain_api,node_visitor toneIndigo
```

## Components

### Learning website

- [Learning interface](https://github.com/danieltheparasite/quantum-coin-flip/blob/main/index.html): `index.html`
- [3D coin room](https://github.com/danieltheparasite/quantum-coin-flip/blob/main/index.html): `index.html`
- [Experiment explorer](https://github.com/danieltheparasite/quantum-coin-flip/blob/main/index.html): `index.html`
- [Coin comparison](https://github.com/danieltheparasite/quantum-coin-flip/blob/main/index.html): `index.html`
- [Plain-words glossary](https://github.com/danieltheparasite/quantum-coin-flip/blob/main/index.html): `index.html`

### Quantum tour

- [Eight-qubit tour](https://github.com/danieltheparasite/quantum-coin-flip/blob/main/python/qiskit_ghz_coin.py): `python/qiskit_ghz_coin.py`

### Python simulator

- [State-vector register](https://github.com/danieltheparasite/quantum-coin-flip/blob/main/python/qsim/register.py): `python/qsim/register.py`
- [Quantum gates](https://github.com/danieltheparasite/quantum-coin-flip/blob/main/python/qsim/gates.py): `python/qsim/gates.py`
- [Noise models](https://github.com/danieltheparasite/quantum-coin-flip/blob/main/python/qsim/noise.py): `python/qsim/noise.py`
- [Plot generation](https://github.com/danieltheparasite/quantum-coin-flip/blob/main/python/qsim/visualize.py): `python/qsim/visualize.py`

### Experiments and results

- [Experiment runner](https://github.com/danieltheparasite/quantum-coin-flip/blob/main/python/main.py): `python/main.py`
- [Fair coin](https://github.com/danieltheparasite/quantum-coin-flip/blob/main/python/experiments/exp1_fair_coin.py): `python/experiments/exp1_fair_coin.py`
- [Biased coin](https://github.com/danieltheparasite/quantum-coin-flip/blob/main/python/experiments/exp2_biased_coin.py): `python/experiments/exp2_biased_coin.py`
- [Eight coins](https://github.com/danieltheparasite/quantum-coin-flip/blob/main/python/experiments/exp3_eight_coins.py): `python/experiments/exp3_eight_coins.py`
- [Entangled coins](https://github.com/danieltheparasite/quantum-coin-flip/blob/main/python/experiments/exp4_entangled_coins.py): `python/experiments/exp4_entangled_coins.py`
- [Quantum walk](https://github.com/danieltheparasite/quantum-coin-flip/blob/main/python/experiments/exp5_quantum_walk.py): `python/experiments/exp5_quantum_walk.py`
- [Penny flip game](https://github.com/danieltheparasite/quantum-coin-flip/blob/main/python/experiments/exp6_penny_flip_game.py): `python/experiments/exp6_penny_flip_game.py`
- [Interference and noise](https://github.com/danieltheparasite/quantum-coin-flip/blob/main/python/experiments/exp7_interference_noise.py): `python/experiments/exp7_interference_noise.py`

### Text explanations

- [Floating hand](https://github.com/danieltheparasite/quantum-coin-flip/blob/main/index.html): `index.html`
- [Gemini helper](https://github.com/danieltheparasite/quantum-coin-flip/blob/main/ai.js): `ai.js`
- [Explanation endpoint](https://github.com/danieltheparasite/quantum-coin-flip/blob/main/api/explain.js): `api/explain.js`

### Other components

- **Learner**
- **Gemini API**

## Connections

- Learner → Learning interface: uses (evidence: `README.md`)
- Learning interface → 3D coin room: presents (evidence: `README.md`)
- Learner → 3D coin room: clicks coins (evidence: `README.md`)
- 3D coin room → Eight-qubit tour: guides through (evidence: `README.md`)
- Learning interface → Experiment explorer: unlocks (evidence: `README.md`)
- Experiment explorer → Coin comparison: offers comparison (evidence: `README.md`)
- Learning interface → Plain-words glossary: unlocks (evidence: `README.md`)
- Learner → Floating hand: selects text (evidence: `README.md`)
- Floating hand → Gemini helper: requests explanation (evidence: `README.md`)
- Gemini helper → Explanation endpoint: calls when deployed (evidence: `README.md`)
- Explanation endpoint → Gemini API: requests answer (evidence: `README.md`)
- Experiment runner → Fair coin: runs (evidence: `python/main.py`)
- Experiment runner → Biased coin: runs (evidence: `python/main.py`)
- Experiment runner → Eight coins: runs (evidence: `python/main.py`)
- Experiment runner → Entangled coins: runs (evidence: `python/main.py`)
- Experiment runner → Quantum walk: runs (evidence: `python/main.py`)
- Experiment runner → Penny flip game: runs (evidence: `python/main.py`)
- Experiment runner → Interference and noise: runs (evidence: `python/main.py`)
- Fair coin → State-vector register: uses (evidence: `python/experiments/exp1_fair_coin.py`)
- Biased coin → State-vector register: uses (evidence: `python/experiments/exp2_biased_coin.py`)
- Eight coins → State-vector register: uses (evidence: `python/experiments/exp3_eight_coins.py`)
- Entangled coins → State-vector register: uses (evidence: `python/experiments/exp4_entangled_coins.py`)
- Penny flip game → State-vector register: uses (evidence: `python/experiments/exp6_penny_flip_game.py`)
- Interference and noise → State-vector register: uses (evidence: `python/experiments/exp7_interference_noise.py`)
- Quantum walk → Plot generation: plots results (evidence: `python/experiments/exp5_quantum_walk.py`)
- Fair coin → Plot generation: plots results (evidence: `python/experiments/exp1_fair_coin.py`)
- Biased coin → Plot generation: plots results (evidence: `python/experiments/exp2_biased_coin.py`)
- Eight coins → Plot generation: plots results (evidence: `python/experiments/exp3_eight_coins.py`)
- Entangled coins → Plot generation: plots results (evidence: `python/experiments/exp4_entangled_coins.py`)
- Penny flip game → Plot generation: plots results (evidence: `python/experiments/exp6_penny_flip_game.py`)
- Interference and noise → Plot generation: plots results (evidence: `python/experiments/exp7_interference_noise.py`)
- State-vector register → Quantum gates: applies matrices from (evidence: `python/qsim/register.py`)
- Interference and noise → Noise models: runs noisy circuits (evidence: `python/experiments/exp7_interference_noise.py`)
- Noise models → State-vector register: creates registers (evidence: `python/qsim/noise.py`)
- Noise models → Quantum gates: applies errors from (evidence: `python/qsim/noise.py`)
