💖 Maternal Health Chatbot
A simple AI-powered chatbot designed to provide information and support for maternal health questions. This chatbot offers guidance on pregnancy stages, nutrition, common symptoms, and includes emergency detection capabilities.
⚠️ Important Disclaimer
This chatbot is for informational purposes only and should not replace professional medical advice. Always consult with your healthcare provider for medical concerns and emergencies.
🌟 Features
- Comprehensive Knowledge Base: Information about pregnancy stages, nutrition, and common symptoms
- Emergency Detection: Identifies potential emergency situations and recommends immediate medical attention
- Pregnancy Stage Guidance: Specific advice for first, second, and third trimesters
- Nutritional Guidance: Foods to eat/avoid and supplement recommendations
- Symptom Support: Help with common pregnancy symptoms like morning sickness, back pain, and fatigue
- Mental Health Support: Resources and advice for pregnancy-related anxiety and stress
- User-Friendly Interface: Clean, responsive web interface with quick-help topics
🚀 Quick Start
Prerequisites
- Python 3.7 or higher
- Modern web browser
Installation
- Clone or download this project
- Install Python dependencies
- Start the backend server
cd backend python app.py - Open the web interface
- Navigate to the
frontendfolder - Open
index.htmlin your web browser - Or serve it using a local server:
cd frontend python -m http.server 8000Then visit
http://localhost:8000
- Navigate to the
📁 Project Structure
├── backend/
│ └── app.py # Flask API server and chatbot logic
├── frontend/
│ ├── index.html # Main web interface
│ ├── styles.css # Styling and responsive design
│ └── script.js # Frontend JavaScript functionality
├── data/ # Directory for future data files
├── requirements.txt # Python dependencies
└── README.md # This file
🛠️ How It Works
Backend (Flask API)
/chat– POST endpoint for sending messages to the chatbot/health– GET endpoint for health checks/knowledge– GET endpoint to view the knowledge base
Frontend (Web Interface)
- Clean, responsive design optimized for mobile and desktop
- Real-time chat interface with typing indicators
- Quick-help topics for common questions
- Emergency alert styling for urgent situations
Chatbot Logic
The chatbot processes user messages and provides appropriate responses based on:
- Emergency keyword detection
- Pregnancy stage identification
- Symptom recognition
- Nutrition and lifestyle questions
- Mental health support
💡 Usage Examples
Sample Questions You Can Ask:
- “What are first trimester symptoms?”
- “What foods should I avoid during pregnancy?”
- “I have morning sickness, what can I do?”
- “Tell me about prenatal vitamins”
- “I’m feeling anxious about pregnancy”
- “What exercise is safe during pregnancy?”
Emergency Detection
The chatbot automatically detects potential emergency situations and will:
- Provide immediate guidance to seek medical attention
- Display emergency alerts prominently
- Recommend contacting healthcare providers or emergency services
🔧 Customization
Adding New Knowledge
Edit the knowledge_base dictionary in backend/app.py to add:
- New emergency signs
- Additional pregnancy stage information
- More nutritional guidance
- Extra symptom responses
Styling Changes
Modify frontend/styles.css to customize:
- Color scheme
- Typography
- Layout and spacing
- Mobile responsiveness
API Integration
- Add API credentials to environment variables
- Install additional packages (e.g.,
openai,anthropic) - Modify the
process_messagemethod in the chatbot class
🌐 Deployment Options
Local Development
- Use the included Flask development server
- Serve frontend files directly from filesystem
Production Deployment
- Backend: Deploy Flask app to Heroku, AWS, or similar
- Frontend: Host on GitHub Pages, Netlify, or any static hosting
- Database: Add PostgreSQL or MongoDB for conversation logging
🔒 Privacy & Security
- No user data is stored by default
- All conversations are processed locally
- Consider adding HTTPS for production use
- Implement user authentication if needed
📋 Future Enhancements
- [ ] Integration with AI APIs (OpenAI, Anthropic)
- [ ] Multi-language support
- [ ] User account system with conversation history
- [ ] Healthcare provider integration
- [ ] Mobile app development
- [ ] Voice interface support
- [ ] Appointment scheduling features
- [ ] Medication reminders
- [ ] Progress tracking and milestone notifications