# rhea-15/mindscope architecture

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

- Interactive diagram: https://gitdiagram.com/rhea-15/mindscope
- Repository: https://github.com/rhea-15/mindscope

## Overview

MindScope is a student wellbeing screening app: students submit a guided assessment, receive a stress prediction with explanations and coping suggestions, and can review their results over time. The backend scales inputs, predicts with XGBoost, generates SHAP factors and interventions, and stores assessments in SQLite. The frontend also provides dashboard, printable insights, history management, and a self-help recommendations library. Relationships for the main prediction flow are documented in the README and backend excerpt; unsampled frontend wiring is not inferred.

Main entry points: [`backend/main.py`](https://github.com/rhea-15/mindscope/blob/master/backend/main.py) (FastAPI routes), [`frontend/lib/api.ts`](https://github.com/rhea-15/mindscope/blob/master/frontend/lib/api.ts) (API client), [`frontend/components/forms/AssessmentForm.tsx`](https://github.com/rhea-15/mindscope/blob/master/frontend/components/forms/AssessmentForm.tsx) (Guided assessment), [`frontend/app/student/dashboard/page.tsx`](https://github.com/rhea-15/mindscope/blob/master/frontend/app/student/dashboard/page.tsx) (Student dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_student_ui["Student experience"]
  node_entry["Sign-in entry<br/>[page.tsx]"]
  node_assessment_page["Assessment route<br/>[page.tsx]"]
  node_assessment_form["Guided assessment<br/>[AssessmentForm.tsx]"]
  node_dashboard["Student dashboard<br/>[page.tsx]"]
  node_insights["Stress insights<br/>[page.tsx]"]
  node_history["Assessment history<br/>[page.tsx]"]
  node_recommendations["Recommendations toolkit<br/>[page.tsx]"]
  node_visualizations["Charts and metrics<br/>[MetricCard.tsx]"]
end

subgraph group_frontend_services["Frontend services"]
  node_api_client["API client<br/>[api.ts]"]
  node_shared_types["Assessment types<br/>[index.ts]"]
end

subgraph group_assessment_engine["Assessment engine"]
  node_backend_api["FastAPI routes<br/>[main.py]"]
  node_input_scaling["Input scaling<br/>[main.py]"]
  node_stress_model["Stress prediction<br/>[main.py]"]
  node_shap_explanations["SHAP factors<br/>[main.py]"]
  node_coping_suggestions["Coping suggestions<br/>[main.py]"]
  node_training_pipeline["Model training<br/>[train.py]"]
end

subgraph group_persistence["Assessment records"]
  node_assessment_store[("SQLite assessments<br/>[main.py]")]
end

node_student(("Student"))

node_student -->|"opens"| node_entry
node_entry -.->|"routes to"| node_assessment_page
node_assessment_page -->|"presents"| node_assessment_form
node_assessment_form -->|"submits"| node_api_client
node_api_client -->|"POST /predict"| node_backend_api
node_backend_api -->|"scales inputs"| node_input_scaling
node_backend_api -->|"predicts class"| node_stress_model
node_backend_api -->|"gets factors"| node_shap_explanations
node_backend_api -->|"generates suggestions"| node_coping_suggestions
node_backend_api -->|"saves result"| node_assessment_store
node_stress_model -.->|"uses trained artifacts"| node_training_pipeline
node_backend_api -->|"queries history"| node_assessment_store
node_api_client -->|"history API"| node_assessment_store
node_history -->|"loads and manages"| node_api_client
node_dashboard -->|"loads history"| node_api_client
node_insights -->|"renders gauge"| node_visualizations
node_insights -->|"uses result types"| node_shared_types
node_history -->|"renders trend"| node_visualizations
node_dashboard -.->|"shows trend"| node_visualizations
node_assessment_form -.->|"uses input types"| node_shared_types
node_student -->|"views wellbeing"| node_dashboard
node_student -->|"reviews result"| node_insights
node_student -->|"reviews records"| node_history
node_student -->|"explores toolkit"| node_recommendations
node_assessment_store -.->|"seeded demo data"| node_assessment_store

click node_entry "https://github.com/rhea-15/mindscope/blob/master/frontend/app/page.tsx"
click node_assessment_page "https://github.com/rhea-15/mindscope/blob/master/frontend/app/student/assessment/page.tsx"
click node_assessment_form "https://github.com/rhea-15/mindscope/blob/master/frontend/components/forms/AssessmentForm.tsx"
click node_dashboard "https://github.com/rhea-15/mindscope/blob/master/frontend/app/student/dashboard/page.tsx"
click node_insights "https://github.com/rhea-15/mindscope/blob/master/frontend/app/student/insights/page.tsx"
click node_history "https://github.com/rhea-15/mindscope/blob/master/frontend/app/student/history/page.tsx"
click node_recommendations "https://github.com/rhea-15/mindscope/blob/master/frontend/app/student/recommendations/page.tsx"
click node_visualizations "https://github.com/rhea-15/mindscope/blob/master/frontend/components/charts/MetricCard.tsx"
click node_api_client "https://github.com/rhea-15/mindscope/blob/master/frontend/lib/api.ts"
click node_shared_types "https://github.com/rhea-15/mindscope/blob/master/frontend/types/index.ts"
click node_backend_api "https://github.com/rhea-15/mindscope/blob/master/backend/main.py"
click node_input_scaling "https://github.com/rhea-15/mindscope/blob/master/backend/main.py"
click node_stress_model "https://github.com/rhea-15/mindscope/blob/master/backend/main.py"
click node_shap_explanations "https://github.com/rhea-15/mindscope/blob/master/backend/main.py"
click node_coping_suggestions "https://github.com/rhea-15/mindscope/blob/master/backend/main.py"
click node_training_pipeline "https://github.com/rhea-15/mindscope/blob/master/backend/train.py"
click node_assessment_store "https://github.com/rhea-15/mindscope/blob/master/backend/main.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_entry,node_assessment_page,node_assessment_form,node_dashboard,node_insights,node_history,node_recommendations,node_visualizations toneBlue
class node_api_client,node_shared_types toneAmber
class node_backend_api,node_input_scaling,node_stress_model,node_shap_explanations,node_coping_suggestions,node_training_pipeline toneMint
class node_assessment_store toneRose
class node_student toneIndigo
```

## Components

### Student experience

- [Sign-in entry](https://github.com/rhea-15/mindscope/blob/master/frontend/app/page.tsx): `frontend/app/page.tsx`
- [Assessment route](https://github.com/rhea-15/mindscope/blob/master/frontend/app/student/assessment/page.tsx): `frontend/app/student/assessment/page.tsx`
- [Guided assessment](https://github.com/rhea-15/mindscope/blob/master/frontend/components/forms/AssessmentForm.tsx): `frontend/components/forms/AssessmentForm.tsx`
- [Student dashboard](https://github.com/rhea-15/mindscope/blob/master/frontend/app/student/dashboard/page.tsx): `frontend/app/student/dashboard/page.tsx`
- [Stress insights](https://github.com/rhea-15/mindscope/blob/master/frontend/app/student/insights/page.tsx): `frontend/app/student/insights/page.tsx`
- [Assessment history](https://github.com/rhea-15/mindscope/blob/master/frontend/app/student/history/page.tsx): `frontend/app/student/history/page.tsx`
- [Recommendations toolkit](https://github.com/rhea-15/mindscope/blob/master/frontend/app/student/recommendations/page.tsx): `frontend/app/student/recommendations/page.tsx`
- [Charts and metrics](https://github.com/rhea-15/mindscope/blob/master/frontend/components/charts/MetricCard.tsx): `frontend/components/charts/MetricCard.tsx`

### Frontend services

- [API client](https://github.com/rhea-15/mindscope/blob/master/frontend/lib/api.ts): `frontend/lib/api.ts`
- [Assessment types](https://github.com/rhea-15/mindscope/blob/master/frontend/types/index.ts): `frontend/types/index.ts`

### Assessment engine

- [FastAPI routes](https://github.com/rhea-15/mindscope/blob/master/backend/main.py): `backend/main.py`
- [Input scaling](https://github.com/rhea-15/mindscope/blob/master/backend/main.py): `backend/main.py`
- [Stress prediction](https://github.com/rhea-15/mindscope/blob/master/backend/main.py): `backend/main.py`
- [SHAP factors](https://github.com/rhea-15/mindscope/blob/master/backend/main.py): `backend/main.py`
- [Coping suggestions](https://github.com/rhea-15/mindscope/blob/master/backend/main.py): `backend/main.py`
- [Model training](https://github.com/rhea-15/mindscope/blob/master/backend/train.py): `backend/train.py`

### Assessment records

- [SQLite assessments](https://github.com/rhea-15/mindscope/blob/master/backend/main.py): `backend/main.py`

### Other components

- **Student**

## Connections

- Student → Sign-in entry: opens (evidence: `frontend/app/page.tsx`)
- Sign-in entry → Assessment route: routes to
- Assessment route → Guided assessment: presents (evidence: `README.md`)
- Guided assessment → API client: submits (evidence: `README.md`)
- API client → FastAPI routes: POST /predict (evidence: `README.md`)
- FastAPI routes → Input scaling: scales inputs (evidence: `backend/main.py`)
- FastAPI routes → Stress prediction: predicts class (evidence: `backend/main.py`)
- FastAPI routes → SHAP factors: gets factors (evidence: `backend/main.py`)
- FastAPI routes → Coping suggestions: generates suggestions (evidence: `backend/main.py`)
- FastAPI routes → SQLite assessments: saves result (evidence: `backend/main.py`)
- Stress prediction → Model training: uses trained artifacts
- FastAPI routes → SQLite assessments: queries history (evidence: `backend/main.py`)
- API client → SQLite assessments: history API (evidence: `README.md`)
- Assessment history → API client: loads and manages (evidence: `frontend/app/student/history/page.tsx`)
- Student dashboard → API client: loads history (evidence: `README.md`)
- Stress insights → Charts and metrics: renders gauge (evidence: `frontend/app/student/insights/page.tsx`)
- Stress insights → Assessment types: uses result types (evidence: `frontend/app/student/insights/page.tsx`)
- Assessment history → Charts and metrics: renders trend (evidence: `frontend/app/student/history/page.tsx`)
- Student dashboard → Charts and metrics: shows trend
- Guided assessment → Assessment types: uses input types
- Student → Student dashboard: views wellbeing (evidence: `README.md`)
- Student → Stress insights: reviews result (evidence: `README.md`)
- Student → Assessment history: reviews records (evidence: `README.md`)
- Student → Recommendations toolkit: explores toolkit (evidence: `README.md`)
- SQLite assessments → SQLite assessments: seeded demo data (evidence: `backend/main.py`)
