# praveenyt872/chemlab-digi architecture

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

- Interactive diagram: https://gitdiagram.com/praveenyt872/chemlab-digi
- Repository: https://github.com/praveenyt872/chemlab-digi

## Overview

LabFlow AI is a browser-based digital lab for chemical-engineering coursework, with student and teacher access, experiment workspaces, calculations, validation, AI tutoring, and report submission. The principal student journey is represented from app navigation through subject and experiment selection to the lab workspace; the listed workspace panels indicate its analysis and reporting capabilities. Sampled source confirms app routing, authentication and backend wiring, and the calculation, validation, AI, and submission services. Workspace internals are unsampled, so their specific calls are not asserted.

Main entry points: [`src/App.jsx`](https://github.com/praveenyt872/chemlab-digi/blob/main/src/App.jsx) (App Router), [`src/pages/WorkspacePage.jsx`](https://github.com/praveenyt872/chemlab-digi/blob/main/src/pages/WorkspacePage.jsx) (Lab Workspace), [`src/store/authStore.js`](https://github.com/praveenyt872/chemlab-digi/blob/main/src/store/authStore.js) (Auth State), [`src/components/auth/TeacherLogin.jsx`](https://github.com/praveenyt872/chemlab-digi/blob/main/src/components/auth/TeacherLogin.jsx) (Teacher Login)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_journey["Lab Journey"]
  node_app["App Router<br/>[App.jsx]"]
  node_landing["Landing<br/>[LandingPage.jsx]"]
  node_subjects["Subject Selection"]
  node_experiments["Experiment Selection"]
end

subgraph group_lab["Lab Workspace"]
  node_workspace["Lab Workspace<br/>[WorkspacePage.jsx]"]
  node_experiment_state["Experiment State<br/>[experimentStore.js]"]
  node_observations["Observation Entry"]
  node_formula_cards["Formula Reference<br/>[FormulaCard.jsx]"]
  node_calculations["Calculation Engine<br/>[formulaEngine.js]"]
  node_live_results["Live Results"]
  node_validation["Result Validation"]
  node_validation_panel["Validation Panel"]
  node_graphs["Experiment Graphs<br/>[GraphPanel.jsx]"]
  node_ai_widget["AI Lab Assistant<br/>[AIChatWidget.jsx]"]
  node_report_export["Report Export"]
end

subgraph group_identity["Access Control"]
  node_auth_store["Auth State<br/>[authStore.js]"]
  node_teacher_login["Teacher Login<br/>[TeacherLogin.jsx]"]
  node_student_gate["Student Access Gate<br/>[StudentGate.jsx]"]
end

subgraph group_services["Services"]
  node_ai_service["AI Tutor Service<br/>[aiService.js]"]
  node_submissions["Submission Service"]
  node_api_server["API Server<br/>[index.js]"]
  node_teacher_routes["Teacher Auth Routes<br/>[teacherAuth.js]"]
  node_db_module["Admin DB Client<br/>[db.js]"]
end

node_student(("Student"))
node_teacher(("Teacher"))
node_supabase[("Supabase")]
node_ai_providers(("AI Providers"))

node_student -->|"opens"| node_app
node_teacher -->|"opens"| node_app
node_app -->|"renders"| node_landing
node_app -->|"renders"| node_subjects
node_app -->|"renders"| node_experiments
node_app -->|"renders"| node_workspace
node_app -->|"renders"| node_teacher_login
node_app -->|"renders"| node_student_gate
node_app -->|"initializes"| node_auth_store
node_teacher_login -->|"authenticates"| node_auth_store
node_student_gate -->|"checks access"| node_auth_store
node_auth_store -->|"reads and writes"| node_supabase
node_auth_store -->|"requests"| node_api_server
node_api_server -->|"dispatches"| node_teacher_routes
node_teacher_routes -->|"uses"| node_db_module
node_db_module -->|"connects"| node_supabase
node_workspace -->|"renders"| node_observations
node_workspace -->|"renders"| node_formula_cards
node_workspace -->|"renders"| node_live_results
node_workspace -->|"renders"| node_validation_panel
node_workspace -->|"renders"| node_graphs
node_workspace -->|"renders"| node_report_export
node_ai_widget -->|"requests answers"| node_ai_service
node_ai_service -.->|"calls optionally"| node_ai_providers
node_submissions -->|"stores reports"| node_supabase

click node_app "https://github.com/praveenyt872/chemlab-digi/blob/main/src/App.jsx"
click node_landing "https://github.com/praveenyt872/chemlab-digi/blob/main/src/pages/LandingPage.jsx"
click node_subjects "https://github.com/praveenyt872/chemlab-digi/blob/main/src/pages/SubjectSelectPage.jsx"
click node_experiments "https://github.com/praveenyt872/chemlab-digi/blob/main/src/pages/ExperimentSelectPage.jsx"
click node_workspace "https://github.com/praveenyt872/chemlab-digi/blob/main/src/pages/WorkspacePage.jsx"
click node_experiment_state "https://github.com/praveenyt872/chemlab-digi/blob/main/src/store/experimentStore.js"
click node_observations "https://github.com/praveenyt872/chemlab-digi/blob/main/src/components/workspace/ObservationTable.jsx"
click node_formula_cards "https://github.com/praveenyt872/chemlab-digi/blob/main/src/components/workspace/FormulaCard.jsx"
click node_calculations "https://github.com/praveenyt872/chemlab-digi/blob/main/src/engine/formulaEngine.js"
click node_live_results "https://github.com/praveenyt872/chemlab-digi/blob/main/src/components/workspace/LiveResultsPanel.jsx"
click node_validation "https://github.com/praveenyt872/chemlab-digi/blob/main/src/engine/validationEngine.js"
click node_validation_panel "https://github.com/praveenyt872/chemlab-digi/blob/main/src/components/workspace/AIValidationPanel.jsx"
click node_graphs "https://github.com/praveenyt872/chemlab-digi/blob/main/src/components/workspace/GraphPanel.jsx"
click node_ai_widget "https://github.com/praveenyt872/chemlab-digi/blob/main/src/components/workspace/AIChatWidget.jsx"
click node_ai_service "https://github.com/praveenyt872/chemlab-digi/blob/main/src/engine/aiService.js"
click node_report_export "https://github.com/praveenyt872/chemlab-digi/blob/main/src/components/modals/ReportExportModal.jsx"
click node_submissions "https://github.com/praveenyt872/chemlab-digi/blob/main/src/utils/submissionService.js"
click node_auth_store "https://github.com/praveenyt872/chemlab-digi/blob/main/src/store/authStore.js"
click node_teacher_login "https://github.com/praveenyt872/chemlab-digi/blob/main/src/components/auth/TeacherLogin.jsx"
click node_student_gate "https://github.com/praveenyt872/chemlab-digi/blob/main/src/components/auth/StudentGate.jsx"
click node_api_server "https://github.com/praveenyt872/chemlab-digi/blob/main/server/index.js"
click node_teacher_routes "https://github.com/praveenyt872/chemlab-digi/blob/main/server/routes/teacherAuth.js"
click node_db_module "https://github.com/praveenyt872/chemlab-digi/blob/main/server/db.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_app,node_landing,node_subjects,node_experiments toneBlue
class node_workspace,node_experiment_state,node_observations,node_formula_cards,node_calculations,node_live_results,node_validation,node_validation_panel,node_graphs,node_ai_widget,node_report_export,node_supabase toneAmber
class node_auth_store,node_teacher_login,node_student_gate toneMint
class node_ai_service,node_submissions,node_api_server,node_teacher_routes,node_db_module toneRose
class node_student,node_teacher,node_ai_providers toneIndigo
```

## Components

### Lab Journey

- [App Router](https://github.com/praveenyt872/chemlab-digi/blob/main/src/App.jsx): `src/App.jsx`
- [Landing](https://github.com/praveenyt872/chemlab-digi/blob/main/src/pages/LandingPage.jsx): `src/pages/LandingPage.jsx`
- [Subject Selection](https://github.com/praveenyt872/chemlab-digi/blob/main/src/pages/SubjectSelectPage.jsx): `src/pages/SubjectSelectPage.jsx`
- [Experiment Selection](https://github.com/praveenyt872/chemlab-digi/blob/main/src/pages/ExperimentSelectPage.jsx): `src/pages/ExperimentSelectPage.jsx`

### Lab Workspace

- [Lab Workspace](https://github.com/praveenyt872/chemlab-digi/blob/main/src/pages/WorkspacePage.jsx): `src/pages/WorkspacePage.jsx`
- [Experiment State](https://github.com/praveenyt872/chemlab-digi/blob/main/src/store/experimentStore.js): `src/store/experimentStore.js`
- [Observation Entry](https://github.com/praveenyt872/chemlab-digi/blob/main/src/components/workspace/ObservationTable.jsx): `src/components/workspace/ObservationTable.jsx`
- [Formula Reference](https://github.com/praveenyt872/chemlab-digi/blob/main/src/components/workspace/FormulaCard.jsx): `src/components/workspace/FormulaCard.jsx`
- [Calculation Engine](https://github.com/praveenyt872/chemlab-digi/blob/main/src/engine/formulaEngine.js): `src/engine/formulaEngine.js`
- [Live Results](https://github.com/praveenyt872/chemlab-digi/blob/main/src/components/workspace/LiveResultsPanel.jsx): `src/components/workspace/LiveResultsPanel.jsx`
- [Result Validation](https://github.com/praveenyt872/chemlab-digi/blob/main/src/engine/validationEngine.js): `src/engine/validationEngine.js`
- [Validation Panel](https://github.com/praveenyt872/chemlab-digi/blob/main/src/components/workspace/AIValidationPanel.jsx): `src/components/workspace/AIValidationPanel.jsx`
- [Experiment Graphs](https://github.com/praveenyt872/chemlab-digi/blob/main/src/components/workspace/GraphPanel.jsx): `src/components/workspace/GraphPanel.jsx`
- [AI Lab Assistant](https://github.com/praveenyt872/chemlab-digi/blob/main/src/components/workspace/AIChatWidget.jsx): `src/components/workspace/AIChatWidget.jsx`
- [Report Export](https://github.com/praveenyt872/chemlab-digi/blob/main/src/components/modals/ReportExportModal.jsx): `src/components/modals/ReportExportModal.jsx`

### Access Control

- [Auth State](https://github.com/praveenyt872/chemlab-digi/blob/main/src/store/authStore.js): `src/store/authStore.js`
- [Teacher Login](https://github.com/praveenyt872/chemlab-digi/blob/main/src/components/auth/TeacherLogin.jsx): `src/components/auth/TeacherLogin.jsx`
- [Student Access Gate](https://github.com/praveenyt872/chemlab-digi/blob/main/src/components/auth/StudentGate.jsx): `src/components/auth/StudentGate.jsx`

### Services

- [AI Tutor Service](https://github.com/praveenyt872/chemlab-digi/blob/main/src/engine/aiService.js): `src/engine/aiService.js`
- [Submission Service](https://github.com/praveenyt872/chemlab-digi/blob/main/src/utils/submissionService.js): `src/utils/submissionService.js`
- [API Server](https://github.com/praveenyt872/chemlab-digi/blob/main/server/index.js): `server/index.js`
- [Teacher Auth Routes](https://github.com/praveenyt872/chemlab-digi/blob/main/server/routes/teacherAuth.js): `server/routes/teacherAuth.js`
- [Admin DB Client](https://github.com/praveenyt872/chemlab-digi/blob/main/server/db.js): `server/db.js`

### Other components

- **Student**
- **Teacher**
- **Supabase**
- **AI Providers**

## Connections

- Student → App Router: opens
- Teacher → App Router: opens
- App Router → Landing: renders
- App Router → Subject Selection: renders
- App Router → Experiment Selection: renders
- App Router → Lab Workspace: renders
- App Router → Teacher Login: renders
- App Router → Student Access Gate: renders
- App Router → Auth State: initializes
- Teacher Login → Auth State: authenticates
- Student Access Gate → Auth State: checks access
- Auth State → Supabase: reads and writes
- Auth State → API Server: requests
- API Server → Teacher Auth Routes: dispatches
- Teacher Auth Routes → Admin DB Client: uses
- Admin DB Client → Supabase: connects
- Lab Workspace → Observation Entry: renders
- Lab Workspace → Formula Reference: renders
- Lab Workspace → Live Results: renders
- Lab Workspace → Validation Panel: renders
- Lab Workspace → Experiment Graphs: renders
- Lab Workspace → Report Export: renders
- AI Lab Assistant → AI Tutor Service: requests answers
- AI Tutor Service → AI Providers: calls optionally
- Submission Service → Supabase: stores reports
