A Self-Hostable Medical Clinic Management System
Built with Django, TailwindCSS, and designed for easy self-hosting
Features β’ Quick Start β’ Installation β’ Configuration β’ Usage β’ Architecture β’ Troubleshooting β’ Contributing
Imhotep Smart Clinic is a fully self-hostable, open-source medical clinic management system designed for doctors and medical practices who want complete control over their patient data and clinic operations. Built with modern web technologies, it provides a comprehensive solution for managing patients, prescriptions, appointments, and medical records.
- Complete Data Ownership: Your patient data stays on your servers
- Privacy Compliant: Meet local data protection regulations (HIPAA, GDPR, etc.)
- Cost Effective: No monthly subscription fees
- Customizable: Modify the system to fit your clinic's workflow
- No Vendor Lock-in: Your data is always accessible
Located at: /doctor/
-
Dashboard Analytics
- Patient statistics and growth trends
- Recent activity overview
- Quick access to pending tasks
- Visual charts and graphs
-
Patient Management (
/doctor/patients/)- Complete patient registry
- Detailed medical histories
- Patient search and filtering
- Add/edit/delete patient records
- Track patient visits and outcomes
-
Prescription System (
/doctor/prescriptions/)- Rich text prescription editor
- Support for Arabic and English text
- PDF generation with custom branding
- Prescription templates
- Print and download prescriptions
- Prescription history tracking
-
Assistant Management (
/doctor/assistants/)- Invite and manage clinic assistants
- Assign roles and permissions
- Monitor assistant activity
Located at: /assistant/
-
Patient Operations
- View assigned patient list
- Update patient contact information
- Schedule and manage appointments
- Add patient notes and updates
-
Daily Operations
- Appointment calendar
- Patient check-in/check-out
- Task management
Located at: /accounts/
-
User Registration (
/accounts/register/)- Email-based registration
- Role selection (Doctor/Assistant)
- Email verification (if configured)
-
Login Options (
/accounts/login/)- Standard email/password login
- Google OAuth integration (optional)
- "Remember me" functionality
-
Profile Management (
/accounts/profile/)- Update personal information
- Change password
- Manage clinic details (doctors only)
-
Password Recovery (
/accounts/password-reset/)- Email-based password reset
- Secure token generation
- Install on Mobile: Add to home screen on iOS/Android
- Offline Capability: Basic functionality works offline
- Responsive Design: Works on desktop, tablet, and mobile
- App-like Experience: Native app feel on mobile devices
- Arabic Support: Full RTL support for Arabic prescriptions
- English Interface: Default English UI
- Easy Translation: i18n ready for additional languages
- Professional Prescriptions: Generate branded PDF prescriptions
- WeasyPrint Integration: High-quality PDF rendering
- Custom Templates: Customize prescription layout
- Print Ready: Optimized for A4 printing
# 1. Clone the repository
git clone https://github.com/Imhotep-Tech/imhotep_smart_clinic.git
cd imhotep_smart_clinic
# 2. Create your configuration file
cp .env.example .env
# Edit .env with your settings (see Configuration section)
# 3. Start the application
docker-compose up -d
# 4. Access your clinic at http://localhost:8000# 1. Clone the repository
git clone https://github.com/Imhotep-Tech/imhotep_smart_clinic.git
cd imhotep_smart_clinic
# 2. Create virtual environment
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
# 3. Install dependencies
pip install -r requirements.txt
# 4. Configure environment
cp .env.example .env
# Edit .env with your settings
# 5. Set up database
python manage.py migrate
python manage.py createsuperuser
# 6. Start development server
python manage.py runserver
# 7. Access at http://localhost:8000-
For Docker Setup:
- Docker Engine 20.10+
- Docker Compose 1.29+
- 2GB RAM minimum, 4GB recommended
- 10GB free disk space
-
For Manual Setup:
- Python 3.8 or higher (3.10+ recommended)
- pip 21.0+
- PostgreSQL 12+ (optional, SQLite works for development)
- Node.js 14+ (optional, for frontend development)
- 2GB RAM minimum, 4GB recommended
Step 1: Prepare Your Server
# Update system packages
sudo apt update && sudo apt upgrade -y
# Install Docker
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
# Install Docker Compose
sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
# Verify installation
docker --version
docker-compose --versionStep 2: Clone and Configure
# Clone the repository
git clone https://github.com/Imhotep-Tech/imhotep_smart_clinic.git
cd imhotep_smart_clinic
# Create environment file
cp .env.example .env
# Edit configuration (see Configuration section)
nano .env # or use your preferred editorStep 3: Launch Application
# Build and start containers
docker-compose up -d --build
# Wait for containers to be healthy
docker-compose ps
# Collect static files (for production)
docker-compose exec web python manage.py collectstatic --no-inputStep 4: Verify Installation
# Check application logs
docker-compose logs -f web
# Access the application
# Open http://your-server-ip:8000 in your browserStep 1: Install System Dependencies
# For Ubuntu/Debian
sudo apt update
sudo apt install python3 python3-pip python3-venv postgresql postgresql-contrib
sudo apt install libpq-dev python3-dev # For PostgreSQL
sudo apt install libcairo2 libpango-1.0-0 libpangocairo-1.0-0 # For PDF generation
# For macOS
brew install python postgresql cairo pango gdk-pixbuf libffiStep 2: Set Up PostgreSQL (Optional)
# Create database and user
sudo -u postgres psql
postgres=# CREATE DATABASE imhotepclinic_db;
postgres=# CREATE USER imhotepclinic_user WITH PASSWORD 'your_secure_password';
postgres=# ALTER ROLE imhotepclinic_user SET client_encoding TO 'utf8';
postgres=# ALTER ROLE imhotepclinic_user SET default_transaction_isolation TO 'read committed';
postgres=# ALTER ROLE imhotepclinic_user SET timezone TO 'UTC';
postgres=# GRANT ALL PRIVILEGES ON DATABASE imhotepclinic_db TO imhotepclinic_user;
postgres=# \qStep 3: Set Up Python Environment
# Clone repository
git clone https://github.com/Imhotep-Tech/imhotep_smart_clinic.git
cd imhotep_smart_clinic
# Create virtual environment
python3 -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
# Install Python dependencies
pip install --upgrade pip
pip install -r requirements.txtStep 4: Configure Application
# Copy environment template
cp .env.example .env
# Edit configuration
nano .env
# Update these minimum settings:
# - SECRET_KEY: Generate a new one
# - DEBUG: Set to False for production
# - database_type: 'postgresql' or 'sqlite'
# - DATABASE_* settings if using PostgreSQL
# - SITE_DOMAIN: Your domain or IPStep 5: Initialize Database
# Run migrations
python manage.py migrate
# Create superuser account
python manage.py createsuperuser
# Collect static files
python manage.py collectstaticStep 6: Run Application
# Development server
python manage.py runserver 0.0.0.0:8000
# For production, use Gunicorn
pip install gunicorn
gunicorn imhotep_smart_clinic.wsgi:application --bind 0.0.0.0:8000 --workers 3Create a .env file by copying .env.example and configure the following:
# DEBUG: Enable detailed error pages
# Set to False in production!
DEBUG=True
# SECRET_KEY: Django secret key for cryptographic signing
# Generate a new one: python -c 'from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())'
SECRET_KEY='your-secret-key-here'
# SITE_DOMAIN: Your clinic's domain or IP address
# Used for OAuth callbacks and email links
# Examples:
# Development: http://localhost:8000
# Production: https://clinic.example.com
SITE_DOMAIN='http://localhost:8000'# database_type: Choose your database backend
# Options: 'postgresql' (recommended for production), 'sqlite' (development only)
database_type='postgresql'
# PostgreSQL Settings (only if database_type='postgresql')
DATABASE_NAME='imhotepclinic_db'
DATABASE_USER='imhotepclinic_user'
DATABASE_PASSWORD='strong_password_here'
DATABASE_HOST='localhost' # Use 'db' for Docker, 'localhost' for local PostgreSQL
# SQLite: No configuration needed, file created automatically# To enable Google Sign-In:
# 1. Go to https://console.cloud.google.com/
# 2. Create a new project or select existing
# 3. Enable Google+ API
# 4. Create OAuth 2.0 credentials
# 5. Add authorized redirect URI: {SITE_DOMAIN}/accounts/google/callback/
GOOGLE_CLIENT_ID='your-client-id.apps.googleusercontent.com'
GOOGLE_CLIENT_SECRET='your-client-secret'
# Leave empty to disable Google login# Email settings for password reset and notifications
# Leave empty to disable email features
# For Gmail:
MAIL_USER='your-email@gmail.com'
MAIL_PASSWORD='your-app-password' # Not your regular password!
# Generate Gmail App Password:
# 1. Enable 2-Factor Authentication
# 2. Visit https://myaccount.google.com/apppasswords
# 3. Generate app password for "Mail"
# For other SMTP servers, you may need to modify settings.py- Set
DEBUG=False - Generate and set a strong
SECRET_KEY - Configure
SITE_DOMAINto your actual domain - Use PostgreSQL instead of SQLite
- Set strong database passwords
- Configure email settings for notifications
- Set up HTTPS/SSL (highly recommended for medical data)
- Configure regular database backups
- Set up firewall rules
- Enable logging and monitoring
For production deployments, use a reverse proxy like Nginx with Let's Encrypt:
# Install Nginx and Certbot
sudo apt install nginx certbot python3-certbot-nginx
# Configure Nginx (example configuration)
sudo nano /etc/nginx/sites-available/clinic
# Add SSL certificate
sudo certbot --nginx -d your-domain.comExample Nginx configuration:
server {
listen 80;
server_name your-domain.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
server_name your-domain.com;
ssl_certificate /etc/letsencrypt/live/your-domain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/your-domain.com/privkey.pem;
location / {
proxy_pass http://localhost:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /static/ {
alias /path/to/imhotep_smart_clinic/staticfiles/;
}
location /media/ {
alias /path/to/imhotep_smart_clinic/media/;
}
}-
Access the Application
- Navigate to
http://your-domain:8000 - You'll see the landing page
- Navigate to
-
Create Your Account
- Click "Register" (
/accounts/register/) - Choose role: "Doctor" for clinic owner
- Fill in your details
- Verify email if configured
- Click "Register" (
-
Complete Your Profile
- Log in and go to Profile (
/accounts/profile/) - Add clinic information
- Upload profile picture
- Set your specialization
- Log in and go to Profile (
-
Add Your First Patient
- Go to Doctor Portal β Patients (
/doctor/patients/) - Click "Add New Patient"
- Fill in patient details
- Save the record
- Go to Doctor Portal β Patients (
-
Create a Prescription
- Select a patient
- Click "New Prescription" (
/doctor/prescriptions/create/) - Use the rich text editor for prescription details
- Add medications, dosages, instructions
- Save and generate PDF
1. Log in to Doctor Portal (/doctor/)
β
2. View Dashboard
- Check today's appointments
- Review patient statistics
β
3. Manage Patients (/doctor/patients/)
- Add new patients
- Update medical histories
- Review past visits
β
4. Create Prescriptions (/doctor/prescriptions/)
- Select patient
- Write prescription
- Generate PDF
- Print or email to patient
β
5. Manage Staff (/doctor/assistants/)
- Invite assistants
- Assign permissions
1. Log in to Assistant Portal (/assistant/)
β
2. View Today's Schedule
- Check appointments
- Patient check-ins
β
3. Manage Patients (/assistant/patients/)
- Update contact info
- Schedule appointments
- Add notes
β
4. Support Doctor
- Prepare patient files
- Handle administrative tasks
-
Install on Mobile
- Open app in mobile browser
- Tap "Add to Home Screen" (iOS) or "Install" (Android)
- App icon appears on home screen
-
Use Offline
- Basic viewing works without internet
- Sync when connection restored
imhotep_smart_clinic/
βββ accounts/ # User authentication & profiles
β βββ models.py # User, Profile models
β βββ views.py # Login, register, profile views
β βββ forms.py # User forms
β βββ templates/accounts/ # Auth templates
β
βββ doctor/ # Doctor portal
β βββ models.py # Patient, Prescription models
β βββ views.py # Doctor dashboard, patient management
β βββ forms.py # Patient, prescription forms
β βββ urls.py # Doctor routes
β βββ templates/doctor/ # Doctor templates
β
βββ assistant/ # Assistant portal
β βββ views.py # Assistant dashboard
β βββ urls.py # Assistant routes
β βββ templates/assistant/ # Assistant templates
β
βββ static/ # Static files
β βββ css/ # Stylesheets
β βββ js/ # JavaScript files
β βββ images/ # Images and logos
β βββ manifest.json # PWA manifest
β βββ serviceworker.js # PWA service worker
β
βββ templates/ # Base templates
β βββ base.html # Base layout
β βββ landing.html # Landing page
β βββ components/ # Reusable components
β
βββ media/ # User uploads
β βββ profile_pics/ # Profile pictures
β βββ prescriptions/ # Generated PDFs
β
βββ imhotep_smart_clinic/ # Project settings
β βββ settings.py # Django settings
β βββ urls.py # URL configuration
β βββ wsgi.py # WSGI config
β
βββ docker-compose.yml # Docker configuration
βββ Dockerfile # Docker image definition
βββ requirements.txt # Python dependencies
βββ .env.example # Environment template
βββ manage.py # Django management script
βββ README.md # This file
- Backend: Django 4.2+ (Python web framework)
- Database: PostgreSQL 12+ (production) or SQLite (development)
- Frontend: TailwindCSS 3.0+, Alpine.js
- PDF Generation: WeasyPrint (HTML to PDF)
- Authentication: Django Auth + Google OAuth
- PWA: Service Workers, Web Manifest
- Deployment: Docker, Docker Compose, Gunicorn
Key Models:
- User (Django built-in): Authentication
- Profile (accounts): User profiles, clinic info
- Patient (doctor): Patient records
- MedicalHistory (doctor): Patient medical histories
- Prescription (doctor): Prescriptions
- Appointment (doctor): Appointments
Error: django.db.utils.OperationalError: could not connect to server
Solution:
# Check if PostgreSQL is running
sudo systemctl status postgresql
# For Docker, check container status
docker-compose ps
# Verify database credentials in .env
# Ensure DATABASE_HOST matches your setup (localhost or db)Error: CSS/JS not loading, 404 errors
Solution:
# Collect static files
python manage.py collectstatic
# For Docker
docker-compose exec web python manage.py collectstatic
# Check STATIC_ROOT and STATIC_URL in settings.pyError: OSError: cannot load library 'gobject-2.0-0'
Solution:
# Install system dependencies
# Ubuntu/Debian:
sudo apt install libcairo2 libpango-1.0-0 libpangocairo-1.0-0 libgdk-pixbuf2.0-0
# macOS:
brew install cairo pango gdk-pixbuf libffi
# For Docker, these are included in the imageError: Redirect URI mismatch
Solution:
# Ensure SITE_DOMAIN in .env matches your actual domain
SITE_DOMAIN='https://your-actual-domain.com'
# Add this redirect URI in Google Console:
# https://your-actual-domain.com/accounts/google/callback/
# For localhost testing:
# http://localhost:8000/accounts/google/callback/Error: Error: That port is already in use
Solution:
# Find process using port 8000
lsof -i :8000 # macOS/Linux
netstat -ano | findstr :8000 # Windows
# Kill the process or use different port
python manage.py runserver 0.0.0.0:8080- Documentation: Check this README and inline code comments
- Issues: GitHub Issues
- Security: See SECURITY.md
# Pull latest changes
git pull origin main
# For Docker
docker-compose down
docker-compose up -d --build
docker-compose exec web python manage.py migrate
# For manual setup
source venv/bin/activate
pip install -r requirements.txt
python manage.py migrate
python manage.py collectstatic# PostgreSQL backup
docker-compose exec db pg_dump -U imhotepclinic_user imhotepclinic_db > backup_$(date +%Y%m%d).sql
# Restore backup
docker-compose exec -T db psql -U imhotepclinic_user imhotepclinic_db < backup_20240101.sql
# For manual PostgreSQL setup
pg_dump -U imhotepclinic_user imhotepclinic_db > backup.sql
psql -U imhotepclinic_user imhotepclinic_db < backup.sql# Install development dependencies
pip install black flake8 isort
# Format code
black .
# Check style
flake8
# Sort imports
isort .- Create feature branch:
git checkout -b feature/your-feature - Make changes and test thoroughly
- Update documentation
- Commit:
git commit -m "Add: your feature description" - Push:
git push origin feature/your-feature - Create pull request
We welcome contributions! Here's how to get started:
-
Fork the Repository
- Click "Fork" on GitHub
- Clone your fork locally
-
Set Up Development Environment
git clone https://github.com/your-username/imhotep_smart_clinic.git cd imhotep_smart_clinic python -m venv venv source venv/bin/activate pip install -r requirements.txt cp .env.example .env python manage.py migrate
-
Create Feature Branch
git checkout -b feature/amazing-feature
-
Make Your Changes
- Write clean, documented code
- Add tests for new features
- Update documentation
-
Test Your Changes
python manage.py test -
Submit Pull Request
- Push to your fork
- Open PR against
mainbranch - Describe your changes clearly
See CONTRIBUTING.md for detailed guidelines.
This project is licensed under the MIT License - see the LICENSE file for details.
You are free to:
- Use commercially
- Modify
- Distribute
- Private use
Under the condition of:
- Include original license and copyright
Important Security Notes for Self-Hosting:
- Always use HTTPS in production
- Keep
DEBUG=Falsein production - Use strong passwords for database and admin accounts
- Regularly update dependencies
- Set up firewall rules
- Enable database backups
- Monitor application logs
- Follow HIPAA/GDPR guidelines for medical data
Report security vulnerabilities privately according to our Security Policy.
- Django Project - Web framework
- TailwindCSS - CSS framework
- WeasyPrint - PDF generation
- Alpine.js - JavaScript framework
- All our contributors
- Documentation: This README and code comments
- Issues: GitHub Issues
- Discussions: GitHub Discussions
Made with β€οΈ for healthcare professionals who value data ownership and privacy
100% Self-Hostable β’ Open Source β’ Privacy First
