MindCare AI is a full-stack intelligent mental health counselling platform that leverages four distinct AI modalities β behavioural data, facial emotion recognition, voice emotion detection, and NLP-driven chat analysis β to deliver a holistic, real-time mental wellness assessment and a personalized therapeutic experience.
Video_Project1.mp4
- π Project Overview
- β¨ Key Features
- ποΈ System Architecture
- π€ AI & Machine Learning Models
- π οΈ Tech Stack
- π Project Structure
- βοΈ Project Setup & Machine Learning Resources
- π Running the Application
- π API Reference
- ποΈ Database Schema
- π₯οΈ Application Screens
- π Security & Authentication
- π€ Contributing
Mental health disorders are a global crisis, yet timely and accurate assessment remains a major challenge. Traditional methods rely on subjective self-reporting, which is insufficient for detecting the true severity of a user's mental state.
MindCare AI solves this by combining four independent AI modalities into a single, unified platform. Rather than relying on one signal, the system fuses insights from:
- π Behavioural Data β Lifestyle and physiological metrics (sleep, BMI, stress, heart rate, BP)
- π Facial Emotion β Deep learning-based facial expression analysis from a live video feed
- ποΈ Voice Emotion β Acoustic feature analysis from audio recordings to detect emotional tone
- π¬ Chat Text (NLP) β Conversational AI that extracts mental health indicators from natural language
The results are fused into a Final Severity Score (0β100) and a Risk Level (Low / Moderate / High / Critical), powering a personalized wellness dashboard with an AI therapist chatbot, daily tasks, mindfulness exercises, and curated video recommendations.
The project is fully deployed and accessible online. You can test the multimodal AI features without installing anything locally.
- Frontend Application (Vercel): MindCare AI Web App
- Backend API & Docs (Hugging Face): FastAPI Swagger UI
(Note: The backend is hosted on a free Hugging Face Space and may take 1-2 minutes to wake up from sleep upon initial load. The OTP email service is currently in DEMO mode; OTPs are generated and can be viewed in the backend logs or network response).
| Step | Module | Technology | Output |
|---|---|---|---|
| 1 | Behavioural Test | Scikit-learn (Gradient Boosting) | Risk category + Severity score |
| 2 | Chat Counselling | OpenRouter | Sentiment, triggers, intensity score |
| 3 | Facial Emotion Detection | ResNet (.keras) + OpenCV |
Dominant emotion + Confidence |
| 4 | Voice Emotion Detection | CNN (.h5/.json) + Librosa |
Voice emotion + Stress level |
| 5 | Final Severity Report | Weighted fusion of all 4 modalities | Risk Level (Low β Critical) |
- Real-Time Severity Gauge β Animated circular progress bar showing the fused mental health score
- Risk Level Indicator β Color-coded badge (π’ Low / π‘ Moderate / π High / π΄ Critical)
- Historical Trends β Area chart showing severity score evolution over time
- Modality Score Breakdown β Individual scores for each of the four AI channels
- Dr. MindCare Chatbot β An empathetic AI therapist powered by OpenRouter
- Daily Wellness Tasks β Personalized, severity-adaptive task checklist
- Mindfulness Breathing Exercises β Interactive guided breathing animations
- YouTube Video Recommendations β Curated mental health content based on risk profile
- User Profile Management β Edit demographic info with occupation/gender dropdowns
- JWT-based authentication with secure token storage
- Google OAuth 2.0 single sign-on integration
- 3-Step Password Reset via OTP sent to registered email (SMTP)
- Route guards β All assessment and dashboard routes are protected
- Dark Glassmorphism design system throughout
- Framer Motion cinematic page transitions and micro-animations
- Three.js/React Three Fiber WebGL background on the landing page
- GSAP animations for scroll-driven reveals
- Custom animated cursor across the entire application
- Responsive layouts for desktop and large screens
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β FRONTEND (React + Vite) β
β β
β Landing β Login/Register β Assessment Pipeline β Dashboard β
β β β β β β
β React.js Google OAuth 4 Modality Pages Recharts / FM β
β WebGL BG JWT Tokens (Behaviour, Chat, Dr. MindCare Bot β
β Face, Voice) Daily Tasks β
βββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββ
β HTTP / REST (Axios)
β Port 5173 β 8000
βββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββ
β BACKEND (FastAPI + Python) β
β β
β ββββββββββββ ββββββββββββ ββββββββββββ βββββββββ βββββββββββ β
β β /auth β β/behaviourβ β /chat β β/face β β /voice β β
β ββββββββββββ ββββββββββββ ββββββββββββ βββββββββ βββββββββββ β
β ββββββββββββ ββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β/severity β β /dashboard β β
β ββββββββββββ ββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β β ML / AI Services Layer ββ
β β ml_loader.py β ai_service.py β nlp_service.py β email_service ββ
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββ
β
ββββββββββββββββββΌββββββββββββββββββ
βΌ βΌ βΌ
βββββββββββββββ ββββββββββββββ ββββββββββββββββββββ
β SQLite DB β β Pre-trainedβ β OpenRouter API β
β mindcare.db β β Models β β (Gemini LLM) β
βββββββββββββββ ββββββββββββββ ββββββββββββββββββββ
User Registers/Logs In
β
βΌ
[Step 1] Behaviour Test βββΊ ML Model (Random Forest) βββΊ Behaviour Severity Score
β
βΌ
[Step 2] Chat Counselling βββΊ LLM + NLP Analysis βββββββΊ Chat Severity Score
β
βΌ
[Step 3] Facial Emotion βββΊ ResNet Deep Learning ββββββΊ Face Severity Score
β
βΌ
[Step 4] Voice Analysis βββΊ CNN + Librosa ββββββββββββββΊ Voice Severity Score
β
βΌ
[Step 5] Final Severity βββΊ Weighted Fusion Algorithm ββΊ Risk Level + Dashboard
- Type: Scikit-learn ensemble classifier (Gradient Boosting)
- Input Features: BMI category, sleep hours, sleep quality, physical activity level, stress level, heart rate, daily steps, systolic BP, diastolic BP
- Output: Risk category (
Low/Moderate/High) + confidence score + severity integer (0β100) - Encoders:
Model_Encoders.pklβ handles label encoding and one-hot encoding for categorical inputs
- Type: Fine-tuned ResNet Convolutional Neural Network (~303 MB)
- Input: Video frames captured via the user's webcam, preprocessed with OpenCV
- Output: Dominant facial emotion (e.g.,
Sad,Angry,Neutral,Happy,Fear,Disgust,Surprise) with per-class confidence scores - Severity Mapping: Emotions are mapped to a severity integer; negative valence emotions score higher
- Type: Custom 1D/2D CNN trained on acoustic features
- Feature Extraction: Librosa extracts MFCCs, chroma, spectral contrast, and mel-spectrogram features
- Preprocessing:
scaler2.pickle(StandardScaler) +encoder2.pickle(LabelEncoder) - Output: Voice emotion label + voice stress (
Normal/Stressed/Highly Stressed) + voice mood + severity score
- Sentiment Analysis: VADER (
vaderSentiment) for rapid valence scoring + TextBlob for subjectivity - LLM Integration: OpenRouter API (Gemini model) for structured mental health Q&A
- Extracted Signals: Problem description, duration, triggers, emotions, physical symptoms, coping strategy, support availability, daily life impact, intensity score
- Risk Flagging: Automatic High/Critical flag for detected crisis indicators
- Combines all four modality scores using a weighted average algorithm
- Calculates overall risk level:
Low (0β30)/Moderate (31β55)/High (56β79)/Critical (80β100) - Generates a natural language summary note for the dashboard
| Technology | Version | Purpose |
|---|---|---|
| React | 19.x | Core UI framework |
| Vite | 7.x | Build tool & dev server |
| Tailwind CSS | 4.x | Utility-first styling |
| Framer Motion | 12.x | Page transitions & animations |
| React Router DOM | 7.x | Client-side routing |
| Recharts | 3.x | Dashboard data visualization |
| Three.js / R3F | 0.183 / 9.x | WebGL 3D landing page background |
| GSAP | 3.x | Scroll-triggered animations |
| Lucide React | 0.575 | Icon library |
| React Hot Toast | 2.x | Notification system |
| Axios | 1.x | HTTP client |
@react-oauth/google |
0.13 | Google OAuth 2.0 |
react-circular-progressbar |
2.x | Severity gauge widget |
@vladmandic/face-api |
1.7 | Client-side face detection helper |
| Technology | Version | Purpose |
|---|---|---|
| FastAPI | 0.115 | REST API framework |
| Uvicorn | 0.32 | ASGI server |
| SQLAlchemy | 2.0 | ORM & database abstraction |
| SQLite | β | Lightweight local database |
| TensorFlow / Keras | β₯2.15 | Deep learning inference (Face & Voice) |
| Scikit-learn | 1.6 | ML model inference (Behaviour) |
| Librosa | 0.10 | Audio feature extraction |
| OpenCV Headless | 4.10 | Video frame processing |
| VADER Sentiment | 3.3 | NLP sentiment analysis |
| TextBlob | 0.18 | NLP subjectivity analysis |
| Passlib + Bcrypt | 1.7 / 4.2 | Password hashing |
| python-jose | 3.3 | JWT token generation & validation |
| python-dotenv | 1.0 | Environment variable management |
| ReportLab | 4.2 | PDF generation |
| Soundfile + Noisereduce | 0.12 / 3.0 | Audio preprocessing |
| httpx | 0.27 | Async HTTP client (OpenRouter API) |
| Technology | Purpose |
|---|---|
| Vercel | Frontend hosting & CI/CD pipeline |
| Hugging Face Spaces | Backend hosting (Dockerized FastAPI) |
| Docker | Containerization for ML backend environment |
| Git & GitHub | Version control and source code management |
MindCare-AI/
β
βββ backend/ # FastAPI Python Backend
β βββ main.py # App entry point, CORS, lifespan
β βββ database.py # SQLAlchemy engine & session
β βββ models.py # All ORM table definitions
β βββ ml_loader.py # Model loading at startup
β βββ ai_service.py # OpenRouter/Gemini LLM service
β βββ nlp_service.py # NLP analysis (VADER + TextBlob)
β βββ jwt_handler.py # JWT encode/decode utilities
β βββ email_service.py # SMTP OTP email sender
β βββ requirements.txt # Python dependencies
β βββ mindcare.db # SQLite database file
β βββ routers/
β β βββ auth.py # Register, login, Google OAuth, OTP reset
β β βββ behaviour.py # Behaviour test submission & history
β β βββ chat.py # Chat counselling & NLP analysis
β β βββ face.py # Facial emotion video upload & inference
β β βββ voice.py # Voice audio upload & inference
β β βββ severity.py # Final severity fusion & report
β β βββ dashboard.py # Dashboard data, tasks, Dr. MindCare chat
β βββ Pre-trained_Models/ # β Place downloaded models here
β β βββ Step1_Behaviour/
β β β βββ Best_Mental_Behaviour_Model.pkl
β β β βββ Model_Encoders.pkl
β β βββ Step3_Face/
β β β βββ Resnet_model_version_2.keras
β β βββ Step4_Voice/
β β βββ CNN_model.json
β β βββ CNN_model.weights.h5
β β βββ encoder2.pickle
β β βββ scaler2.pickle
β βββ uploads/ # Uploaded audio/video files
β
βββ frontend/ # React + Vite Frontend
β βββ index.html
β βββ vite.config.js
β βββ package.json
β βββ src/
β βββ App.jsx # Root router with protected routes
β βββ main.jsx # React DOM entry point
β βββ index.css # Global styles & design tokens
β βββ api.js # Axios base URL configuration
β βββ contexts/
β β βββ AuthContext.jsx # JWT auth state management
β βββ components/
β β βββ Particles.jsx # Animated particle backdrop
β β βββ CustomCursor.jsx # Custom cursor effect
β β βββ CinematicTransition.jsx # Page transition wrapper
β βββ hooks/ # Custom React hooks
β βββ services/ # API service functions
β βββ pages/
β βββ Landing.jsx # Hero page (Three.js WebGL)
β βββ Login.jsx # JWT + Google OAuth login
β βββ Register.jsx # Multi-step registration
β βββ ForgotPassword.jsx # 3-step OTP password reset
β βββ BehaviourTest.jsx # Step 1: Lifestyle questionnaire
β βββ ChatCounselling.jsx # Step 2: AI chat assessment
β βββ FaceEmotion.jsx # Step 3: Webcam facial analysis
β βββ VoiceAnalysis.jsx # Step 4: Microphone voice analysis
β βββ FinalSeverity.jsx # Fusion report & severity score
β βββ Dashboard.jsx # Main wellness dashboard
β
βββ model_training/ # β Place downloaded training resources here
β βββ (Jupyter notebooks for each modality)
β βββ (Training datasets)
β
βββ run_backend.bat # One-click backend launcher (Windows)
βββ run_frontend.bat # One-click frontend launcher (Windows)
βββ .gitignore
βββ README.md
Due to GitHub's file size limits, the large pre-trained multimodal models and the training datasets/scripts are hosted externally on Google Drive. To fully run or explore this project, please download the resource file below:
π₯ Download MindCare Resources (Models & Training Data)
Once you download and extract MindCare_Resources.zip, you will find two folders inside. Please place them as instructed below:
Pre-trained_Models/: Move this entire folder directly inside thebackend/directory of this project. (These are the.keras,.h5, and.pklfiles required for the FastAPI backend to run).model_training/: Move this folder to the root directory of the project. (This contains the Jupyter notebooks, scripts, and datasets used to train the multimodal AI models).
- Python 3.10 or higher
- Node.js 18 or higher (with npm)
- Git
- A webcam and microphone (required for Face & Voice analysis modules)
git clone https://github.com/Hashmil-Muhammed/Smart-Mental-Health-Counselling-System-Using-Multimodal-AI.git
cd Smart-Mental-Health-Counselling-System-Using-Multimodal-AIFollow the instructions above to download and correctly place the Pre-trained_Models/ folder inside backend/.
cd backend
# Create and activate a virtual environment
python -m venv venv
# Windows
venv\Scripts\activate
# macOS/Linux
source venv/bin/activate
# Install all Python dependencies
pip install -r requirements.txtConfigure Backend Environment Variables:
Create a .env file inside the backend/ directory:
SECRET_KEY=your_super_secret_jwt_key_here
DATABASE_URL=sqlite:///./mindcare.db
OPENROUTER_API_KEY=your_openrouter_api_key_here
SMTP_EMAIL=your_gmail_address@gmail.com
SMTP_PASSWORD=your_gmail_app_password
GOOGLE_CLIENT_ID=your_google_oauth_client_idStart the Backend Server:
uvicorn main:app --host 0.0.0.0 --port 8000 --reloadThe API will be live at http://localhost:8000
Interactive API docs available at http://localhost:8000/docs
cd frontend
# Install Node.js dependencies
npm installConfigure Frontend Environment Variables:
Create a .env file inside the frontend/ directory:
VITE_API_BASE_URL=http://localhost:8000
VITE_GOOGLE_CLIENT_ID=your_google_oauth_client_idStart the Frontend Dev Server:
npm run devThe application will be available at http://localhost:5173
For convenience, use the provided batch scripts from the project root:
# Terminal 1 β Start Backend
run_backend.bat
# Terminal 2 β Start Frontend
run_frontend.batThe FastAPI backend automatically generates interactive documentation. Once the server is running, visit:
- Swagger UI:
http://localhost:8000/docs - ReDoc:
http://localhost:8000/redoc
| Method | Endpoint | Description | Auth |
|---|---|---|---|
POST |
/auth/register |
Register a new user account | β |
POST |
/auth/login |
Login with email/password β JWT | β |
POST |
/auth/google |
Login with Google OAuth | β |
POST |
/auth/forgot-password |
Request OTP for password reset | β |
POST |
/auth/verify-otp |
Verify OTP code | β |
POST |
/auth/reset-password |
Set new password | β |
POST |
/behaviour/submit |
Submit behavioural assessment | β |
GET |
/behaviour/history |
Get past behaviour results | β |
POST |
/chat/send |
Send message to AI counsellor | β |
GET |
/chat/history |
Retrieve chat message history | β |
POST |
/face/analyze |
Upload video β facial emotion | β |
POST |
/voice/analyze |
Upload audio β voice emotion | β |
GET |
/severity/final |
Get fused final severity report | β |
GET |
/dashboard/summary |
Full dashboard data payload | β |
GET |
/dashboard/tasks |
Get daily wellness tasks | β |
POST |
/dashboard/tasks/complete |
Mark a task as completed | β |
POST |
/dashboard/doctor-chat |
Chat with Dr. MindCare bot | β |
GET |
/health |
Backend & model health check | β |
β = Requires
Authorization: Bearer <token>header
The SQLite database (mindcare.db) is managed by SQLAlchemy and contains the following tables:
| Table | Description |
|---|---|
register_database |
User profiles (name, age, gender, occupation, email, Google ID) |
behaviour_results |
Behavioural test submissions with ML predictions |
chat_messages |
Raw chat counselling message history |
chat_analysis |
Structured NLP analysis results from counselling sessions |
face_results |
Facial emotion detection results with emotion distribution |
voice_results |
Voice emotion results with stress and mood labels |
final_severity_results |
Fused severity scores and risk level per session |
emergency_events |
High-severity / crisis trigger event log |
suggestions |
Personalized recommendations stored per severity level |
daily_tasks |
Daily wellness task list with completion tracking |
doctor_chat_messages |
Dr. MindCare AI therapist conversation history |
password_reset_otps |
Time-limited OTP records for password reset flow |
| Screen | Route | Description |
|---|---|---|
| Landing Page | / |
Hero page with Three.js WebGL background, GSAP scroll animations, and feature showcase |
| Login | /login |
JWT + Google OAuth sign-in with glassmorphic card |
| Register | /register |
Multi-step registration with profile details |
| Forgot Password | /forgot-password |
3-step OTP-based password reset via email |
| Behaviour Test | /behaviour |
Lifestyle questionnaire form β ML prediction |
| Chat Counselling | /chat |
NLP-powered AI chat assessment session |
| Facial Emotion | /face |
Live webcam capture β ResNet emotion analysis |
| Voice Analysis | /voice |
Microphone recording β CNN emotion analysis |
| Final Severity | /severity |
Fused multimodal report with risk level |
| Dashboard | /dashboard |
Main wellness hub with charts, tasks, Dr. MindCare, and video recommendations |
Here is a glimpse of the MindCare AI platform in action:
| Landing Page |
|---|
![]() |
| Register Account | Login |
|---|---|
![]() |
![]() |
| Behaviour Test Input | Behaviour Test Result |
|---|---|
![]() |
![]() |
| AI Chat Counselling | Chat Summary |
|---|---|
![]() |
![]() |
| Face Emotion (Recording) | Face Emotion (Result) |
|---|---|
![]() |
![]() |
| Voice Stress (Recording) | Voice Stress (Result) |
|---|---|
![]() |
![]() |
| Final Assessment Report | Main Dashboard |
|---|---|
![]() |
![]() |
- Password Hashing: Bcrypt via
passlibβ passwords are never stored in plaintext - JWT Tokens: Signed with
python-jose, validated on every protected route - Google OAuth 2.0: Token verified server-side using Google's public key infrastructure
- OTP Expiry: Password reset OTPs are time-limited and invalidated after use
- CORS: Configured to allow only specified frontend origins
- Environment Variables: All secrets (API keys, SMTP credentials, JWT secret) are stored in
.envfiles β never committed to version control
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature-name - Commit your changes:
git commit -m 'feat: add some feature' - Push to the branch:
git push origin feature/your-feature-name - Open a Pull Request
Please ensure your code follows the existing project structure and styling conventions.
Built with β€οΈ for better mental wellness
MindCare AI β Because your mind matters.












