# hhtomaswt11/labhero architecture

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

- Interactive diagram: https://gitdiagram.com/hhtomaswt11/labhero
- Repository: https://github.com/hhtomaswt11/labhero

## Overview

LabHero is a serious game that teaches constraint-based metabolic modeling through student registration, campaign missions, interactive simulation, and evidence-based answers. The map covers both the Pygame game and its FastAPI simulation service, plus progression, hints, scoring, and persistence. Mission and simulator links are supported by the SOURCE INDEX and README; unsampled implementation details are not inferred.

Main entry points: [`code`](https://github.com/hhtomaswt11/labhero/tree/main/code) (Mission curriculum), [`backend/app/simulator.py`](https://github.com/hhtomaswt11/labhero/blob/main/backend/app/simulator.py) (Model simulator), [`code/window.py`](https://github.com/hhtomaswt11/labhero/blob/main/code/window.py) (Simulator interface), [`backend/app/main.py`](https://github.com/hhtomaswt11/labhero/blob/main/backend/app/main.py) (Simulation API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_gameplay["Game experience"]
  node_game["Game runtime<br/>[LabHero.py]"]
  node_world["Lab exploration<br/>[level.py]"]
  node_registration["Student registration"]
  node_teacher["Teacher preview<br/>[teacher_mode.py]"]
  node_simui["Simulator interface<br/>[window.py]"]
end

subgraph group_learning["Learning and progression"]
  node_missions["Mission curriculum"]
  node_hints["Hints and rewards<br/>[hint_system.py]"]
  node_scoring["Answer scoring<br/>[answer_penalty.py]"]
  node_campaign["Campaign progression<br/>[campaign.py]"]
  node_results["Final results<br/>[final_results.py]"]
end

subgraph group_simulation["Simulation service"]
  node_frontend_model["Model options<br/>[model_registry.py]"]
  node_api["Simulation API<br/>[main.py]"]
  node_simulator["Model simulator<br/>[simulator.py]"]
  node_schemas["Request schemas<br/>[schemas.py]"]
  node_gpr["Gene rules<br/>[gpr.py]"]
  node_room["ROOM solver<br/>[room_milp.py]"]
end

subgraph group_state["Player state"]
  node_saves[("Save management<br/>[save_load.py]")]
  node_player["Player profile<br/>[player.py]"]
end

node_student(("Student"))

node_student -->|"starts game"| node_game
node_game -->|"runs level"| node_world
node_student -->|"registers with"| node_registration
node_world -->|"hosts player"| node_player
node_player -->|"loads and saves"| node_saves
node_student -->|"plays campaign"| node_missions
node_missions -->|"opens simulations"| node_simui
node_missions -->|"uses hints"| node_hints
node_missions -->|"applies penalties"| node_scoring
node_campaign -->|"defines routes"| node_missions
node_missions -->|"completes campaign"| node_results
node_simui -->|"sends requests"| node_api
node_simui -->|"selects model"| node_frontend_model
node_api -->|"validates requests"| node_schemas
node_api -->|"dispatches simulation"| node_simulator
node_simulator -->|"uses request types"| node_schemas
node_simulator -->|"uses gene rules"| node_gpr
node_simulator -->|"runs ROOM"| node_room
node_student -->|"enters preview"| node_teacher
node_teacher -->|"launches preview"| node_game

click node_game "https://github.com/hhtomaswt11/labhero/blob/main/LabHero.py"
click node_world "https://github.com/hhtomaswt11/labhero/blob/main/code/level.py"
click node_registration "https://github.com/hhtomaswt11/labhero/blob/main/code/student_registration.py"
click node_teacher "https://github.com/hhtomaswt11/labhero/blob/main/code/teacher_mode.py"
click node_missions "https://github.com/hhtomaswt11/labhero/tree/main/code"
click node_hints "https://github.com/hhtomaswt11/labhero/blob/main/code/hint_system.py"
click node_scoring "https://github.com/hhtomaswt11/labhero/blob/main/code/answer_penalty.py"
click node_campaign "https://github.com/hhtomaswt11/labhero/blob/main/code/campaign.py"
click node_results "https://github.com/hhtomaswt11/labhero/blob/main/code/final_results.py"
click node_simui "https://github.com/hhtomaswt11/labhero/blob/main/code/window.py"
click node_frontend_model "https://github.com/hhtomaswt11/labhero/blob/main/code/model_registry.py"
click node_api "https://github.com/hhtomaswt11/labhero/blob/main/backend/app/main.py"
click node_simulator "https://github.com/hhtomaswt11/labhero/blob/main/backend/app/simulator.py"
click node_schemas "https://github.com/hhtomaswt11/labhero/blob/main/backend/app/schemas.py"
click node_gpr "https://github.com/hhtomaswt11/labhero/blob/main/backend/app/gpr.py"
click node_room "https://github.com/hhtomaswt11/labhero/blob/main/backend/app/room_milp.py"
click node_saves "https://github.com/hhtomaswt11/labhero/blob/main/code/save_load.py"
click node_player "https://github.com/hhtomaswt11/labhero/blob/main/code/player.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_game,node_world,node_registration,node_teacher,node_simui toneBlue
class node_missions,node_hints,node_scoring,node_campaign,node_results toneAmber
class node_frontend_model,node_api,node_simulator,node_schemas,node_gpr,node_room toneMint
class node_saves,node_player toneRose
class node_student toneIndigo
```

## Components

### Game experience

- [Game runtime](https://github.com/hhtomaswt11/labhero/blob/main/LabHero.py): `LabHero.py`
- [Lab exploration](https://github.com/hhtomaswt11/labhero/blob/main/code/level.py): `code/level.py`
- [Student registration](https://github.com/hhtomaswt11/labhero/blob/main/code/student_registration.py): `code/student_registration.py`
- [Teacher preview](https://github.com/hhtomaswt11/labhero/blob/main/code/teacher_mode.py): `code/teacher_mode.py`
- [Simulator interface](https://github.com/hhtomaswt11/labhero/blob/main/code/window.py): `code/window.py`

### Learning and progression

- [Mission curriculum](https://github.com/hhtomaswt11/labhero/tree/main/code): `code`
- [Hints and rewards](https://github.com/hhtomaswt11/labhero/blob/main/code/hint_system.py): `code/hint_system.py`
- [Answer scoring](https://github.com/hhtomaswt11/labhero/blob/main/code/answer_penalty.py): `code/answer_penalty.py`
- [Campaign progression](https://github.com/hhtomaswt11/labhero/blob/main/code/campaign.py): `code/campaign.py`
- [Final results](https://github.com/hhtomaswt11/labhero/blob/main/code/final_results.py): `code/final_results.py`

### Simulation service

- [Model options](https://github.com/hhtomaswt11/labhero/blob/main/code/model_registry.py): `code/model_registry.py`
- [Simulation API](https://github.com/hhtomaswt11/labhero/blob/main/backend/app/main.py): `backend/app/main.py`
- [Model simulator](https://github.com/hhtomaswt11/labhero/blob/main/backend/app/simulator.py): `backend/app/simulator.py`
- [Request schemas](https://github.com/hhtomaswt11/labhero/blob/main/backend/app/schemas.py): `backend/app/schemas.py`
- [Gene rules](https://github.com/hhtomaswt11/labhero/blob/main/backend/app/gpr.py): `backend/app/gpr.py`
- [ROOM solver](https://github.com/hhtomaswt11/labhero/blob/main/backend/app/room_milp.py): `backend/app/room_milp.py`

### Player state

- [Save management](https://github.com/hhtomaswt11/labhero/blob/main/code/save_load.py): `code/save_load.py`
- [Player profile](https://github.com/hhtomaswt11/labhero/blob/main/code/player.py): `code/player.py`

### Other components

- **Student**

## Connections

- Student → Game runtime: starts game (evidence: `README.md`)
- Game runtime → Lab exploration: runs level (evidence: `LabHero.py`)
- Student → Student registration: registers with (evidence: `README.md`)
- Lab exploration → Player profile: hosts player (evidence: `code/level.py`)
- Player profile → Save management: loads and saves (evidence: `code/player.py`)
- Student → Mission curriculum: plays campaign (evidence: `README.md`)
- Mission curriculum → Simulator interface: opens simulations (evidence: `code/mission02.py`)
- Mission curriculum → Hints and rewards: uses hints (evidence: `code/mission11.py`)
- Mission curriculum → Answer scoring: applies penalties (evidence: `code/mission02.py`)
- Campaign progression → Mission curriculum: defines routes (evidence: `README.md`)
- Mission curriculum → Final results: completes campaign (evidence: `README.md`)
- Simulator interface → Simulation API: sends requests (evidence: `README.md`)
- Simulator interface → Model options: selects model (evidence: `code/window.py`)
- Simulation API → Request schemas: validates requests (evidence: `backend/app/main.py`)
- Simulation API → Model simulator: dispatches simulation (evidence: `backend/app/main.py`)
- Model simulator → Request schemas: uses request types (evidence: `backend/app/simulator.py`)
- Model simulator → Gene rules: uses gene rules (evidence: `backend/app/simulator.py`)
- Model simulator → ROOM solver: runs ROOM (evidence: `backend/app/simulator.py`)
- Student → Teacher preview: enters preview (evidence: `README.md`)
- Teacher preview → Game runtime: launches preview (evidence: `LabHero.py`)
