# d0t-j/tutre architecture

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

- Interactive diagram: https://gitdiagram.com/d0t-j/tutre
- Repository: https://github.com/d0t-j/tutre

## Overview

Tutre is a STEM learning platform with independent staff and student React portals backed by Supabase. Teachers manage curriculum and create, preview, and publish AI-generated simulations; students browse the curriculum, run simulations in a sandboxed iframe, and chat with an AI tutor. The graph reflects the README’s documented workflow and capabilities plus the supplied source excerpts. Backend function internals and several feature implementations were not sampled, so undocumented connections are omitted.

Main entry points: [`admin-panel/src/features/simulations`](https://github.com/d0t-j/tutre/tree/main/admin-panel/src/features/simulations) (Simulation studio), [`supabase/functions/generate-simulation/index.ts`](https://github.com/d0t-j/tutre/blob/main/supabase/functions/generate-simulation/index.ts) (Simulation generation), [`supabase/functions/chat-tutor/index.ts`](https://github.com/d0t-j/tutre/blob/main/supabase/functions/chat-tutor/index.ts) (Tutor function), [`student-panel/src/pages/Simulations/SimulationViewer.jsx`](https://github.com/d0t-j/tutre/blob/main/student-panel/src/pages/Simulations/SimulationViewer.jsx) (Simulation viewer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_staff["Staff portal"]
  node_admin_routes["Staff routes<br/>[AppRoutes.jsx]"]
  node_studio["Simulation studio"]
  node_save_sim["Save simulation"]
end

subgraph group_learning["Student learning"]
  node_student_routes["Student routes<br/>[AppRoutes.jsx]"]
  node_dashboard["Curriculum browsing<br/>[Dashboard.jsx]"]
  node_viewer["Simulation viewer"]
  node_iframe["Sandboxed simulation<br/>[ViewerIframe.jsx]"]
  node_tutor_chat["AI tutor chat"]
  node_study_guides["Study guides"]
  node_progress["Learning progress<br/>[useProgress.js]"]
end

subgraph group_backend["Supabase backend"]
  node_database[("Supabase database")]
  node_generate["Simulation generation<br/>[index.ts]"]
  node_generate_3d["3D generation<br/>[index.ts]"]
  node_chat_function["Tutor function<br/>[index.ts]"]
  node_extract["HTML detail extraction<br/>[index.ts]"]
  node_suggest["Requirement suggestions<br/>[index.ts]"]
  node_translate["Content translation<br/>[index.ts]"]
  node_whatsapp["WhatsApp delivery<br/>[index.ts]"]
end

subgraph group_management["School and curriculum"]
  node_curriculum["Curriculum manager"]
  node_school_admin["School administration"]
  node_organization_admin["Organizations"]
end

node_teacher(("Teacher"))
node_student(("Student"))
node_ai_service{{"AI services"}}

node_teacher -->|"uses"| node_admin_routes
node_admin_routes -->|"routes to"| node_studio
node_teacher -->|"manages"| node_curriculum
node_teacher -->|"manages school"| node_school_admin
node_teacher -->|"manages"| node_organization_admin
node_studio -->|"requests generation"| node_generate
node_studio -.->|"requests generation"| node_generate_3d
node_generate -->|"generates HTML"| node_ai_service
node_generate_3d -.->|"generates simulation"| node_ai_service
node_generate -->|"returns HTML"| node_studio
node_generate_3d -.->|"returns result"| node_studio
node_studio -.->|"saves draft"| node_save_sim
node_save_sim -->|"writes topic and simulation"| node_database
node_teacher -->|"previews and publishes"| node_studio
node_student -->|"uses"| node_student_routes
node_student_routes -->|"routes to"| node_dashboard
node_student_routes -->|"routes to"| node_viewer
node_student -->|"browses curriculum"| node_dashboard
node_dashboard -->|"selects simulations"| node_database
node_student -->|"opens simulation"| node_viewer
node_viewer -->|"loads simulation"| node_database
node_viewer -->|"renders sandboxed"| node_iframe
node_student -->|"asks questions"| node_tutor_chat
node_tutor_chat -->|"requests streamed answer"| node_chat_function
node_chat_function -.->|"generates answer"| node_ai_service
node_chat_function -->|"streams answer"| node_tutor_chat
node_student -->|"exports guides"| node_study_guides
node_study_guides -.->|"sends guide"| node_whatsapp
node_student -.->|"views progress"| node_progress
node_progress -.->|"reads progress"| node_database
node_studio -.->|"extracts HTML details"| node_extract
node_studio -.->|"gets requirement suggestions"| node_suggest
node_studio -.->|"translates content"| node_translate
node_generate -.->|"uses backend"| node_database
node_chat_function -.->|"uses backend"| node_database

click node_admin_routes "https://github.com/d0t-j/tutre/blob/main/admin-panel/src/routes/AppRoutes.jsx"
click node_studio "https://github.com/d0t-j/tutre/tree/main/admin-panel/src/features/simulations"
click node_save_sim "https://github.com/d0t-j/tutre/blob/main/admin-panel/src/features/simulations/hooks/useSimulationStorage.js"
click node_curriculum "https://github.com/d0t-j/tutre/blob/main/admin-panel/src/pages/Curriculum/CurriculumManager.jsx"
click node_school_admin "https://github.com/d0t-j/tutre/tree/main/admin-panel/src/features/school"
click node_organization_admin "https://github.com/d0t-j/tutre/tree/main/admin-panel/src/features/organizations"
click node_student_routes "https://github.com/d0t-j/tutre/blob/main/student-panel/src/routes/AppRoutes.jsx"
click node_dashboard "https://github.com/d0t-j/tutre/blob/main/student-panel/src/pages/Dashboard/Dashboard.jsx"
click node_viewer "https://github.com/d0t-j/tutre/blob/main/student-panel/src/pages/Simulations/SimulationViewer.jsx"
click node_iframe "https://github.com/d0t-j/tutre/blob/main/student-panel/src/features/simulations/components/ViewerIframe.jsx"
click node_tutor_chat "https://github.com/d0t-j/tutre/blob/main/student-panel/src/features/simulations/hooks/useChatbotStream.js"
click node_study_guides "https://github.com/d0t-j/tutre/tree/main/student-panel/src/features/simulations"
click node_progress "https://github.com/d0t-j/tutre/blob/main/student-panel/src/features/progress/hooks/useProgress.js"
click node_generate "https://github.com/d0t-j/tutre/blob/main/supabase/functions/generate-simulation/index.ts"
click node_generate_3d "https://github.com/d0t-j/tutre/blob/main/supabase/functions/generate-simulation-3d/index.ts"
click node_chat_function "https://github.com/d0t-j/tutre/blob/main/supabase/functions/chat-tutor/index.ts"
click node_extract "https://github.com/d0t-j/tutre/blob/main/supabase/functions/extract-html-details/index.ts"
click node_suggest "https://github.com/d0t-j/tutre/blob/main/supabase/functions/suggest-requirements/index.ts"
click node_translate "https://github.com/d0t-j/tutre/blob/main/supabase/functions/translate-content/index.ts"
click node_whatsapp "https://github.com/d0t-j/tutre/blob/main/supabase/functions/send-whatsapp/index.ts"

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_admin_routes,node_studio,node_save_sim toneBlue
class node_student_routes,node_dashboard,node_viewer,node_iframe,node_tutor_chat,node_study_guides,node_progress toneAmber
class node_database,node_generate,node_generate_3d,node_chat_function,node_extract,node_suggest,node_translate,node_whatsapp toneMint
class node_curriculum,node_school_admin,node_organization_admin toneRose
class node_teacher,node_student,node_ai_service toneIndigo
```

## Components

### Staff portal

- [Staff routes](https://github.com/d0t-j/tutre/blob/main/admin-panel/src/routes/AppRoutes.jsx): `admin-panel/src/routes/AppRoutes.jsx`
- [Simulation studio](https://github.com/d0t-j/tutre/tree/main/admin-panel/src/features/simulations): `admin-panel/src/features/simulations`
- [Save simulation](https://github.com/d0t-j/tutre/blob/main/admin-panel/src/features/simulations/hooks/useSimulationStorage.js): `admin-panel/src/features/simulations/hooks/useSimulationStorage.js`

### Student learning

- [Student routes](https://github.com/d0t-j/tutre/blob/main/student-panel/src/routes/AppRoutes.jsx): `student-panel/src/routes/AppRoutes.jsx`
- [Curriculum browsing](https://github.com/d0t-j/tutre/blob/main/student-panel/src/pages/Dashboard/Dashboard.jsx): `student-panel/src/pages/Dashboard/Dashboard.jsx`
- [Simulation viewer](https://github.com/d0t-j/tutre/blob/main/student-panel/src/pages/Simulations/SimulationViewer.jsx): `student-panel/src/pages/Simulations/SimulationViewer.jsx`
- [Sandboxed simulation](https://github.com/d0t-j/tutre/blob/main/student-panel/src/features/simulations/components/ViewerIframe.jsx): `student-panel/src/features/simulations/components/ViewerIframe.jsx`
- [AI tutor chat](https://github.com/d0t-j/tutre/blob/main/student-panel/src/features/simulations/hooks/useChatbotStream.js): `student-panel/src/features/simulations/hooks/useChatbotStream.js`
- [Study guides](https://github.com/d0t-j/tutre/tree/main/student-panel/src/features/simulations): `student-panel/src/features/simulations`
- [Learning progress](https://github.com/d0t-j/tutre/blob/main/student-panel/src/features/progress/hooks/useProgress.js): `student-panel/src/features/progress/hooks/useProgress.js`

### Supabase backend

- **Supabase database**
- [Simulation generation](https://github.com/d0t-j/tutre/blob/main/supabase/functions/generate-simulation/index.ts): `supabase/functions/generate-simulation/index.ts`
- [3D generation](https://github.com/d0t-j/tutre/blob/main/supabase/functions/generate-simulation-3d/index.ts): `supabase/functions/generate-simulation-3d/index.ts`
- [Tutor function](https://github.com/d0t-j/tutre/blob/main/supabase/functions/chat-tutor/index.ts): `supabase/functions/chat-tutor/index.ts`
- [HTML detail extraction](https://github.com/d0t-j/tutre/blob/main/supabase/functions/extract-html-details/index.ts): `supabase/functions/extract-html-details/index.ts`
- [Requirement suggestions](https://github.com/d0t-j/tutre/blob/main/supabase/functions/suggest-requirements/index.ts): `supabase/functions/suggest-requirements/index.ts`
- [Content translation](https://github.com/d0t-j/tutre/blob/main/supabase/functions/translate-content/index.ts): `supabase/functions/translate-content/index.ts`
- [WhatsApp delivery](https://github.com/d0t-j/tutre/blob/main/supabase/functions/send-whatsapp/index.ts): `supabase/functions/send-whatsapp/index.ts`

### School and curriculum

- [Curriculum manager](https://github.com/d0t-j/tutre/blob/main/admin-panel/src/pages/Curriculum/CurriculumManager.jsx): `admin-panel/src/pages/Curriculum/CurriculumManager.jsx`
- [School administration](https://github.com/d0t-j/tutre/tree/main/admin-panel/src/features/school): `admin-panel/src/features/school`
- [Organizations](https://github.com/d0t-j/tutre/tree/main/admin-panel/src/features/organizations): `admin-panel/src/features/organizations`

### Other components

- **Teacher**
- **Student**
- **AI services**

## Connections

- Teacher → Staff routes: uses (evidence: `README.md`)
- Staff routes → Simulation studio: routes to (evidence: `admin-panel/src/routes/AppRoutes.jsx`)
- Teacher → Curriculum manager: manages (evidence: `README.md`)
- Teacher → School administration: manages school (evidence: `README.md`)
- Teacher → Organizations: manages (evidence: `README.md`)
- Simulation studio → Simulation generation: requests generation (evidence: `README.md`)
- Simulation studio → 3D generation: requests generation
- Simulation generation → AI services: generates HTML (evidence: `README.md`)
- 3D generation → AI services: generates simulation
- Simulation generation → Simulation studio: returns HTML (evidence: `README.md`)
- 3D generation → Simulation studio: returns result
- Simulation studio → Save simulation: saves draft
- Save simulation → Supabase database: writes topic and simulation (evidence: `admin-panel/src/features/simulations/hooks/useSimulationStorage.js`)
- Teacher → Simulation studio: previews and publishes (evidence: `README.md`)
- Student → Student routes: uses (evidence: `README.md`)
- Student routes → Curriculum browsing: routes to (evidence: `student-panel/src/routes/AppRoutes.jsx`)
- Student routes → Simulation viewer: routes to (evidence: `student-panel/src/routes/AppRoutes.jsx`)
- Student → Curriculum browsing: browses curriculum (evidence: `README.md`)
- Curriculum browsing → Supabase database: selects simulations (evidence: `README.md`)
- Student → Simulation viewer: opens simulation (evidence: `README.md`)
- Simulation viewer → Supabase database: loads simulation (evidence: `README.md`)
- Simulation viewer → Sandboxed simulation: renders sandboxed (evidence: `README.md`)
- Student → AI tutor chat: asks questions (evidence: `README.md`)
- AI tutor chat → Tutor function: requests streamed answer (evidence: `README.md`)
- Tutor function → AI services: generates answer
- Tutor function → AI tutor chat: streams answer (evidence: `README.md`)
- Student → Study guides: exports guides (evidence: `README.md`)
- Study guides → WhatsApp delivery: sends guide
- Student → Learning progress: views progress
- Learning progress → Supabase database: reads progress
- Simulation studio → HTML detail extraction: extracts HTML details
- Simulation studio → Requirement suggestions: gets requirement suggestions
- Simulation studio → Content translation: translates content
- Simulation generation → Supabase database: uses backend
- Tutor function → Supabase database: uses backend
