Skip to content

mohamed68909/ClinicManagementAPI

Repository files navigation

๐Ÿฅ Clinic Management System API

A production-ready RESTful Web API built using ASP.NET Core (.NET 9) and Entity Framework Core to manage clinic operations securely and efficiently.

This system provides a complete backend solution for managing patients, doctors, appointments, invoices, payments, and hospital stays โ€” with strong security and clean architecture principles.


๐Ÿš€ Core Features

๐Ÿฅ Clinic Management

  • Manage doctors, patients, and hospital stays
  • Full appointment management (CRUD)
  • โญ Doctor reviews and ratings
  • ๐Ÿ”Ž Pagination & filtering support

๐Ÿ“… Online Appointment Booking (Patient Feature)

  • Patients can book appointments online
  • JWT-protected booking endpoint
  • Ownership-based access validation
  • Patients can only access their own appointments

๐Ÿ’ฐ Financial System

  • Invoice creation and management
  • Secure payment processing
  • PDF invoice export
  • Ownership-based invoice protection

๐Ÿ” Authentication & Authorization

  • JWT Authentication
  • ASP.NET Identity integration
  • Role-Based Authorization (Admin / Patient)
  • Resource-Level Ownership validation
  • Secure Swagger integration (JWT enabled)

๐Ÿ—๏ธ Architecture & Design

This project follows a clean layered architecture:

Controllers โ†’ Services โ†’ Data โ†’ Entities

Key Design Patterns Used

  • Service Layer Pattern
  • DTOs (Data Transfer Objects)
  • Result wrapper for consistent API responses
  • Fluent API for entity configuration
  • Centralized authorization helper
  • Dependency Injection

๐Ÿงฐ Technologies Used

Category Technology
Language C# (.NET 9)
Framework ASP.NET Core Web API
ORM Entity Framework Core
Database SQL Server
Authentication ASP.NET Identity + JWT
Authorization Role-Based + Ownership
Object Mapping Mapster
Documentation Swagger
Architecture Clean Layered Architecture

๐Ÿ”’ Authentication Flow

1๏ธโƒฃ Register or log in:

POST /api/Auth/sign-up
POST /api/Auth/sign-in

2๏ธโƒฃ Receive a JWT token in the response.

3๏ธโƒฃ Use the token in secured endpoints:

Authorization: Bearer {your_token}

4๏ธโƒฃ Access control supports:

  • Role-based restrictions (Admin / Patient)
  • Ownership validation (users can only access their own resources)

๐Ÿ“… Online Booking Flow (Patient)

Patients can book appointments directly via the API.

Booking Process:

  1. Patient logs in and receives JWT.
  2. Patient calls the booking endpoint:
POST /api/appointments/patient/{patientId}/book
  1. System validates:

    • User is authenticated
    • User role is Patient
    • The patientId belongs to the logged-in user
  2. Appointment is created securely.


๐Ÿ“ฆ Example Endpoints

Method Endpoint Description
GET /api/appointments?page=1&pageSize=10 Get paginated appointments
POST /api/appointments Create appointment (Admin)
POST /api/appointments/patient/{patientId}/book Patient books appointment
GET /api/patients/{id} Get patient details
GET /api/invoices/{id}/pdf Export invoice as PDF
POST /api/payments/{appointmentId} Create payment
GET /api/doctors List doctors

โš™๏ธ How to Run Locally

Prerequisites

  • .NET 9 SDK
  • SQL Server
  • EF Core CLI tools

Steps

git clone https://github.com/mohamed68909/ClinicManagement.git
cd ClinicManagement/ClinicManagement.API
dotnet ef database update
dotnet run

Open in browser:

https://localhost:{port}/swagger

๐Ÿ“ธ API Preview

๐Ÿ” Swagger UI (JWT Enabled)

Swagger UI

๐Ÿ“… Appointments Module

Appointments

๐Ÿ‘จโ€โš•๏ธ Doctors & Reviews

Doctors

๐Ÿงพ Invoices & Payments

Invoices

๐Ÿฅ Patients & Stays

Patients


๐Ÿง  What This Project Demonstrates

  • Secure backend API development
  • JWT-based authentication pipeline
  • Role-based & ownership-based authorization
  • Clean service-based architecture
  • Pagination & filtering implementation
  • Real-world backend system design

๐Ÿ”ฎ Future Improvements

  • Unit & Integration Testing (xUnit + Moq)
  • Structured logging with Serilog
  • CI/CD pipeline setup
  • Cloud deployment (Azure App Service)
  • Frontend integration (React or Angular)
  • Role expansion (Doctor / Receptionist)

๐Ÿ‘จโ€๐Ÿ’ป Author

Mohamed Ashraf .NET Backend Developer

GitHub: https://github.com/mohamed68909


๐Ÿ“œ License

MIT License Developed for educational and portfolio purposes.


About

RESTful API for clinic management - patients, doctors and appointments | ASP.NET Core + EF Core + SQL Server

Topics

Resources

License

Contributing

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors