# trinhtt8/mentor-thena architecture

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

- Interactive diagram: https://gitdiagram.com/trinhtt8/mentor-thena
- Repository: https://github.com/trinhtt8/mentor-thena

## Overview

MentorThena helps elementary students complete coding quests: Python runs in the browser, the backend detects stuck states, supplies and checks progressively specific hints, and returns student status; correct output docks the student at Ithaca. Teachers assign quests and monitor the class Sea Map and class-level insights. The README documents this workflow and the major backend capabilities. Some frontend-to-API links are documented rather than visible in sampled API source; unsampled subsystem internals are represented only at their supported directory paths.

Main entry points: [`backend/app.py`](https://github.com/trinhtt8/mentor-thena/blob/main/backend/app.py) (Flask API), [`frontend/src/pages/StudentPage.jsx`](https://github.com/trinhtt8/mentor-thena/blob/main/frontend/src/pages/StudentPage.jsx) (Quest Workspace), [`backend/athena/hint_giver.py`](https://github.com/trinhtt8/mentor-thena/blob/main/backend/athena/hint_giver.py) (Hint Generation), [`backend/gemini_client.py`](https://github.com/trinhtt8/mentor-thena/blob/main/backend/gemini_client.py) (Gemini Service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_student["Student Voyage"]
  node_home["Voyage Map<br/>[HomePage.jsx]"]
  node_student_page["Quest Workspace<br/>[StudentPage.jsx]"]
  node_python_runner["Python Runner<br/>[pyodide-worker.js]"]
  node_student_ui["Student Components"]
  node_voyage_state["Voyage State<br/>[voyage.js]"]
  node_login["Login<br/>[LoginPage.jsx]"]
end

subgraph group_teacher["Teacher Fleet"]
  node_teacher_home["Class &amp; Quests<br/>[TeacherHome.jsx]"]
  node_sea_map_ui["Sea Map<br/>[TeacherPage.jsx]"]
  node_teacher_state["Demo &amp; Voyage Store<br/>[voyageStore.js]"]
end

subgraph group_guidance["Detection &amp; Guidance"]
  node_api_server["Flask API<br/>[app.py]"]
  node_argus["Stuck Detection<br/>[watcher.py]"]
  node_athena["Hint Generation<br/>[hint_giver.py]"]
  node_hint_rules["Hint Prompts &amp; Fallbacks<br/>[prompts.py]"]
  node_siren["Answer Guard<br/>[siren_guard.py]"]
  node_config["Runtime Settings<br/>[config.py]"]
end

subgraph group_data["Class Data &amp; Memory"]
  node_mongo[("MongoDB Atlas")]
  node_db_access["Database Access<br/>[db.py]"]
  node_ship_log["Helpful Hint Memory<br/>[memory.py]"]
  node_sea_map_data["Dashboard Data<br/>[dashboard.py]"]
  node_class_counts["Class Counts<br/>[class_counts.py]"]
  node_insights["Teacher Insight<br/>[insights.py]"]
end

node_student_actor(("Student"))
node_teacher_actor(("Teacher"))
node_api["API Client<br/>[api.js]"]
node_gemini["Gemini Service<br/>[gemini_client.py]"]

node_student_actor -->|"signs in"| node_login
node_login -->|"opens voyage"| node_home
node_student_actor -->|"writes code"| node_student_page
node_home -->|"opens quest"| node_student_page
node_student_page -->|"runs code"| node_python_runner
node_student_page -->|"sends run &amp; heartbeat"| node_api
node_python_runner -->|"returns output"| node_student_page
node_student_page -->|"renders"| node_student_ui
node_student_page -->|"uses voyage"| node_voyage_state
node_teacher_actor -->|"assigns quests"| node_teacher_home
node_teacher_actor -->|"monitors class"| node_sea_map_ui
node_teacher_home -->|"requests class data"| node_api
node_sea_map_ui -->|"refreshes dashboard"| node_api
node_teacher_home -->|"uses demo state"| node_teacher_state
node_sea_map_ui -->|"uses voyage state"| node_teacher_state
node_api -->|"calls JSON routes"| node_api_server
node_api_server -->|"checks student state"| node_argus
node_api_server -->|"requests hint"| node_athena
node_api_server -->|"requests ship data"| node_sea_map_data
node_api_server -->|"requests insight"| node_class_counts
node_athena -->|"builds hint prompt"| node_hint_rules
node_athena -->|"checks hint"| node_siren
node_athena -->|"generates hint"| node_gemini
node_siren -->|"checks hint safety"| node_gemini
node_athena -->|"looks up prior hint"| node_ship_log
node_api_server -->|"saves helpful hint"| node_ship_log
node_ship_log -->|"embeds bug"| node_gemini
node_db_access -->|"connects collections"| node_mongo
node_sea_map_data -->|"reads class records"| node_db_access
node_class_counts -->|"counts stuck students"| node_db_access
node_class_counts -->|"requests teacher tip"| node_insights
node_insights -->|"writes class tip"| node_gemini
node_config -->|"sets detection rules"| node_argus
node_config -->|"sets model settings"| node_gemini
node_api_server -->|"reads and writes"| node_db_access

click node_home "https://github.com/trinhtt8/mentor-thena/blob/main/frontend/src/pages/HomePage.jsx"
click node_student_page "https://github.com/trinhtt8/mentor-thena/blob/main/frontend/src/pages/StudentPage.jsx"
click node_python_runner "https://github.com/trinhtt8/mentor-thena/blob/main/frontend/public/pyodide-worker.js"
click node_student_ui "https://github.com/trinhtt8/mentor-thena/tree/main/frontend/src/components"
click node_voyage_state "https://github.com/trinhtt8/mentor-thena/blob/main/frontend/src/voyage.js"
click node_teacher_home "https://github.com/trinhtt8/mentor-thena/blob/main/frontend/src/pages/TeacherHome.jsx"
click node_sea_map_ui "https://github.com/trinhtt8/mentor-thena/blob/main/frontend/src/pages/TeacherPage.jsx"
click node_teacher_state "https://github.com/trinhtt8/mentor-thena/blob/main/frontend/src/voyageStore.js"
click node_api "https://github.com/trinhtt8/mentor-thena/blob/main/frontend/src/api.js"
click node_api_server "https://github.com/trinhtt8/mentor-thena/blob/main/backend/app.py"
click node_argus "https://github.com/trinhtt8/mentor-thena/blob/main/backend/argus/watcher.py"
click node_athena "https://github.com/trinhtt8/mentor-thena/blob/main/backend/athena/hint_giver.py"
click node_hint_rules "https://github.com/trinhtt8/mentor-thena/blob/main/backend/athena/prompts.py"
click node_siren "https://github.com/trinhtt8/mentor-thena/blob/main/backend/athena/siren_guard.py"
click node_gemini "https://github.com/trinhtt8/mentor-thena/blob/main/backend/gemini_client.py"
click node_db_access "https://github.com/trinhtt8/mentor-thena/blob/main/backend/db.py"
click node_ship_log "https://github.com/trinhtt8/mentor-thena/blob/main/backend/ships_log/memory.py"
click node_sea_map_data "https://github.com/trinhtt8/mentor-thena/blob/main/backend/seamap/dashboard.py"
click node_class_counts "https://github.com/trinhtt8/mentor-thena/blob/main/backend/tiresias/class_counts.py"
click node_insights "https://github.com/trinhtt8/mentor-thena/blob/main/backend/tiresias/insights.py"
click node_config "https://github.com/trinhtt8/mentor-thena/blob/main/backend/config.py"
click node_login "https://github.com/trinhtt8/mentor-thena/blob/main/frontend/src/pages/LoginPage.jsx"

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_home,node_student_page,node_python_runner,node_student_ui,node_voyage_state,node_login,node_api toneBlue
class node_teacher_home,node_sea_map_ui,node_teacher_state toneAmber
class node_api_server,node_argus,node_athena,node_hint_rules,node_siren,node_config toneMint
class node_mongo,node_db_access,node_ship_log,node_sea_map_data,node_class_counts,node_insights toneRose
class node_student_actor,node_teacher_actor toneIndigo
class node_gemini toneTeal
```

## Components

### Student Voyage

- [Voyage Map](https://github.com/trinhtt8/mentor-thena/blob/main/frontend/src/pages/HomePage.jsx): `frontend/src/pages/HomePage.jsx`
- [Quest Workspace](https://github.com/trinhtt8/mentor-thena/blob/main/frontend/src/pages/StudentPage.jsx): `frontend/src/pages/StudentPage.jsx`
- [Python Runner](https://github.com/trinhtt8/mentor-thena/blob/main/frontend/public/pyodide-worker.js): `frontend/public/pyodide-worker.js`
- [Student Components](https://github.com/trinhtt8/mentor-thena/tree/main/frontend/src/components): `frontend/src/components`
- [Voyage State](https://github.com/trinhtt8/mentor-thena/blob/main/frontend/src/voyage.js): `frontend/src/voyage.js`
- [Login](https://github.com/trinhtt8/mentor-thena/blob/main/frontend/src/pages/LoginPage.jsx): `frontend/src/pages/LoginPage.jsx`

### Teacher Fleet

- [Class & Quests](https://github.com/trinhtt8/mentor-thena/blob/main/frontend/src/pages/TeacherHome.jsx): `frontend/src/pages/TeacherHome.jsx`
- [Sea Map](https://github.com/trinhtt8/mentor-thena/blob/main/frontend/src/pages/TeacherPage.jsx): `frontend/src/pages/TeacherPage.jsx`
- [Demo & Voyage Store](https://github.com/trinhtt8/mentor-thena/blob/main/frontend/src/voyageStore.js): `frontend/src/voyageStore.js`

### Detection & Guidance

- [Flask API](https://github.com/trinhtt8/mentor-thena/blob/main/backend/app.py): `backend/app.py`
- [Stuck Detection](https://github.com/trinhtt8/mentor-thena/blob/main/backend/argus/watcher.py): `backend/argus/watcher.py`
- [Hint Generation](https://github.com/trinhtt8/mentor-thena/blob/main/backend/athena/hint_giver.py): `backend/athena/hint_giver.py`
- [Hint Prompts & Fallbacks](https://github.com/trinhtt8/mentor-thena/blob/main/backend/athena/prompts.py): `backend/athena/prompts.py`
- [Answer Guard](https://github.com/trinhtt8/mentor-thena/blob/main/backend/athena/siren_guard.py): `backend/athena/siren_guard.py`
- [Runtime Settings](https://github.com/trinhtt8/mentor-thena/blob/main/backend/config.py): `backend/config.py`

### Class Data & Memory

- **MongoDB Atlas**
- [Database Access](https://github.com/trinhtt8/mentor-thena/blob/main/backend/db.py): `backend/db.py`
- [Helpful Hint Memory](https://github.com/trinhtt8/mentor-thena/blob/main/backend/ships_log/memory.py): `backend/ships_log/memory.py`
- [Dashboard Data](https://github.com/trinhtt8/mentor-thena/blob/main/backend/seamap/dashboard.py): `backend/seamap/dashboard.py`
- [Class Counts](https://github.com/trinhtt8/mentor-thena/blob/main/backend/tiresias/class_counts.py): `backend/tiresias/class_counts.py`
- [Teacher Insight](https://github.com/trinhtt8/mentor-thena/blob/main/backend/tiresias/insights.py): `backend/tiresias/insights.py`

### Other components

- **Student**
- **Teacher**
- [API Client](https://github.com/trinhtt8/mentor-thena/blob/main/frontend/src/api.js): `frontend/src/api.js`
- [Gemini Service](https://github.com/trinhtt8/mentor-thena/blob/main/backend/gemini_client.py): `backend/gemini_client.py`

## Connections

- Student → Login: signs in (evidence: `README.md`)
- Login → Voyage Map: opens voyage (evidence: `frontend/src/App.jsx`)
- Student → Quest Workspace: writes code (evidence: `README.md`)
- Voyage Map → Quest Workspace: opens quest (evidence: `README.md`)
- Quest Workspace → Python Runner: runs code (evidence: `README.md`)
- Quest Workspace → API Client: sends run & heartbeat (evidence: `README.md`)
- Python Runner → Quest Workspace: returns output (evidence: `README.md`)
- Quest Workspace → Student Components: renders (evidence: `frontend/src/pages/StudentPage.jsx`)
- Quest Workspace → Voyage State: uses voyage
- Teacher → Class & Quests: assigns quests (evidence: `README.md`)
- Teacher → Sea Map: monitors class (evidence: `README.md`)
- Class & Quests → API Client: requests class data (evidence: `frontend/src/pages/TeacherHome.jsx`)
- Sea Map → API Client: refreshes dashboard (evidence: `README.md`)
- Class & Quests → Demo & Voyage Store: uses demo state (evidence: `frontend/src/pages/TeacherHome.jsx`)
- Sea Map → Demo & Voyage Store: uses voyage state (evidence: `frontend/src/pages/TeacherPage.jsx`)
- API Client → Flask API: calls JSON routes (evidence: `README.md`)
- Flask API → Stuck Detection: checks student state (evidence: `backend/app.py`)
- Flask API → Hint Generation: requests hint (evidence: `backend/app.py`)
- Flask API → Dashboard Data: requests ship data (evidence: `backend/app.py`)
- Flask API → Class Counts: requests insight (evidence: `backend/app.py`)
- Hint Generation → Hint Prompts & Fallbacks: builds hint prompt (evidence: `backend/athena/hint_giver.py`)
- Hint Generation → Answer Guard: checks hint (evidence: `backend/athena/hint_giver.py`)
- Hint Generation → Gemini Service: generates hint (evidence: `backend/athena/hint_giver.py`)
- Answer Guard → Gemini Service: checks hint safety (evidence: `backend/athena/siren_guard.py`)
- Hint Generation → Helpful Hint Memory: looks up prior hint (evidence: `backend/athena/hint_giver.py`)
- Flask API → Helpful Hint Memory: saves helpful hint (evidence: `README.md`)
- Helpful Hint Memory → Gemini Service: embeds bug (evidence: `backend/ships_log/memory.py`)
- Database Access → MongoDB Atlas: connects collections (evidence: `backend/db.py`)
- Dashboard Data → Database Access: reads class records (evidence: `backend/seamap/dashboard.py`)
- Class Counts → Database Access: counts stuck students (evidence: `backend/tiresias/class_counts.py`)
- Class Counts → Teacher Insight: requests teacher tip (evidence: `backend/tiresias/class_counts.py`)
- Teacher Insight → Gemini Service: writes class tip (evidence: `backend/tiresias/insights.py`)
- Runtime Settings → Stuck Detection: sets detection rules (evidence: `backend/argus/watcher.py`)
- Runtime Settings → Gemini Service: sets model settings (evidence: `backend/gemini_client.py`)
- Flask API → Database Access: reads and writes (evidence: `backend/app.py`)
