A modern healthcare management system built with Clean Architecture, .NET 10, and MongoDB.
- Clean Architecture - Domain-driven design with clear separation of concerns
- MongoDB Integration - Code-first approach with MongoDB as the database
- JWT Authentication - Role-based authorization (Doctor, HospitalEmployee, Admin)
- Scalar API Documentation - Modern, interactive API documentation
- Serilog Logging - Structured logging to MongoDB with request tracking
HospitalCare/
├── HospitalCare.Domain/ # Core domain entities and interfaces
│ ├── Entities/ # Patient, Doctor, Appointment, User
│ ├── Interfaces/ # Repository interfaces
│ └── Events/ # Domain events
├── HospitalCare.Application/ # Business logic and DTOs
│ ├── DTOs/ # Data transfer objects
│ ├── Interfaces/ # Service interfaces
│ └── Services/ # Application services
├── HospitalCare.Infrastructure/ # Data access and external services
│ ├── Data/ # MongoDB context, migrations, seeding
│ ├── Repositories/ # MongoDB repositories
│ └── Services/ # JWT service
├── HospitalCare.Api/ # REST API with controllers
│ └── Controllers/ # API endpoints
└── HospitalCare.Migrations/ # Database migration tool
| Role |
Permissions |
| Admin |
Full access: manage doctors, patients, appointments, users |
| HospitalEmployee |
Manage patients, create/reschedule appointments, register users |
| Doctor |
View patients, appointments, doctors; complete appointments |
- .NET 10 SDK
- MongoDB (local or Atlas)
Update appsettings.json:
{
"MongoDB": {
"ConnectionString": "mongodb://localhost:27017",
"DatabaseName": "HospitalCareDb"
},
"Jwt": {
"SecretKey": "Your-Secret-Key-Here",
"Issuer": "HospitalCare",
"Audience": "HospitalCareApi",
"ExpirationMinutes": 60
}
}
cd HospitalCare.Migrations
dotnet run
cd HospitalCare
dotnet run --project HospitalCare.Api
| Method |
Endpoint |
Description |
| POST |
/api/auth/login |
Login and get JWT token |
| POST |
/api/auth/register |
Register new user (auth required) |
| GET |
/api/auth/me |
Get current user info |
| POST |
/api/auth/change-password |
Change password |
| Method |
Endpoint |
Description |
Roles |
| GET |
/api/patients |
Get all patients |
Doctor, HospitalEmployee, Admin |
| GET |
/api/patients/{id} |
Get patient by ID |
Doctor, HospitalEmployee, Admin |
| GET |
/api/patients/search?name= |
Search patients by name |
Doctor, HospitalEmployee, Admin |
| POST |
/api/patients |
Create patient |
HospitalEmployee, Admin |
| PUT |
/api/patients/{id} |
Update patient |
HospitalEmployee, Admin |
| DELETE |
/api/patients/{id} |
Delete patient |
Admin |
| Method |
Endpoint |
Description |
Roles |
| GET |
/api/doctors |
Get all doctors |
Doctor, HospitalEmployee, Admin |
| GET |
/api/doctors/{id} |
Get doctor by ID |
Doctor, HospitalEmployee, Admin |
| GET |
/api/doctors/specialization/{spec} |
Get doctors by specialization |
Doctor, HospitalEmployee, Admin |
| POST |
/api/doctors |
Create doctor |
Admin |
| DELETE |
/api/doctors/{id} |
Delete doctor |
Admin |
| Method |
Endpoint |
Description |
Roles |
| GET |
/api/appointments |
Get all appointments |
Doctor, HospitalEmployee, Admin |
| GET |
/api/appointments/{id} |
Get appointment by ID |
Doctor, HospitalEmployee, Admin |
| GET |
/api/appointments/patient/{id} |
Get patient appointments |
Doctor, HospitalEmployee, Admin |
| GET |
/api/appointments/doctor/{id} |
Get doctor appointments |
Doctor, HospitalEmployee, Admin |
| POST |
/api/appointments |
Create appointment |
HospitalEmployee, Admin |
| PUT |
/api/appointments/{id}/cancel |
Cancel appointment |
Doctor, HospitalEmployee, Admin |
| PUT |
/api/appointments/{id}/complete |
Complete appointment |
Doctor, Admin |
| PUT |
/api/appointments/{id}/reschedule |
Reschedule appointment |
HospitalEmployee, Admin |
All API requests are logged to MongoDB with:
- Timestamp
- HTTP method and path
- Response status code
- Response time
- User ID and email
- Environment and machine name
Query logs:
db.logs.find().sort({ _id: -1 }).limit(10)
- .NET 10 - Web API framework
- MongoDB - NoSQL database
- Serilog - Structured logging
- JWT Bearer - Authentication
- Scalar - API documentation
- Clean Architecture - Architectural pattern
This project is licensed under the MIT License - see the LICENSE file for details.