📘 MindMate — AI Mental Health Chatbot
MindMate is an AI-powered mental health support chatbot that provides empathetic, context-aware responses and emotional support. It detects the user’s emotional state and intensity from text, maintains conversational memory, stores interactions, and visualizes emotional trends through a dashboard.
🌟 Features
✅ Real-time emotion detection (Transformer + Rule-based) ✅ Emotion intensity classification (normal & high) ✅ Session-based conversational memory ✅ Context-aware response generation (avoids repetition) ✅ Crisis detection and safety message delivery ✅ SQLite storage of chat history ✅ Dashboard analytics (emotion counts, trends) ✅ Lightweight deployment on Render ✅ Relaxation tips for emotional coping
🧠 Algorithm Overview
User sends a message
Flask server receives request
Crisis keyword check (safety layer)
Save message to session history (last 5 messages)
Emotion detection (Text → Transformer / Rule)
Emotion intensity classification
Context continuity comparison
Smart response generation
Tip attachment
Save chat & emotion to SQLite
Return response to user
Dashboard updated with new data
This creates a context-aware and emotionally sensitive chatbot that responds meaningfully while tracking emotional trends.
🧩 Tech Stack Component Technology Backend Python, Flask NLP/AI Transformer-based emotion model (optional/prod-light rule) Database SQLite Frontend HTML, CSS, JavaScript Deployment Render Session Flask session for memory 📁 Project Structure MINDMATE/ ├── app.py ├── templates/ │ ├── index.html │ └── dashboard.html ├── static/ ├── requirements.txt ├── mindmate.db ├── emotion_model.py (optional) ├── sentiment_test.py └── emotion_test.py 🚀 Getting Started 1️⃣ Clone the repository git clone https://github.com/Athiraa1804/MINDMATE.git cd MINDMATE 2️⃣ Install dependencies pip install -r requirements.txt 3️⃣ Run the app (local) python app.py
The app will start locally on:
http://127.0.0.1:5000 📊 Dashboard
Navigate to:
http://127.0.0.1:5000/dashboard
Dashboard visualizes: ✔ Total chats ✔ Emotion breakdown ✔ Most frequent emotion
🧠 Emotion Detection
The system supports both modes:
Local fast mode
Rule-based detection
Lightweight
Works on deployment free tiers
Transformer mode (optional)
Install the transformer model in local environment only:
USE_TRANSFORMER=True python app.py
This enables a more accurate emotion classifier.
💾 Database
Chats are stored in:
mindmate.db
Table: chats
Column Type id INTEGER username TEXT message TEXT emotion TEXT timestamp TEXT 📦 Environment Variables
To enable transformer mode in production, configure the following in Render:
USE_TRANSFORMER=True
If not set, the app defaults to lightweight mode.
📍 Crisis Detection
The chatbot detects potentially harmful content like:
suicide, kill myself, die, end my life, can't live
and immediately recommends a helpline.
📌 Deployment (Render)
Push code to GitHub
Connect repo to Render
Set environment variables
Deploy web service
Enjoy online hosted chatbot
Render will automatically build and run your app.
🧩 Future Improvements
✔ Dynamic adaptive learning ✔ Emotion intensity progression ✔ User profile tracking ✔ Advanced analytics graphs ✔ Multi-modal input (voice/image) ✔ Integration with help resources and strategies
📝 License
This project is for academic and educational use.