A production-grade REST API built with ASP.NET Core 8 using Clean Architecture, JWT authentication, and Entity Framework Core.
- ASP.NET Core 8 Web API
- Entity Framework Core 8 + SQL Server
- JWT Authentication + Role-Based Authorization (Admin, Doctor, Patient)
- Clean Architecture (Domain, Application, Infrastructure, API layers)
- Repository Pattern + Dependency Injection
- xUnit + Moq (Unit Tests)
- Swagger / OpenAPI documentation
- Multi-role JWT authentication (Admin, Doctor, Patient)
- Appointment booking with double-booking prevention
- Appointment state machine (Requested → Confirmed → Completed/Cancelled)
- EF Core RowVersion concurrency token
- Audit logging for every status change
- Pagination on all list endpoints
- Global exception handling middleware
- Background Hosted Service for notifications
HospitalManagement/ ├── HospitalManagement.Domain/ ← Entities, Enums ├── HospitalManagement.Application/ ← Interfaces, DTOs, Services ├── HospitalManagement.Infrastructure/← DbContext, Repositories, EF Core └── HospitalManagement.API/ ← Controllers, Middleware, Program.cs
-
Clone the repository git clone https://github.com/meJoydev/HospitalManagement-API.git
-
Open HospitalManagement.sln in Visual Studio 2022
-
Update appsettings.json connection string if needed
-
Open Package Manager Console and run: Update-Database -StartupProject HospitalManagement.API
-
Press Ctrl+F5 to run
-
Swagger opens at http://localhost:5009
| Method | URL | Role | Description |
|---|---|---|---|
| POST | /api/auth/register | Public | Register as Admin/Doctor/Patient |
| POST | /api/auth/login | Public | Login and get JWT token |
| GET | /api/doctor | Any auth user | List all doctors |
| GET | /api/doctor/{id} | Any auth user | Get doctor details |
| GET | /api/doctor/{id}/schedule | Any auth user | Get doctor schedule |
| POST | /api/doctor/{id}/schedule | Admin | Add doctor schedule |
| GET | /api/patient | Admin | List all patients |
| GET | /api/patient/me | Patient | My profile |
| GET | /api/appointment | Admin | All appointments (paginated) |
| GET | /api/appointment/my | Patient | My appointments |
| GET | /api/appointment/doctor | Doctor | My patients' appointments |
| POST | /api/appointment | Patient | Book appointment |
| PUT | /api/appointment/{id}/status | Doctor/Admin | Update appointment status |