A RESTful Patient Management System API built with FastAPI and Pydantic. This project demonstrates how to build a scalable backend API with complete CRUD operations, request validation, automatic BMI calculation, and interactive API documentation.
- ➕ Create a new patient
- 📋 View all patients
- 🔍 Retrieve a patient by ID
- ✏️ Update patient information
- ❌ Delete a patient
- 📊 Sort patients by Height, Weight, or BMI
- 🧮 Automatic BMI calculation
- 💡 Automatic BMI health verdict
- ✅ Request validation using Pydantic
⚠️ Proper exception handling- 📖 Interactive API documentation with Swagger UI
- Python
- FastAPI
- Pydantic v2
- Uvicorn
- JSON (Data Storage)
Patient-Management-System/
│── main.py
│── patients.json
│── requirements.txt
│── README.md
└── .gitignore
git clone https://github.com/<your-github-username>/Patient-Management-System.gitcd Patient-Management-SystemWindows
python -m venv venv
venv\Scripts\activateLinux / macOS
python3 -m venv venv
source venv/bin/activatepip install -r requirements.txtuvicorn main:app --reloadServer will run on:
http://127.0.0.1:8000
FastAPI automatically generates interactive documentation.
http://127.0.0.1:8000/docs
http://127.0.0.1:8000/redoc
| Method | Endpoint | Description |
|---|---|---|
| GET | / |
Home |
| GET | /about |
About the API |
| GET | /view |
View all patients |
| GET | /patient/{patient_id} |
Get patient by ID |
| GET | /sort?sort_by=Height&order=asc |
Sort patients |
| POST | /create_patient |
Create a patient |
| PUT | /update_patient/{patient_id} |
Update patient |
| DELETE | /delete_patient/{patient_id} |
Delete patient |
The API automatically calculates the Body Mass Index (BMI):
BMI = Weight (kg) / Height² (m²)
Based on the BMI value, the API also returns a health verdict:
- Underweight
- Normal Weight
- Overweight
- Obesity
- REST API Development
- CRUD Operations
- FastAPI Routing
- Pydantic Models
- Data Validation
- Computed Fields
- Query Parameters
- Path Parameters
- HTTP Status Codes
- Exception Handling
- JSON Responses
- File Handling
- API Documentation
Add screenshots of your API here:
- Swagger UI Home
- Create Patient
- View Patient
- Update Patient
- Delete Patient
- Sort Patients
- MongoDB Integration
- PostgreSQL Support
- JWT Authentication
- User Login & Registration
- Search & Filtering
- Pagination
- Docker Support
- Unit Testing with Pytest
- Deployment on Render/Railway
- CI/CD using GitHub Actions
This project helped me strengthen my understanding of:
- Backend development using FastAPI
- Building RESTful APIs
- Data validation with Pydantic
- Request and response handling
- Clean API design
- Error handling
- API documentation with Swagger UI
It also serves as a strong foundation for deploying AI/ML models using FastAPI in future projects.
Contributions, suggestions, and feedback are always welcome.
If you'd like to improve this project, feel free to fork the repository and submit a pull request.
If you found this project helpful, consider giving it a ⭐ on GitHub.
Happy Coding! 🚀