# lohith5911/mental-health-speech-app architecture

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

- Interactive diagram: https://gitdiagram.com/lohith5911/mental-health-speech-app
- Repository: https://github.com/lohith5911/mental-health-speech-app

## Overview

MindTrace AI is an authenticated speech-based check-in application for emotional self-monitoring, not a diagnostic tool. Users register or log in, record and preview a voice check-in, submit it for analysis, and review results, history, and trends. The backend handles authenticated requests and persistence; its audio-processing flow calls the V4 predictor, acoustic-feature extraction, and signal-quality assessment. The README documents these major capabilities, while some implementation details and UI-page internals were not sampled.

Main entry points: [`frontend/src/App.tsx`](https://github.com/lohith5911/mental-health-speech-app/blob/main/frontend/src/App.tsx) (Routes and access), [`backend/app/main.py`](https://github.com/lohith5911/mental-health-speech-app/blob/main/backend/app/main.py) (API and check-in flow), [`frontend/src/services/index.ts`](https://github.com/lohith5911/mental-health-speech-app/blob/main/frontend/src/services/index.ts) (API client), [`frontend/src/pages/DailyCheckIn.tsx`](https://github.com/lohith5911/mental-health-speech-app/blob/main/frontend/src/pages/DailyCheckIn.tsx) (Daily check-in page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Browser application"]
  node_app["Routes and access<br/>[App.tsx]"]
  node_authui["Session and auth<br/>[AuthContext.tsx]"]
  node_authhook["Auth context hook<br/>[useAuth.ts]"]
  node_checkinpage["Daily check-in page<br/>[DailyCheckIn.tsx]"]
  node_recording["Microphone recording<br/>[useRecording.ts]"]
  node_recordcard["Recording controls<br/>[RecordingCard.tsx]"]
  node_services["API client<br/>[index.ts]"]
  node_dashboard["Dashboard<br/>[Dashboard.tsx]"]
  node_results["Results view<br/>[Results.tsx]"]
  node_history["History and trends<br/>[History.tsx]"]
  node_profile["Profile and resources<br/>[Profile.tsx]"]
  node_resources["Professional resources<br/>[Resources.tsx]"]
end

subgraph group_backend["API and persistence"]
  node_api["API and check-in flow<br/>[main.py]"]
  node_auth["Token authentication<br/>[auth.py]"]
  node_store[("SQLite records<br/>[main.py]")]
  node_quality["Signal quality<br/>[quality.py]"]
  node_trends["Trend insights<br/>[trend_engine.py]"]
end

subgraph group_ml["Speech analysis"]
  node_predictor["V4 emotion predictor"]
  node_acoustics["Acoustic features"]
  node_preprocess["Audio preprocessing<br/>[audio.py]"]
end

node_user(("User"))

node_user -->|"uses"| node_app
node_app -->|"provides session"| node_authui
node_app -->|"routes to"| node_checkinpage
node_app -->|"routes to"| node_dashboard
node_app -->|"routes to"| node_results
node_app -->|"routes to"| node_history
node_app -->|"routes to"| node_profile
node_app -->|"routes to"| node_resources
node_authui -->|"calls"| node_services
node_app -->|"checks session"| node_authhook
node_checkinpage -->|"uses"| node_recording
node_checkinpage -->|"renders"| node_recordcard
node_recording -->|"submits audio"| node_services
node_services -->|"sends requests"| node_api
node_api -->|"validates identity"| node_auth
node_api -->|"runs inference"| node_predictor
node_api -->|"extracts features"| node_acoustics
node_api -->|"assesses signal"| node_quality
node_api -->|"reads and writes"| node_store
node_api -->|"builds insights"| node_trends
node_predictor -->|"loads audio"| node_preprocess
node_acoustics -->|"uses"| node_preprocess
node_dashboard -->|"fetches data"| node_services
node_history -->|"fetches history"| node_services
node_results -->|"fetches results"| node_services

click node_app "https://github.com/lohith5911/mental-health-speech-app/blob/main/frontend/src/App.tsx"
click node_authui "https://github.com/lohith5911/mental-health-speech-app/blob/main/frontend/src/context/AuthContext.tsx"
click node_authhook "https://github.com/lohith5911/mental-health-speech-app/blob/main/frontend/src/context/useAuth.ts"
click node_checkinpage "https://github.com/lohith5911/mental-health-speech-app/blob/main/frontend/src/pages/DailyCheckIn.tsx"
click node_recording "https://github.com/lohith5911/mental-health-speech-app/blob/main/frontend/src/hooks/useRecording.ts"
click node_recordcard "https://github.com/lohith5911/mental-health-speech-app/blob/main/frontend/src/components/check-in/RecordingCard.tsx"
click node_services "https://github.com/lohith5911/mental-health-speech-app/blob/main/frontend/src/services/index.ts"
click node_dashboard "https://github.com/lohith5911/mental-health-speech-app/blob/main/frontend/src/pages/Dashboard.tsx"
click node_results "https://github.com/lohith5911/mental-health-speech-app/blob/main/frontend/src/pages/Results.tsx"
click node_history "https://github.com/lohith5911/mental-health-speech-app/blob/main/frontend/src/pages/History.tsx"
click node_profile "https://github.com/lohith5911/mental-health-speech-app/blob/main/frontend/src/pages/Profile.tsx"
click node_api "https://github.com/lohith5911/mental-health-speech-app/blob/main/backend/app/main.py"
click node_auth "https://github.com/lohith5911/mental-health-speech-app/blob/main/backend/app/auth.py"
click node_store "https://github.com/lohith5911/mental-health-speech-app/blob/main/backend/app/main.py"
click node_quality "https://github.com/lohith5911/mental-health-speech-app/blob/main/backend/app/services/quality.py"
click node_trends "https://github.com/lohith5911/mental-health-speech-app/blob/main/backend/app/services/trend_engine.py"
click node_predictor "https://github.com/lohith5911/mental-health-speech-app/blob/main/ml/src/models/v4_emotion_model.py"
click node_acoustics "https://github.com/lohith5911/mental-health-speech-app/blob/main/ml/src/features/acoustic_features.py"
click node_preprocess "https://github.com/lohith5911/mental-health-speech-app/blob/main/ml/src/preprocessing/audio.py"
click node_resources "https://github.com/lohith5911/mental-health-speech-app/blob/main/frontend/src/pages/Resources.tsx"

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_authui,node_authhook,node_checkinpage,node_recording,node_recordcard,node_services,node_dashboard,node_results,node_history,node_profile,node_resources,node_user toneBlue
class node_api,node_auth,node_store,node_quality,node_trends toneAmber
class node_predictor,node_acoustics,node_preprocess toneMint
```

## Components

### Browser application

- [Routes and access](https://github.com/lohith5911/mental-health-speech-app/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Session and auth](https://github.com/lohith5911/mental-health-speech-app/blob/main/frontend/src/context/AuthContext.tsx): `frontend/src/context/AuthContext.tsx`
- [Auth context hook](https://github.com/lohith5911/mental-health-speech-app/blob/main/frontend/src/context/useAuth.ts): `frontend/src/context/useAuth.ts`
- [Daily check-in page](https://github.com/lohith5911/mental-health-speech-app/blob/main/frontend/src/pages/DailyCheckIn.tsx): `frontend/src/pages/DailyCheckIn.tsx`
- [Microphone recording](https://github.com/lohith5911/mental-health-speech-app/blob/main/frontend/src/hooks/useRecording.ts): `frontend/src/hooks/useRecording.ts`
- [Recording controls](https://github.com/lohith5911/mental-health-speech-app/blob/main/frontend/src/components/check-in/RecordingCard.tsx): `frontend/src/components/check-in/RecordingCard.tsx`
- [API client](https://github.com/lohith5911/mental-health-speech-app/blob/main/frontend/src/services/index.ts): `frontend/src/services/index.ts`
- [Dashboard](https://github.com/lohith5911/mental-health-speech-app/blob/main/frontend/src/pages/Dashboard.tsx): `frontend/src/pages/Dashboard.tsx`
- [Results view](https://github.com/lohith5911/mental-health-speech-app/blob/main/frontend/src/pages/Results.tsx): `frontend/src/pages/Results.tsx`
- [History and trends](https://github.com/lohith5911/mental-health-speech-app/blob/main/frontend/src/pages/History.tsx): `frontend/src/pages/History.tsx`
- [Profile and resources](https://github.com/lohith5911/mental-health-speech-app/blob/main/frontend/src/pages/Profile.tsx): `frontend/src/pages/Profile.tsx`
- [Professional resources](https://github.com/lohith5911/mental-health-speech-app/blob/main/frontend/src/pages/Resources.tsx): `frontend/src/pages/Resources.tsx`

### API and persistence

- [API and check-in flow](https://github.com/lohith5911/mental-health-speech-app/blob/main/backend/app/main.py): `backend/app/main.py`
- [Token authentication](https://github.com/lohith5911/mental-health-speech-app/blob/main/backend/app/auth.py): `backend/app/auth.py`
- [SQLite records](https://github.com/lohith5911/mental-health-speech-app/blob/main/backend/app/main.py): `backend/app/main.py`
- [Signal quality](https://github.com/lohith5911/mental-health-speech-app/blob/main/backend/app/services/quality.py): `backend/app/services/quality.py`
- [Trend insights](https://github.com/lohith5911/mental-health-speech-app/blob/main/backend/app/services/trend_engine.py): `backend/app/services/trend_engine.py`

### Speech analysis

- [V4 emotion predictor](https://github.com/lohith5911/mental-health-speech-app/blob/main/ml/src/models/v4_emotion_model.py): `ml/src/models/v4_emotion_model.py`
- [Acoustic features](https://github.com/lohith5911/mental-health-speech-app/blob/main/ml/src/features/acoustic_features.py): `ml/src/features/acoustic_features.py`
- [Audio preprocessing](https://github.com/lohith5911/mental-health-speech-app/blob/main/ml/src/preprocessing/audio.py): `ml/src/preprocessing/audio.py`

### Other components

- **User**

## Connections

- User → Routes and access: uses (evidence: `README.md`)
- Routes and access → Session and auth: provides session (evidence: `frontend/src/main.tsx`)
- Routes and access → Daily check-in page: routes to (evidence: `frontend/src/App.tsx`)
- Routes and access → Dashboard: routes to (evidence: `frontend/src/App.tsx`)
- Routes and access → Results view: routes to (evidence: `frontend/src/App.tsx`)
- Routes and access → History and trends: routes to (evidence: `frontend/src/App.tsx`)
- Routes and access → Profile and resources: routes to (evidence: `frontend/src/App.tsx`)
- Routes and access → Professional resources: routes to (evidence: `frontend/src/App.tsx`)
- Session and auth → API client: calls (evidence: `frontend/src/context/AuthContext.tsx`)
- Routes and access → Auth context hook: checks session (evidence: `frontend/src/App.tsx`)
- Daily check-in page → Microphone recording: uses (evidence: `frontend/src/pages/DailyCheckIn.tsx`)
- Daily check-in page → Recording controls: renders (evidence: `frontend/src/pages/DailyCheckIn.tsx`)
- Microphone recording → API client: submits audio (evidence: `frontend/src/hooks/useRecording.ts`)
- API client → API and check-in flow: sends requests (evidence: `README.md`)
- API and check-in flow → Token authentication: validates identity (evidence: `backend/app/main.py`)
- API and check-in flow → V4 emotion predictor: runs inference (evidence: `backend/app/main.py`)
- API and check-in flow → Acoustic features: extracts features (evidence: `backend/app/main.py`)
- API and check-in flow → Signal quality: assesses signal (evidence: `backend/app/main.py`)
- API and check-in flow → SQLite records: reads and writes (evidence: `backend/app/main.py`)
- API and check-in flow → Trend insights: builds insights (evidence: `backend/app/main.py`)
- V4 emotion predictor → Audio preprocessing: loads audio (evidence: `ml/src/models/v4_emotion_model.py`)
- Acoustic features → Audio preprocessing: uses (evidence: `ml/src/features/acoustic_features.py`)
- Dashboard → API client: fetches data (evidence: `frontend/src/pages/Dashboard.tsx`)
- History and trends → API client: fetches history (evidence: `frontend/src/pages/History.tsx`)
- Results view → API client: fetches results (evidence: `frontend/src/pages/Results.tsx`)
