# pasupulasaiteja/mindguardai architecture

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

- Interactive diagram: https://gitdiagram.com/pasupulasaiteja/mindguardai
- Repository: https://github.com/pasupulasaiteja/mindguardai

## Overview

MindGuardAI is a higher-education mental-wellness platform for students, counselors, and campus administrators. The main journey runs from student check-ins and passive device telemetry through clinical/ML assessment and longitudinal analysis to student-facing support and counselor triage; administrators also receive cohort analytics. The graph preserves documented privacy, consent, notifications, appointments, and screening capabilities. Several API and service implementations were not sampled, so their internal call relationships are not asserted.

Main entry points: [`backend/app/main.py`](https://github.com/pasupulasaiteja/mindguardai/blob/main/backend/app/main.py) (FastAPI gateway), [`frontend/src/App.tsx`](https://github.com/pasupulasaiteja/mindguardai/blob/main/frontend/src/App.tsx) (Client routing), [`backend/app/db/session.py`](https://github.com/pasupulasaiteja/mindguardai/blob/main/backend/app/db/session.py) (SQL database), [`frontend/src/pages/student/StudentDashboard.tsx`](https://github.com/pasupulasaiteja/mindguardai/blob/main/frontend/src/pages/student/StudentDashboard.tsx) (Student wellness UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["User experience"]
  node_app["Client routing<br/>[App.tsx]"]
  node_student_ui["Student wellness UI"]
  node_screen_time["Screen-time UI<br/>[ScreenTimePage.tsx]"]
  node_chat_ui["Chat UI<br/>[StudentChatbot.tsx]"]
  node_counselor_ui["Counselor triage UI"]
  node_casefile_ui["Student case file"]
  node_admin_ui["Campus analytics UI<br/>[AdminDashboard.tsx]"]
  node_api_client["REST client<br/>[api.ts]"]
end

subgraph group_gateway["API and privacy"]
  node_backend["FastAPI gateway<br/>[main.py]"]
  node_auth["Authentication<br/>[auth.py]"]
  node_privacy["Consent and audit"]
end

subgraph group_wellness["Wellness and AI"]
  node_phenotyping["Device phenotyping"]
  node_ml["Risk and emotion inference<br/>[inference.py]"]
  node_safety["Crisis safety<br/>[safety_engine.py]"]
  node_conversation["Chat response orchestration"]
  node_trends["Wellness trends<br/>[trend_service.py]"]
  node_screenings["Clinical screenings<br/>[surveys.py]"]
  node_desktop_agent["Desktop telemetry agent"]
end

subgraph group_records["Records and intervention"]
  node_appointments["Consultation scheduling<br/>[appointments.py]"]
  node_notifications["Alerts and notifications<br/>[notifications.py]"]
  node_email["Email delivery<br/>[email_service.py]"]
  node_database[("SQL database<br/>[session.py]")]
  node_account_records["Accounts and roles<br/>[users.py]"]
  node_assessment_records["Risk assessments<br/>[assessments.py]"]
  node_alert_records["Counselor alerts<br/>[alerts.py]"]
  node_mood_records["Mood history<br/>[mood_logs.py]"]
end

node_student(("Student"))
node_counselor(("Counselor"))
node_admin(("Administrator"))

node_student -->|"uses"| node_app
node_counselor -->|"uses"| node_app
node_admin -->|"uses"| node_app
node_app -->|"routes to"| node_student_ui
node_app -->|"routes to"| node_counselor_ui
node_app -->|"routes to"| node_admin_ui
node_student_ui -.->|"offers"| node_screen_time
node_student_ui -.->|"offers"| node_chat_ui
node_counselor_ui -.->|"opens"| node_casefile_ui
node_app -.->|"uses"| node_api_client
node_api_client -->|"REST requests"| node_backend
node_backend -->|"mounts routes"| node_auth
node_backend -->|"initializes schema"| node_database
node_backend -->|"enforces consent"| node_privacy
node_backend -->|"inference hooks"| node_ml
node_backend -.->|"routes telemetry"| node_phenotyping
node_backend -->|"mounts surveys"| node_screenings
node_backend -->|"mounts routes"| node_appointments
node_backend -->|"mounts routes"| node_notifications
node_chat_ui -.->|"sends chat"| node_conversation
node_conversation -->|"crisis override"| node_safety
node_phenotyping -.->|"reads telemetry"| node_desktop_agent
node_trends -->|"reads history"| node_database
node_database -->|"stores"| node_mood_records
node_database -->|"stores"| node_assessment_records
node_database -->|"stores"| node_alert_records
node_database -->|"stores"| node_account_records
node_ml -.->|"produces risk"| node_assessment_records
node_assessment_records -->|"triggers alert"| node_alert_records
node_notifications -.->|"dispatches email"| node_email
node_counselor_ui -.->|"reviews alerts"| node_notifications
node_admin_ui -.->|"requests cohort analytics"| node_backend

click node_app "https://github.com/pasupulasaiteja/mindguardai/blob/main/frontend/src/App.tsx"
click node_student_ui "https://github.com/pasupulasaiteja/mindguardai/blob/main/frontend/src/pages/student/StudentDashboard.tsx"
click node_screen_time "https://github.com/pasupulasaiteja/mindguardai/blob/main/frontend/src/pages/student/ScreenTimePage.tsx"
click node_chat_ui "https://github.com/pasupulasaiteja/mindguardai/blob/main/frontend/src/pages/student/StudentChatbot.tsx"
click node_counselor_ui "https://github.com/pasupulasaiteja/mindguardai/blob/main/frontend/src/pages/counselor/CounselorDashboard.tsx"
click node_casefile_ui "https://github.com/pasupulasaiteja/mindguardai/blob/main/frontend/src/pages/counselor/StudentCaseFile.tsx"
click node_admin_ui "https://github.com/pasupulasaiteja/mindguardai/blob/main/frontend/src/pages/admin/AdminDashboard.tsx"
click node_api_client "https://github.com/pasupulasaiteja/mindguardai/blob/main/frontend/src/services/api.ts"
click node_backend "https://github.com/pasupulasaiteja/mindguardai/blob/main/backend/app/main.py"
click node_auth "https://github.com/pasupulasaiteja/mindguardai/blob/main/backend/app/api/v1/auth.py"
click node_privacy "https://github.com/pasupulasaiteja/mindguardai/blob/main/backend/app/middleware/consent_enforcement.py"
click node_phenotyping "https://github.com/pasupulasaiteja/mindguardai/blob/main/backend/app/services/behavioral_service.py"
click node_ml "https://github.com/pasupulasaiteja/mindguardai/blob/main/backend/app/ml/inference.py"
click node_safety "https://github.com/pasupulasaiteja/mindguardai/blob/main/backend/app/ml/safety_engine.py"
click node_conversation "https://github.com/pasupulasaiteja/mindguardai/blob/main/backend/app/ml/response_orchestrator.py"
click node_trends "https://github.com/pasupulasaiteja/mindguardai/blob/main/backend/app/services/trend_service.py"
click node_screenings "https://github.com/pasupulasaiteja/mindguardai/blob/main/backend/app/api/v1/surveys.py"
click node_appointments "https://github.com/pasupulasaiteja/mindguardai/blob/main/backend/app/api/v1/appointments.py"
click node_notifications "https://github.com/pasupulasaiteja/mindguardai/blob/main/backend/app/api/v1/notifications.py"
click node_email "https://github.com/pasupulasaiteja/mindguardai/blob/main/backend/app/services/email_service.py"
click node_database "https://github.com/pasupulasaiteja/mindguardai/blob/main/backend/app/db/session.py"
click node_account_records "https://github.com/pasupulasaiteja/mindguardai/blob/main/backend/app/models/users.py"
click node_assessment_records "https://github.com/pasupulasaiteja/mindguardai/blob/main/backend/app/models/assessments.py"
click node_alert_records "https://github.com/pasupulasaiteja/mindguardai/blob/main/backend/app/models/alerts.py"
click node_mood_records "https://github.com/pasupulasaiteja/mindguardai/blob/main/backend/app/models/mood_logs.py"
click node_desktop_agent "https://github.com/pasupulasaiteja/mindguardai/blob/main/desktop_agent/mindguard_pc_agent.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_app,node_student_ui,node_screen_time,node_chat_ui,node_counselor_ui,node_casefile_ui,node_admin_ui,node_api_client toneBlue
class node_backend,node_auth,node_privacy toneAmber
class node_phenotyping,node_ml,node_safety,node_conversation,node_trends,node_screenings,node_desktop_agent toneMint
class node_appointments,node_notifications,node_email,node_database,node_account_records,node_assessment_records,node_alert_records,node_mood_records toneRose
class node_student,node_counselor,node_admin toneIndigo
```

## Components

### User experience

- [Client routing](https://github.com/pasupulasaiteja/mindguardai/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Student wellness UI](https://github.com/pasupulasaiteja/mindguardai/blob/main/frontend/src/pages/student/StudentDashboard.tsx): `frontend/src/pages/student/StudentDashboard.tsx`
- [Screen-time UI](https://github.com/pasupulasaiteja/mindguardai/blob/main/frontend/src/pages/student/ScreenTimePage.tsx): `frontend/src/pages/student/ScreenTimePage.tsx`
- [Chat UI](https://github.com/pasupulasaiteja/mindguardai/blob/main/frontend/src/pages/student/StudentChatbot.tsx): `frontend/src/pages/student/StudentChatbot.tsx`
- [Counselor triage UI](https://github.com/pasupulasaiteja/mindguardai/blob/main/frontend/src/pages/counselor/CounselorDashboard.tsx): `frontend/src/pages/counselor/CounselorDashboard.tsx`
- [Student case file](https://github.com/pasupulasaiteja/mindguardai/blob/main/frontend/src/pages/counselor/StudentCaseFile.tsx): `frontend/src/pages/counselor/StudentCaseFile.tsx`
- [Campus analytics UI](https://github.com/pasupulasaiteja/mindguardai/blob/main/frontend/src/pages/admin/AdminDashboard.tsx): `frontend/src/pages/admin/AdminDashboard.tsx`
- [REST client](https://github.com/pasupulasaiteja/mindguardai/blob/main/frontend/src/services/api.ts): `frontend/src/services/api.ts`

### API and privacy

- [FastAPI gateway](https://github.com/pasupulasaiteja/mindguardai/blob/main/backend/app/main.py): `backend/app/main.py`
- [Authentication](https://github.com/pasupulasaiteja/mindguardai/blob/main/backend/app/api/v1/auth.py): `backend/app/api/v1/auth.py`
- [Consent and audit](https://github.com/pasupulasaiteja/mindguardai/blob/main/backend/app/middleware/consent_enforcement.py): `backend/app/middleware/consent_enforcement.py`

### Wellness and AI

- [Device phenotyping](https://github.com/pasupulasaiteja/mindguardai/blob/main/backend/app/services/behavioral_service.py): `backend/app/services/behavioral_service.py`
- [Risk and emotion inference](https://github.com/pasupulasaiteja/mindguardai/blob/main/backend/app/ml/inference.py): `backend/app/ml/inference.py`
- [Crisis safety](https://github.com/pasupulasaiteja/mindguardai/blob/main/backend/app/ml/safety_engine.py): `backend/app/ml/safety_engine.py`
- [Chat response orchestration](https://github.com/pasupulasaiteja/mindguardai/blob/main/backend/app/ml/response_orchestrator.py): `backend/app/ml/response_orchestrator.py`
- [Wellness trends](https://github.com/pasupulasaiteja/mindguardai/blob/main/backend/app/services/trend_service.py): `backend/app/services/trend_service.py`
- [Clinical screenings](https://github.com/pasupulasaiteja/mindguardai/blob/main/backend/app/api/v1/surveys.py): `backend/app/api/v1/surveys.py`
- [Desktop telemetry agent](https://github.com/pasupulasaiteja/mindguardai/blob/main/desktop_agent/mindguard_pc_agent.py): `desktop_agent/mindguard_pc_agent.py`

### Records and intervention

- [Consultation scheduling](https://github.com/pasupulasaiteja/mindguardai/blob/main/backend/app/api/v1/appointments.py): `backend/app/api/v1/appointments.py`
- [Alerts and notifications](https://github.com/pasupulasaiteja/mindguardai/blob/main/backend/app/api/v1/notifications.py): `backend/app/api/v1/notifications.py`
- [Email delivery](https://github.com/pasupulasaiteja/mindguardai/blob/main/backend/app/services/email_service.py): `backend/app/services/email_service.py`
- [SQL database](https://github.com/pasupulasaiteja/mindguardai/blob/main/backend/app/db/session.py): `backend/app/db/session.py`
- [Accounts and roles](https://github.com/pasupulasaiteja/mindguardai/blob/main/backend/app/models/users.py): `backend/app/models/users.py`
- [Risk assessments](https://github.com/pasupulasaiteja/mindguardai/blob/main/backend/app/models/assessments.py): `backend/app/models/assessments.py`
- [Counselor alerts](https://github.com/pasupulasaiteja/mindguardai/blob/main/backend/app/models/alerts.py): `backend/app/models/alerts.py`
- [Mood history](https://github.com/pasupulasaiteja/mindguardai/blob/main/backend/app/models/mood_logs.py): `backend/app/models/mood_logs.py`

### Other components

- **Student**
- **Counselor**
- **Administrator**

## Connections

- Student → Client routing: uses
- Counselor → Client routing: uses
- Administrator → Client routing: uses
- Client routing → Student wellness UI: routes to (evidence: `frontend/src/App.tsx`)
- Client routing → Counselor triage UI: routes to (evidence: `frontend/src/App.tsx`)
- Client routing → Campus analytics UI: routes to (evidence: `frontend/src/App.tsx`)
- Student wellness UI → Screen-time UI: offers
- Student wellness UI → Chat UI: offers
- Counselor triage UI → Student case file: opens
- Client routing → REST client: uses
- REST client → FastAPI gateway: REST requests
- FastAPI gateway → Authentication: mounts routes (evidence: `backend/app/main.py`)
- FastAPI gateway → SQL database: initializes schema (evidence: `backend/app/main.py`)
- FastAPI gateway → Consent and audit: enforces consent
- FastAPI gateway → Risk and emotion inference: inference hooks (evidence: `backend/app/main.py`)
- FastAPI gateway → Device phenotyping: routes telemetry
- FastAPI gateway → Clinical screenings: mounts surveys (evidence: `backend/app/main.py`)
- FastAPI gateway → Consultation scheduling: mounts routes (evidence: `backend/app/main.py`)
- FastAPI gateway → Alerts and notifications: mounts routes (evidence: `backend/app/main.py`)
- Chat UI → Chat response orchestration: sends chat
- Chat response orchestration → Crisis safety: crisis override
- Device phenotyping → Desktop telemetry agent: reads telemetry
- Wellness trends → SQL database: reads history (evidence: `backend/app/services/trend_service.py`)
- SQL database → Mood history: stores (evidence: `backend/app/models/mood_logs.py`)
- SQL database → Risk assessments: stores (evidence: `backend/app/models/assessments.py`)
- SQL database → Counselor alerts: stores (evidence: `backend/app/models/alerts.py`)
- SQL database → Accounts and roles: stores (evidence: `backend/app/models/users.py`)
- Risk and emotion inference → Risk assessments: produces risk
- Risk assessments → Counselor alerts: triggers alert (evidence: `backend/app/models/alerts.py`)
- Alerts and notifications → Email delivery: dispatches email
- Counselor triage UI → Alerts and notifications: reviews alerts
- Campus analytics UI → FastAPI gateway: requests cohort analytics
