A comprehensive clinic management system backend API built with FastAPI, providing endpoints for patient management, doctor scheduling, appointment booking, and AI-powered prescription generation.
- Patient Management: Registration, login, appointment booking
- Doctor Management: Profile management, schedule setting, appointment viewing
- Nurse Management: Patient care coordination, appointment assistance
- AI-Powered Prescriptions: Automated prescription generation using AI
- Appointment System: Comprehensive booking and management system
- Authentication: JWT-based secure authentication for all user types
- Database: PostgreSQL with SQLAlchemy ORM and Alembic migrations
- Backend Framework: FastAPI
- Database: PostgreSQL
- ORM: SQLAlchemy
- Migrations: Alembic
- Authentication: JWT (JSON Web Tokens)
- AI Integration: Groq and Google Gemini APIs
- PDF Generation: ReportLab
- File Processing: PyPDF2, python-docx
- Python 3.8+
- PostgreSQL
- Virtual Environment (recommended)
- Clone the repository
git clone <repository-url>
cd clinic_flow- Create and activate virtual environment
python -m venv venv
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activate- Install dependencies
pip install -r requirements.txt- Database Setup
- Create a PostgreSQL database named
clinic_flow - Update database credentials in
.envfile - Run migrations:
alembic upgrade head- Environment Variables
Create a
.envfile with:
DATABASE_URL=postgresql://username:password@localhost:5432/clinic_flow
SECRET_KEY=your-secret-key-here
GROQ_API_KEY=your-groq-api-key
GEMINI_API_KEY=your-gemini-api-key
- Run the application
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000The API will be available at http://localhost:8000
Once the server is running, visit:
- Interactive API Docs:
http://localhost:8000/docs - ReDoc Documentation:
http://localhost:8000/redoc
clinic_flow/
├── app/
│ ├── auth/ # Authentication modules
│ ├── core/ # Core security and configuration
│ ├── db/ # Database configuration and models
│ ├── routers/ # API route handlers
│ ├── schemas/ # Pydantic schemas
│ ├── utils/ # Utility functions
│ └── main.py # FastAPI application entry point
├── alembic/ # Database migrations
├── requirements.txt # Python dependencies
└── README.md # This file
POST /register/patient- Patient registrationPOST /register/doctor- Doctor registrationPOST /register/nurse- Nurse registrationPOST /login/patient- Patient loginPOST /login/doctor- Doctor loginPOST /login/nurse- Nurse login
GET /patient/doctors- List available doctorsGET /patient/available-slots/{doctor_name}- Get doctor's available slotsPOST /patient/book-appointment- Book an appointmentGET /patient/appointments- View patient appointmentsGET /patient/prescription/report/{prescription_id}- Download prescription PDF
GET /doctor/profile/{doctor_name}- Get doctor profilePUT /doctor/profile/{name}- Update doctor profilePOST /doctor/schedule/{doctor_name}- Set doctor scheduleGET /doctor/schedule/{doctor_name}- View doctor scheduleGET /doctor/appointments/{doctor_name}- View doctor appointmentsPUT /doctor/appointment/{appointment_id}- Update appointmentPOST /doctor/generate-prescription/{doctor_name}- Generate prescriptionPOST /doctor/upload-medical-report/{doctor_name}- Upload medical reports
GET /nurse/profile/{nurse_name}- Get nurse profileGET /nurse/appointments- View all appointmentsGET /nurse/appointments/{appointment_id}- View specific appointmentPUT /nurse/appointments/reassign- Reassign appointments
POST /AI_doctor/prescribe- AI prescription generationPOST /AI_doctor/check-symptoms- Symptom analysisPOST /AI_doctor/generate-prescription- Enhanced prescription generationPOST /AI_doctor/upload-report- Process medical reports
uvicorn app.main:app --reload# Create new migration
alembic revision --autogenerate -m "Description"
# Apply migrations
alembic upgrade head
# Rollback migration
alembic downgrade -1MIT License - see LICENSE file for details.