# vaishnavichaubey06/clearing-mental-health-chatbot architecture

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

- Interactive diagram: https://gitdiagram.com/vaishnavichaubey06/clearing-mental-health-chatbot
- Repository: https://github.com/vaishnavichaubey06/clearing-mental-health-chatbot

## Overview

Clearing is a web-based mental wellbeing and self-reflection platform. Users interact through the JavaScript frontend, which calls the FastAPI backend for authentication, chat, tracking, analysis, activities, yoga, and reports. Chat and wellbeing analysis are distinct processing stages; persistence and the configurable LLM are supporting layers. The README documents the feature set, while excerpts and the source index confirm only selected call paths, so unverified links are omitted or marked dashed.

Main entry points: [`backend/app/api`](https://github.com/vaishnavichaubey06/clearing-mental-health-chatbot/tree/main/backend/app/api) (Feature Endpoints), [`js/api.js`](https://github.com/vaishnavichaubey06/clearing-mental-health-chatbot/blob/main/js/api.js) (API Client), [`backend/app/main.py`](https://github.com/vaishnavichaubey06/clearing-mental-health-chatbot/blob/main/backend/app/main.py) (FastAPI App), [`backend/app/models`](https://github.com/vaishnavichaubey06/clearing-mental-health-chatbot/tree/main/backend/app/models) (Wellbeing Records)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend"]
  node_web["Web Experience<br/>[app.js]"]
  node_api_client["API Client<br/>[api.js]"]
  node_chat_ui["Chat UI<br/>[chat.js]"]
  node_mood_ui["Mood UI<br/>[mood.js]"]
  node_yoga_ui["Yoga UI<br/>[yoga.js]"]
end

subgraph group_api["HTTP API"]
  node_api_app["FastAPI App<br/>[main.py]"]
  node_auth_api["Authentication<br/>[auth.py]"]
  node_chat_api["Chat Endpoint<br/>[chat.py]"]
  node_feature_apis["Feature Endpoints"]
end

subgraph group_analysis["AI And Analysis"]
  node_chat_service["Conversation Logic<br/>[chat_service.py]"]
  node_llm["LLM Client<br/>[llm.py]"]
  node_emotion["Emotion Analysis<br/>[emotion_service.py]"]
  node_wellbeing_analysis["Wellbeing Assessment"]
  node_risk["Risk Analysis"]
  node_sentiment["Sentiment Analysis"]
end

subgraph group_wellbeing["Wellbeing Features"]
  node_mood_journal["Mood And Journal<br/>[moods.py]"]
  node_activities["Activities<br/>[activities.py]"]
  node_yoga_api["Yoga Integration<br/>[yoga.py]"]
  node_pose_engine["Pose Checking<br/>[main.py]"]
  node_reports["Reports And PDF<br/>[reports_service.py]"]
  node_pdf_service["PDF Generation"]
end

subgraph group_persistence["Persistence"]
  node_db_session["Database Session<br/>[session.py]"]
  node_records[("Wellbeing Records")]
end

node_user(("User"))
node_llm_provider["LLM Provider"]

node_user -->|"uses"| node_web
node_web -->|"requests"| node_api_client
node_api_client -->|"calls API"| node_api_app
node_api_app -->|"registers"| node_auth_api
node_api_app -->|"registers"| node_chat_api
node_api_app -->|"registers"| node_feature_apis
node_chat_ui -->|"requests"| node_api_client
node_mood_ui -->|"requests"| node_api_client
node_yoga_ui -->|"requests"| node_api_client
node_auth_api -->|"uses session"| node_db_session
node_auth_api -->|"registers users"| node_records
node_chat_api -->|"delegates"| node_chat_service
node_chat_api -->|"uses client"| node_llm
node_chat_service -.->|"generates replies"| node_llm
node_llm -->|"sends prompt"| node_llm_provider
node_feature_apis -.->|"includes"| node_mood_journal
node_feature_apis -.->|"includes"| node_activities
node_feature_apis -.->|"includes"| node_yoga_api
node_yoga_api -->|"uses pose logic"| node_pose_engine
node_feature_apis -->|"assesses"| node_wellbeing_analysis
node_feature_apis -->|"requests analysis"| node_risk
node_wellbeing_analysis -->|"analyzes text"| node_sentiment
node_wellbeing_analysis -->|"reads records"| node_records
node_feature_apis -.->|"exposes analysis"| node_emotion
node_feature_apis -.->|"provides reports"| node_reports
node_reports -->|"reads history"| node_records
node_reports -.->|"formats PDF"| node_pdf_service
node_db_session -->|"persists"| node_records

click node_web "https://github.com/vaishnavichaubey06/clearing-mental-health-chatbot/blob/main/js/app.js"
click node_api_client "https://github.com/vaishnavichaubey06/clearing-mental-health-chatbot/blob/main/js/api.js"
click node_chat_ui "https://github.com/vaishnavichaubey06/clearing-mental-health-chatbot/blob/main/js/chat.js"
click node_mood_ui "https://github.com/vaishnavichaubey06/clearing-mental-health-chatbot/blob/main/js/mood.js"
click node_yoga_ui "https://github.com/vaishnavichaubey06/clearing-mental-health-chatbot/blob/main/js/yoga.js"
click node_api_app "https://github.com/vaishnavichaubey06/clearing-mental-health-chatbot/blob/main/backend/app/main.py"
click node_auth_api "https://github.com/vaishnavichaubey06/clearing-mental-health-chatbot/blob/main/backend/app/api/auth.py"
click node_chat_api "https://github.com/vaishnavichaubey06/clearing-mental-health-chatbot/blob/main/backend/app/api/chat.py"
click node_feature_apis "https://github.com/vaishnavichaubey06/clearing-mental-health-chatbot/tree/main/backend/app/api"
click node_chat_service "https://github.com/vaishnavichaubey06/clearing-mental-health-chatbot/blob/main/backend/app/services/chat_service.py"
click node_llm "https://github.com/vaishnavichaubey06/clearing-mental-health-chatbot/blob/main/backend/app/ai/llm.py"
click node_emotion "https://github.com/vaishnavichaubey06/clearing-mental-health-chatbot/blob/main/backend/app/services/emotion_service.py"
click node_wellbeing_analysis "https://github.com/vaishnavichaubey06/clearing-mental-health-chatbot/blob/main/backend/app/services/wellbeing_assessment_service.py"
click node_risk "https://github.com/vaishnavichaubey06/clearing-mental-health-chatbot/blob/main/backend/app/services/risk_analysis_service.py"
click node_sentiment "https://github.com/vaishnavichaubey06/clearing-mental-health-chatbot/blob/main/backend/app/services/sentiment_service.py"
click node_mood_journal "https://github.com/vaishnavichaubey06/clearing-mental-health-chatbot/blob/main/backend/app/api/moods.py"
click node_activities "https://github.com/vaishnavichaubey06/clearing-mental-health-chatbot/blob/main/backend/app/api/activities.py"
click node_yoga_api "https://github.com/vaishnavichaubey06/clearing-mental-health-chatbot/blob/main/backend/app/api/yoga.py"
click node_pose_engine "https://github.com/vaishnavichaubey06/clearing-mental-health-chatbot/blob/main/backend/app/yoga/api/main.py"
click node_reports "https://github.com/vaishnavichaubey06/clearing-mental-health-chatbot/blob/main/backend/app/services/reports_service.py"
click node_pdf_service "https://github.com/vaishnavichaubey06/clearing-mental-health-chatbot/blob/main/backend/app/services/report_pdf_service.py"
click node_db_session "https://github.com/vaishnavichaubey06/clearing-mental-health-chatbot/blob/main/backend/app/db/session.py"
click node_records "https://github.com/vaishnavichaubey06/clearing-mental-health-chatbot/tree/main/backend/app/models"

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_web,node_api_client,node_chat_ui,node_mood_ui,node_yoga_ui,node_user toneBlue
class node_api_app,node_auth_api,node_chat_api,node_feature_apis toneAmber
class node_chat_service,node_llm,node_emotion,node_wellbeing_analysis,node_risk,node_sentiment toneMint
class node_mood_journal,node_activities,node_yoga_api,node_pose_engine,node_reports,node_pdf_service toneRose
class node_db_session,node_records,node_llm_provider toneIndigo
```

## Components

### Frontend

- [Web Experience](https://github.com/vaishnavichaubey06/clearing-mental-health-chatbot/blob/main/js/app.js): `js/app.js`
- [API Client](https://github.com/vaishnavichaubey06/clearing-mental-health-chatbot/blob/main/js/api.js): `js/api.js`
- [Chat UI](https://github.com/vaishnavichaubey06/clearing-mental-health-chatbot/blob/main/js/chat.js): `js/chat.js`
- [Mood UI](https://github.com/vaishnavichaubey06/clearing-mental-health-chatbot/blob/main/js/mood.js): `js/mood.js`
- [Yoga UI](https://github.com/vaishnavichaubey06/clearing-mental-health-chatbot/blob/main/js/yoga.js): `js/yoga.js`

### HTTP API

- [FastAPI App](https://github.com/vaishnavichaubey06/clearing-mental-health-chatbot/blob/main/backend/app/main.py): `backend/app/main.py`
- [Authentication](https://github.com/vaishnavichaubey06/clearing-mental-health-chatbot/blob/main/backend/app/api/auth.py): `backend/app/api/auth.py`
- [Chat Endpoint](https://github.com/vaishnavichaubey06/clearing-mental-health-chatbot/blob/main/backend/app/api/chat.py): `backend/app/api/chat.py`
- [Feature Endpoints](https://github.com/vaishnavichaubey06/clearing-mental-health-chatbot/tree/main/backend/app/api): `backend/app/api`

### AI And Analysis

- [Conversation Logic](https://github.com/vaishnavichaubey06/clearing-mental-health-chatbot/blob/main/backend/app/services/chat_service.py): `backend/app/services/chat_service.py`
- [LLM Client](https://github.com/vaishnavichaubey06/clearing-mental-health-chatbot/blob/main/backend/app/ai/llm.py): `backend/app/ai/llm.py`
- [Emotion Analysis](https://github.com/vaishnavichaubey06/clearing-mental-health-chatbot/blob/main/backend/app/services/emotion_service.py): `backend/app/services/emotion_service.py`
- [Wellbeing Assessment](https://github.com/vaishnavichaubey06/clearing-mental-health-chatbot/blob/main/backend/app/services/wellbeing_assessment_service.py): `backend/app/services/wellbeing_assessment_service.py`
- [Risk Analysis](https://github.com/vaishnavichaubey06/clearing-mental-health-chatbot/blob/main/backend/app/services/risk_analysis_service.py): `backend/app/services/risk_analysis_service.py`
- [Sentiment Analysis](https://github.com/vaishnavichaubey06/clearing-mental-health-chatbot/blob/main/backend/app/services/sentiment_service.py): `backend/app/services/sentiment_service.py`

### Wellbeing Features

- [Mood And Journal](https://github.com/vaishnavichaubey06/clearing-mental-health-chatbot/blob/main/backend/app/api/moods.py): `backend/app/api/moods.py`
- [Activities](https://github.com/vaishnavichaubey06/clearing-mental-health-chatbot/blob/main/backend/app/api/activities.py): `backend/app/api/activities.py`
- [Yoga Integration](https://github.com/vaishnavichaubey06/clearing-mental-health-chatbot/blob/main/backend/app/api/yoga.py): `backend/app/api/yoga.py`
- [Pose Checking](https://github.com/vaishnavichaubey06/clearing-mental-health-chatbot/blob/main/backend/app/yoga/api/main.py): `backend/app/yoga/api/main.py`
- [Reports And PDF](https://github.com/vaishnavichaubey06/clearing-mental-health-chatbot/blob/main/backend/app/services/reports_service.py): `backend/app/services/reports_service.py`
- [PDF Generation](https://github.com/vaishnavichaubey06/clearing-mental-health-chatbot/blob/main/backend/app/services/report_pdf_service.py): `backend/app/services/report_pdf_service.py`

### Persistence

- [Database Session](https://github.com/vaishnavichaubey06/clearing-mental-health-chatbot/blob/main/backend/app/db/session.py): `backend/app/db/session.py`
- [Wellbeing Records](https://github.com/vaishnavichaubey06/clearing-mental-health-chatbot/tree/main/backend/app/models): `backend/app/models`

### Other components

- **User**
- **LLM Provider**

## Connections

- User → Web Experience: uses (evidence: `README.md`)
- Web Experience → API Client: requests (evidence: `README.md`)
- API Client → FastAPI App: calls API (evidence: `README.md`)
- FastAPI App → Authentication: registers (evidence: `backend/app/main.py`)
- FastAPI App → Chat Endpoint: registers (evidence: `backend/app/main.py`)
- FastAPI App → Feature Endpoints: registers (evidence: `backend/app/main.py`)
- Chat UI → API Client: requests (evidence: `README.md`)
- Mood UI → API Client: requests (evidence: `README.md`)
- Yoga UI → API Client: requests (evidence: `README.md`)
- Authentication → Database Session: uses session (evidence: `backend/app/api/auth.py`)
- Authentication → Wellbeing Records: registers users (evidence: `backend/app/api/auth.py`)
- Chat Endpoint → Conversation Logic: delegates (evidence: `backend/app/api/chat.py`)
- Chat Endpoint → LLM Client: uses client (evidence: `backend/app/api/chat.py`)
- Conversation Logic → LLM Client: generates replies
- LLM Client → LLM Provider: sends prompt (evidence: `backend/app/ai/llm.py`)
- Feature Endpoints → Mood And Journal: includes (evidence: `backend/app/api/moods.py`)
- Feature Endpoints → Activities: includes (evidence: `backend/app/api/activities.py`)
- Feature Endpoints → Yoga Integration: includes
- Yoga Integration → Pose Checking: uses pose logic (evidence: `backend/app/yoga/api/main.py`)
- Feature Endpoints → Wellbeing Assessment: assesses (evidence: `backend/app/api/assessments.py`)
- Feature Endpoints → Risk Analysis: requests analysis (evidence: `backend/app/api/assessments.py`)
- Wellbeing Assessment → Sentiment Analysis: analyzes text (evidence: `backend/app/services/wellbeing_assessment_service.py`)
- Wellbeing Assessment → Wellbeing Records: reads records (evidence: `backend/app/services/wellbeing_assessment_service.py`)
- Feature Endpoints → Emotion Analysis: exposes analysis
- Feature Endpoints → Reports And PDF: provides reports
- Reports And PDF → Wellbeing Records: reads history (evidence: `backend/app/services/reports_service.py`)
- Reports And PDF → PDF Generation: formats PDF
- Database Session → Wellbeing Records: persists (evidence: `backend/app/db/session.py`)
