MediGuard is a comprehensive, secure medication management platform designed to help individuals, families, and caregivers track medications, manage prescriptions, set reminders, and ensure medication safety with AI-powered assistance.
- Complete Medicine Tracking - Add, edit, and organize medications with detailed information
- Expiry Date Monitoring - Automatic alerts for expiring medications
- Stock Level Management - Track quantities and get low stock notifications
- Barcode/QR Code Support - Quick medicine entry via scanning
- Batch Operations - Manage multiple medications efficiently
- Role-Based Access Control - Admin and User roles with granular permissions
- Family Member Management - Add and manage family members' medications
- Caregiver Permissions - Grant controlled access to caregivers
- Emergency Contacts - Quick access to emergency contact information
- Email Notifications - Expiry alerts, low stock warnings, and reminders
- SMS Alerts - Critical notifications via Twilio integration
- Customizable Reminders - Set medication reminders with flexible schedules
- Daily/Weekly Digests - Summary reports of medication status
- Medication Information - Get instant answers about medications
- Drug Interactions - Check for potential interactions
- Dosage Guidance - AI-powered dosage recommendations
- Health Tips - Personalized medication management advice
- Powered by Google Gemini - Advanced natural language processing
- Manufacturer Database - Track medication manufacturers with contact details
- Category Organization - Organize medicines by therapeutic categories
- Verification System - Verify manufacturer authenticity
- Detailed Profiles - Store licenses, websites, and descriptions
- CSRF Protection - Secure forms with Flask-WTF
- Rate Limiting - Prevent abuse with Flask-Limiter
- Secure Headers - Enhanced security with Flask-Talisman
- Password Hashing - Werkzeug secure password storage
- Session Management - Secure session handling
- Audit Logging - Complete activity tracking for compliance
- System Overview - Real-time statistics and metrics
- User Management - Promote, demote, activate/deactivate users
- Audit Logs - Comprehensive activity monitoring
- System Health - Monitor application performance
- Bulk Operations - Efficient management of large datasets
- Responsive Design - Works seamlessly on desktop, tablet, and mobile
- Bootstrap 5 - Modern, clean interface
- Font Awesome Icons - Beautiful iconography
- Gradient Themes - Eye-catching visual design
- Dark Mode Ready - Comfortable viewing in any lighting
- Python 3.9 or higher
- MySQL 8.0 or higher
- Redis (optional, for caching)
- Gmail account (for email notifications)
- Twilio account (optional, for SMS)
- Google Gemini API key (for AI assistant)
- Clone the repository
git clone https://github.com/yourusername/mediguard.git
cd mediguard- Create virtual environment
python -m venv .venv- Activate virtual environment
Windows:
.venv\Scripts\activateLinux/Mac:
source .venv/bin/activate- Install dependencies
pip install -r requirements.txt- Set up MySQL database
# Login to MySQL
mysql -u root -p
# Create database
CREATE DATABASE medication_navigator;- Configure environment variables
# Copy example environment file
cp .env.example .env
# Edit .env with your configuration
# Required: SECRET_KEY, MYSQL credentials, MAIL settings- Initialize database
python
>>> from app import app, db
>>> with app.app_context():
>>> db.create_all()
>>> exit()- Run the application
python app.py- Access the application
http://127.0.0.1:5000
Create a .env file in the root directory with the following variables:
# Application
SECRET_KEY=your-secret-key-here
FLASK_ENV=development
DEBUG=True
# Database
MYSQL_HOST=localhost
MYSQL_PORT=3306
MYSQL_USER=root
MYSQL_PASSWORD=your-password
MYSQL_DATABASE=medication_navigator
# Email (Gmail)
MAIL_SERVER=smtp.gmail.com
MAIL_PORT=587
MAIL_USE_TLS=True
MAIL_USERNAME=your-email@gmail.com
MAIL_PASSWORD=your-app-password
MAIL_DEFAULT_SENDER=your-email@gmail.com
EMAIL_NOTIFICATIONS_ENABLED=True
# SMS (Twilio - Optional)
TWILIO_ACCOUNT_SID=your-account-sid
TWILIO_AUTH_TOKEN=your-auth-token
TWILIO_PHONE_NUMBER=+1234567890
SMS_NOTIFICATIONS_ENABLED=False
# AI Assistant (Google Gemini)
GEMINI_API_KEY=your-gemini-api-key
# Scheduler
SCHEDULER_ENABLED=True
REMINDER_CHECK_INTERVAL=60Gmail App Password:
- Enable 2-Factor Authentication on your Google account
- Go to Google Account > Security > App Passwords
- Generate a new app password for "Mail"
Twilio (Optional):
- Sign up at https://www.twilio.com
- Get your Account SID and Auth Token from the dashboard
- Purchase a phone number for SMS
Google Gemini API:
- Visit https://makersuite.google.com/app/apikey
- Create a new API key
- Copy the key to your .env file
-
Create Admin Account
- Navigate to
/signup - Register with your details
- First user is automatically assigned admin role
- Navigate to
-
Add Categories
- Go to Admin Dashboard > Manage Categories
- Add medication categories (e.g., Antibiotics, Pain Relief)
-
Add Manufacturers
- Go to Admin Dashboard > Manage Manufacturers
- Add pharmaceutical manufacturers with contact details
-
Add Medications
- Go to Dashboard > Add Medicine
- Fill in medication details
- Set expiry dates and stock levels
-
Set Up Reminders
- Go to Reminders section
- Create medication reminders with schedules
Admin:
- Full system access
- User management
- View all medications across users
- System configuration
- Audit log access
User:
- Manage own medications
- Add family members
- Set reminders
- View personal dashboard
- Use AI assistant
mediguard/
β
βββ app.py # Main application file
βββ forms.py # WTForms form definitions
βββ sms_templates.py # SMS notification templates
βββ requirements.txt # Python dependencies
βββ .env.example # Environment variables template
βββ .gitignore # Git ignore rules
β
βββ config/
β βββ secure_config.py # Application configuration
β
βββ services/
β βββ ai_assistant_service.py # AI assistant logic
β βββ medicine_service.py # Medicine business logic
β βββ notification_service.py # Notification handling
β
βββ scripts/
β βββ mysql_schema.sql # Database schema
β βββ setup_mysql_database.py # Database setup script
β βββ mysql_backup.py # Backup utility
β
βββ templates/
β βββ base.html # Base template
β βββ index.html # Landing page
β βββ dashboard.html # User dashboard
β βββ admin_dashboard.html # Admin dashboard
β βββ medicines.html # Medicine list
β βββ add_medicine.html # Add medicine form
β βββ edit_medicine.html # Edit medicine form
β βββ reminders.html # Reminders page
β βββ manage_users.html # User management
β βββ manage_manufacturers.html # Manufacturer management
β βββ manage_categories.html # Category management
β βββ medication_assistant.html # AI assistant interface
β βββ profile.html # User profile
β βββ login.html # Login page
β βββ signup.html # Registration page
β βββ emails/ # Email templates
β βββ errors/ # Error pages
β
βββ static/
β βββ uploads/ # User uploaded files
β
βββ backups/ # Database backups
- users - User accounts and authentication
- medicines - Medication records
- categories - Medication categories
- manufacturers - Pharmaceutical manufacturers
- reminders - Medication reminders
- family_members - Family member profiles
- caregiver_permissions - Access control for caregivers
- emergency_contacts - Emergency contact information
- audit_logs - System activity tracking
- notifications - Notification queue
- Password Hashing - Werkzeug PBKDF2 with salt
- CSRF Protection - Token-based form protection
- Rate Limiting - Prevent brute force attacks
- Secure Headers - CSP, HSTS, X-Frame-Options
- Session Security - HTTPOnly, Secure, SameSite cookies
- Input Validation - WTForms validators
- SQL Injection Prevention - SQLAlchemy ORM
- XSS Protection - Jinja2 auto-escaping
- Audit Logging - Complete activity tracking
POST /login- User loginPOST /signup- User registrationGET /logout- User logoutPOST /forgot-password- Password reset requestPOST /reset-password- Password reset
GET /medicines/- List user medicinesPOST /medicines/add- Add new medicineGET /medicines/edit/<id>- Edit medicinePOST /medicines/delete/<id>- Delete medicineGET /api/medicines- API endpoint for medicines
GET /admin/dashboard- Admin dashboardGET /admin/users- User managementGET /admin/medicines- All medicines viewGET /admin/manufacturers- Manufacturer managementGET /admin/categories- Category managementGET /admin/audit-logs- Audit logsGET /admin/system-status- System health
POST /medication-assistant- AI chat endpoint
# Run tests (when implemented)
pytest
# Check code coverage
pytest --cov=app
# Lint code
flake8 app.py- Set
FLASK_ENV=productionin.env - Set
DEBUG=False - Use strong
SECRET_KEY - Enable
SESSION_COOKIE_SECURE=True(HTTPS only) - Configure production database
- Set up Redis for caching
- Configure email/SMS services
- Enable HTTPS with SSL certificate
- Set up automated backups
- Configure monitoring and logging
Option 1: Traditional Server
# Install gunicorn
pip install gunicorn
# Run with gunicorn
gunicorn -w 4 -b 0.0.0.0:5000 app:appOption 2: Docker
# Create Dockerfile
FROM python:3.9-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:5000", "app:app"]Option 3: Cloud Platforms
- Heroku
- AWS Elastic Beanstalk
- Google Cloud Run
- Azure App Service
- DigitalOcean App Platform
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- Follow PEP 8 style guide
- Write descriptive commit messages
- Add comments for complex logic
- Update documentation
- Test your changes
Database Connection Error:
Solution: Check MySQL is running and credentials in .env are correct
Email Not Sending:
Solution: Verify Gmail app password and enable "Less secure app access"
Redis Connection Failed:
Solution: Application falls back to SimpleCache automatically
AI Assistant Not Working:
Solution: Verify GEMINI_API_KEY is set correctly in .env
Port Already in Use:
# Windows
netstat -ano | findstr :5000
taskkill /PID <PID> /F
# Linux/Mac
lsof -ti:5000 | xargs kill -9This project is licensed under the MIT License - see the LICENSE file for details.
Your Name
- GitHub: @yourusername
- Email: your.email@example.com
- Flask framework and community
- Bootstrap for UI components
- Font Awesome for icons
- Google Gemini for AI capabilities
- Twilio for SMS services
- All contributors and users
For support, email support@mediguard.com or open an issue on GitHub.
- Mobile app (iOS/Android)
- Prescription scanning with OCR
- Pharmacy integration
- Insurance claim tracking
- Multi-language support
- Voice reminders
- Wearable device integration
- Telemedicine integration
- Advanced analytics dashboard
- Export to PDF/Excel
- AI-powered medication assistant
- Family member management
- Caregiver permissions
- Medication interaction checker
- Refill reminders
- Doctor appointment tracking
Made with β€οΈ for better medication management