A modern, robust healthcare management API built with FastAPI — delivering secure, scalable, and efficient healthcare services with real-time notifications.
- Docker & Docker Compose
- Python 3.11+ (for local development)
# Clone and deploy in one command
docker-compose up --build -dThe API will be available at: http://localhost:8000 API Documentation: http://localhost:8000/docs
.
├── app/
│ ├── api/
│ │ ├── routes/ # API endpoint handlers
│ │ │ ├── auth.py
│ │ │ ├── appointment.py
│ │ │ ├── doctor.py
│ │ │ └── patient.py
│ │ └── deps.py # Dependency injection
│ ├── core/ # Core application logic
│ │ ├── config.py # Configuration management
│ │ ├── security.py # Authentication & authorization
│ │ ├── cache.py # Redis caching layer
│ │ ├── rate_limiter.py # Request rate limiting
│ │ └── notifications.py # Notification utilities
│ ├── crud/ # Database operations layer
│ │ ├── crud_base.py # Base CRUD operations
│ │ ├── crud_user.py
│ │ ├── crud_patient.py
│ │ ├── crud_doctor.py
│ │ └── crud_appointment.py
│ ├── db/ # Database layer
│ │ ├── models.py # SQLAlchemy models
│ │ └── session.py # Database session management
│ ├── schemas/ # Pydantic schemas
│ │ ├── user.py
│ │ ├── patient.py
│ │ ├── doctor.py
│ │ ├── appointment.py
│ │ └── medical_record.py
│ └── tests/ # Test suites
│ ├── test_api.py
│ ├── test_crud.py
│ └── test_security.py
├── docker-compose.yml # Multi-service orchestration
├── Dockerfile # Main application container
├── Dockerfile.notification # Notification worker container
└── notification_service.py # Async notification processor
The system runs as a multi-container application:
| Service | Purpose | Port | Health Check |
|---|---|---|---|
| app | FastAPI Application | 8000 | HTTP 200 on /health |
| db | PostgreSQL Database | 5432 | pg_isready |
| redis | Redis Cache | 6379 | redis-cli ping |
| rabbitmq | Message Queue | 5672/15672 | Built-in |
# Production deployment
docker-compose up --build -d
# View logs
docker-compose logs -f app
# Stop services
docker-compose down# Create virtual environment
python -m venv .venv
source .venv/bin/activate # Linux/Mac
# OR
.\.venv\Scripts\Activate.ps1 # Windows
# Install dependencies
pip install -r requirements.txt
# Run the application
uvicorn app.main:app --reload --host 127.0.0.1 --port 8000| Command | Description |
|---|---|
docker-compose up --build -d |
Build and start all services |
docker-compose logs -f [service] |
Follow service logs |
docker-compose down |
Stop and remove containers |
docker-compose exec app [cmd] |
Execute command in app container |
| Command | Description |
|---|---|
uvicorn app.main:app --reload |
Start development server |
pytest -q |
Run test suite quietly |
pytest -v |
Run tests with verbose output |
pytest --cov=app |
Run tests with coverage |
- 🔐 Secure Authentication – JWT-based auth with password hashing
- 👥 Role-Based Access Control – Patient, Doctor, and Admin roles
- 📅 Appointment Management – Schedule, reschedule, and cancel appointments
- ⚡ Real-time Notifications – Async notification system with RabbitMQ
- 💾 Intelligent Caching – Redis-powered response caching
- 🚀 Rate Limiting – Request throttling for API protection
- 📊 Health Checks – Container and service health monitoring
- 🔒 Security Hardened – Password validation, SQL injection protection
fastapi– Modern, fast web frameworkuvicorn– ASGI server implementationpydantic– Data validation and settings management
sqlalchemy– SQL toolkit and ORMasyncpg– Async PostgreSQL driveralembic– Database migrations
python-jose– JWT implementationpasslib– Password hashingbcrypt– Secure password hashing
redis– Redis client for Pythoncelery– Distributed task queuepika– RabbitMQ client
python-multipart– Form data handlingemail-validator– Email validationpython-dotenv– Environment variable management
# Database
DATABASE_URL=postgresql://user:pass@db:5432/healthcare_db
DB_PASSWORD=your_secure_password
# Cache
REDIS_URL=redis://redis:6379/0
# Message Queue
RABBITMQ_URL=amqp://user:pass@rabbitmq:5672/
RABBITMQ_USER=admin
RABBITMQ_PASSWORD=your_rabbitmq_password
# Security
SECRET_KEY=your_jwt_secret_keyapp/core/config.py– Centralized configuration managementdocker-compose.yml– Service orchestrationDockerfile– Application container definitionDockerfile.notification– Worker container definition
- Set environment variables in
.envfile - Run
docker-compose up --build -d - Access API at
http://your-server:8000 - Monitor services with
docker-compose logs -f
- API:
GET /health - Database: Automatic health checks in compose
- Redis: Automatic health checks in compose
- Multi-stage Docker builds for optimized image sizes
- Non-root user execution for enhanced security
- Connection pooling for database efficiency
- Request rate limiting to prevent abuse
- JWT token expiration for session security
- Password strength validation with bcrypt hashing
# Run all tests
pytest
# Run with coverage
pytest --cov=app --cov-report=html
# Run specific test module
pytest app/tests/test_api.py -v- Fork the repository
- Create your feature branch
git checkout -b feature/amazing-feature
- Commit your changes
git commit -m 'Add amazing feature' - Push to the branch
git push origin feature/amazing-feature
- Open a Pull Request
This project is licensed under the MIT License.
See the LICENSE file for more information.
Delivering secure, scalable healthcare APIs with cutting-edge technology.