Skip to content

Repository files navigation

Leave Management System

A production-style Microservices-based Leave Management System developed using Java, Spring Boot, Spring Cloud, Docker, MySQL, and JWT Authentication.

The application enables employees to apply for leave, managers to approve or reject leave requests, and automatically updates employee leave balances after approval. The project follows modern microservices architecture using Spring Cloud components such as Config Server, Eureka Service Discovery, API Gateway, and OpenFeign.

This project was built to demonstrate enterprise-level backend development practices including distributed architecture, centralized configuration, service discovery, secure authentication, inter-service communication, Docker deployment, and clean layered architecture.


Table of Contents

  • Overview
  • Features
  • Architecture
  • Microservices
  • Technology Stack
  • Project Structure
  • System Workflow
  • Getting Started
  • Prerequisites
  • Installation
  • Configuration
  • Running the Project
  • API Endpoints
  • Authentication
  • Docker Support
  • Future Enhancements
  • Screenshots
  • Author

Overview

The Leave Management System is designed to simplify employee leave management by automating the complete leave approval workflow.

Employees can:

  • Login securely
  • Apply for leave
  • View leave history
  • Track leave status

Managers can:

  • View pending leave requests
  • Approve or reject leave requests
  • Automatically deduct employee leave balance after approval

The application follows a distributed microservices architecture where each service has a single responsibility.


Features

Authentication

  • JWT Authentication
  • Role-based Authorization
  • Secure Login
  • Password Encryption

Employee Management

  • Employee Registration
  • Employee Login
  • Employee Details
  • Leave Balance Management

Leave Management

  • Apply Leave
  • View Leave Requests
  • Leave Approval
  • Leave Rejection
  • Automatic Leave Balance Deduction

Architecture Features

  • Spring Boot Microservices
  • API Gateway
  • Eureka Service Discovery
  • Spring Cloud Config Server
  • OpenFeign Communication
  • Global Exception Handling
  • Validation
  • Centralized Configuration
  • Dockerized Deployment

Architecture

                      Client
                         |
                         |
                  API Gateway
                         |
     ----------------------------------------
     |          |            |             |
 Auth Service Employee Service Leave Service Notification Service
                    |
                MySQL Database

               Eureka Server
                    ^
                    |
          All Services Registered

              Config Server
                    ^
                    |
       Configuration for all Services

Microservices

API Gateway

Responsibilities

  • Single Entry Point
  • Routing Requests
  • JWT Validation
  • Security

Config Server

Responsibilities

  • Centralized Configuration
  • Environment-based Properties

Eureka Server

Responsibilities

  • Service Discovery
  • Dynamic Registration

Auth Service

Responsibilities

  • User Authentication
  • JWT Token Generation
  • Login Validation

Employee Service

Responsibilities

  • Employee CRUD
  • Leave Balance
  • Employee Information

Leave Service

Responsibilities

  • Apply Leave
  • Approve Leave
  • Reject Leave
  • Leave Status
  • Business Logic

Notification Service

Responsibilities

  • Notification APIs
  • Email (Future Scope)

Technology Stack

Backend

  • Java 21
  • Spring Boot 3
  • Spring Security
  • Spring Data JPA
  • Spring Validation

Spring Cloud

  • Eureka Server
  • Spring Cloud Gateway
  • Spring Cloud Config
  • OpenFeign

Database

  • MySQL

Authentication

  • JWT

Build Tool

  • Maven

Containerization

  • Docker
  • Docker Compose

Documentation

  • Swagger/OpenAPI

Project Structure

leave-management-system

│
├── api-gateway
├── auth-service
├── config-server
├── eureka-server
├── employee-service
├── leave-service
├── notification-service
├── common-library
├── docker-compose.yml
├── pom.xml
└── README.md

System Workflow

Employee Login

Employee

API Gateway

Auth Service

JWT Token Generated

Token Returned


Apply Leave

Employee

API Gateway

Leave Service

Leave Request Saved

Pending Manager Approval


Approve Leave

Manager

API Gateway

Leave Service

Employee Service

Leave Balance Updated

Leave Status = APPROVED


Prerequisites

Before running the project, ensure the following software is installed:

  • Java 21
  • Maven 3.9+
  • Docker
  • Docker Compose
  • MySQL
  • Git

Getting Started

Clone Repository

git clone https://github.com/yourusername/leave-management-system.git

cd leave-management-system

Build Project

mvn clean install

Run Services

Run in the following order:

  1. Config Server

  2. Eureka Server

  3. Auth Service

  4. Employee Service

  5. Leave Service

  6. Notification Service

  7. API Gateway


Configuration

Update your application-local.yml or application.yml with your database credentials.

Example:

spring:
  datasource:
    url: jdbc:mysql://localhost:3306/leave_management
    username: root
    password: password

Running with Docker

Build Docker Images

docker compose build

Run Containers

docker compose up

Stop Containers

docker compose down

Authentication

The application uses JWT Authentication.

Typical Flow

  1. Login

  2. Receive JWT Token

  3. Add JWT Token in Authorization Header

Authorization: Bearer <JWT_TOKEN>

Sample API Endpoints

Authentication

POST /api/auth/login
POST /api/auth/register

Employee

GET /api/employees

GET /api/employees/{id}

POST /api/employees

Leave

POST /api/leaves

GET /api/leaves

PUT /api/leaves/{id}/approve

PUT /api/leaves/{id}/reject

Error Handling

The project includes centralized exception handling for:

  • Resource Not Found
  • Validation Errors
  • Unauthorized Access
  • Business Exceptions
  • Internal Server Errors

Security

  • Spring Security
  • JWT Authentication
  • Password Encryption
  • Protected APIs
  • Role-Based Access

Testing

You can run all unit tests using:

mvn test

Future Enhancements

  • Email Notifications
  • Leave Cancellation
  • Holiday Calendar
  • Manager Dashboard
  • Admin Dashboard
  • File Attachments
  • Audit Logging
  • Kafka Event Messaging
  • Redis Caching
  • Kubernetes Deployment
  • CI/CD Pipeline
  • Monitoring using Prometheus & Grafana

Screenshots

Add screenshots here.

Example:

docs/images/login.png

docs/images/dashboard.png

docs/images/swagger.png

Learning Outcomes

This project demonstrates practical experience with:

  • Java
  • Spring Boot
  • Spring Security
  • Spring Cloud
  • Microservices
  • REST APIs
  • OpenFeign
  • JWT
  • MySQL
  • Docker
  • Maven
  • Exception Handling
  • Layered Architecture
  • Distributed Systems
  • Service Discovery
  • API Gateway
  • Config Server

Author

Akshat Bhawsar

Java Backend Developer

If you found this project helpful, consider giving it a ⭐ on GitHub.

About

Production-grade Leave Management System built using Java, Spring Boot, Spring Cloud, JWT, Docker, MySQL, and Microservices architecture with API Gateway, Service Discovery, and centralized configuration and Messaging with Rabbit MQ.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages