Skip to content

Repository files navigation

🏥 Clinic Management System – Backend API

A production-ready Spring Boot RESTful API for managing a clinic system. This project demonstrates clean architecture, secure authentication, and scalable backend design using modern Java technologies.


🚀 Overview

The Clinic Management System provides backend services for:

  • 👨‍⚕️ Doctor management
  • 🧑‍🤝‍🧑 Patient management
  • 📅 Appointment scheduling
  • 🔐 Authentication & authorization
  • 📊 Data persistence with relational database
  • 🧪 Unit & integration testing

This project follows best practices for layered architecture and REST API design.


🏗️ Architecture

The project follows a layered architecture:

Controller → Service → Repository → Database

Layers

  • Controller Layer

    • Handles HTTP requests
    • Input validation
    • API responses
  • Service Layer

    • Business logic
    • Transaction management
    • Domain rules enforcement
  • Repository Layer

    • Database interaction using JPA
    • Query abstraction
  • Entity Layer

    • Database models
    • ORM mapping

🛠️ Tech Stack

Backend

  • Java 17+
  • Spring Boot
  • Spring Web
  • Spring Data JPA
  • Spring Security
  • Hibernate

Database

  • PostgreSQL / MySQL (configurable)
  • H2 (for development/testing)

Security

  • JWT Authentication
  • Role-Based Authorization
  • Password Encryption (BCrypt)

Testing

  • JUnit 5
  • Mockito
  • Spring Boot Test

DevOps

  • Docker
  • Docker Compose

🔐 Authentication & Authorization

The system uses:

  • JWT-based authentication
  • Stateless session management
  • Role-based access control (e.g., ADMIN, DOCTOR, PATIENT)

Typical flow:

  1. User logs in
  2. Server returns JWT token
  3. Client includes token in Authorization header
  4. Backend validates token for secured endpoints

📂 Project Structure

src/main/java/
│
├── controller/
├── service/
├── repository/
├── entity/
├── dto/
├── exception/
├── security/
└── config/

📌 Main Features

👨‍⚕️ Doctor Management

  • Create doctor
  • Update doctor
  • Delete doctor
  • View doctor details

🧑 Patient Management

  • Register patient
  • Update patient data
  • View patient records

📅 Appointment System

  • Create appointment
  • Prevent scheduling conflicts
  • List appointments by doctor or patient

⚠️ Global Exception Handling

  • Custom exceptions
  • Meaningful API error responses
  • Centralized error management

📊 API Design

  • RESTful endpoints
  • Proper HTTP status codes
  • DTO usage (no entity exposure)
  • Validation annotations
  • Pagination & sorting support (if implemented)

Example:

GET     /api/doctors
POST    /api/patients
PUT     /api/appointments/{id}
DELETE  /api/doctors/{id}

🧪 Testing

Includes:

  • Unit tests for service layer
  • Mocking dependencies using Mockito
  • Integration testing for API endpoints

To run tests:

mvn test

🐳 Running with Docker

Build the project:

mvn clean package

Build Docker image:

docker build -t clinic-app .

Run container:

docker run -p 8080:8080 clinic-app

Or use Docker Compose:

docker-compose up

⚙️ Configuration

Application configuration is managed in:

application.yml

You can configure:

  • Database URL
  • Username & password
  • JWT secret
  • Server port
  • Logging level

🔄 Future Improvements

  • Swagger / OpenAPI documentation
  • Advanced filtering & search
  • Caching with Redis
  • Audit logging
  • CI/CD pipeline
  • Kubernetes deployment

📈 Learning Objectives Demonstrated

This project demonstrates:

  • Clean backend architecture
  • Secure REST API development
  • Database modeling & relationships
  • Proper exception handling
  • Real-world backend structure
  • Production-ready configuration mindset

👨‍💻 Author

Ali Al-Jalo

Java Backend Developer


About

Spring Boot REST API for management clinic operations including patients, appointments, and role-based authentication suing JWT. Dockerized with MySQL and documented using Swagger

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages