Skip to content

Case Study - Work Permission (Java 21, Spring Boot, MySQL, JUnit, AOP, Jacoco, Prometheus,Grafana, Docker, Kubernetes, Github Action (CI/CD))

Notifications You must be signed in to change notification settings

Rapter1990/workpermission

Repository files navigation

Case Study - Work Permission

Main Information

📖 Information

  • Annual Paid Leave Policy:
    • To be eligible for annual paid leave, an employee must have worked at least one year in our company. Each year, employees earn leave days based on their length of service, as shown in the table below:

      Length of Service Annual Leave (Business Days/Year)
      From 1 year up to (and including) 5 years 15
      More than 5 years up to (and including) 10 years 18
      More than 10 years 24
    • Weekends (Saturday, Sunday) and official holidays do not count towards leave days.
    • New hires can use up to 5 business days as advanced leave during their first year. This applies only to the first year of employment.
    • When a future-dated leave request is submitted, the requested days are deducted from the employee’s available leave balance.
    • Employees cannot request more leave than their remaining leave balance.
    • When a leave request is created, it is initially in the “Pending Approval” status. After managerial review, it is either “Approved” or “Rejected.”

Explore Rest APIs

Endpoints Summary

Method Url Description Request Body Path Variable Response
POST /api/v1/authentication/user/register Register for Admin or User RegisterRequest CustomResponse<Void>
POST /api/v1/authentication/user/login Login for Admin or User LoginRequest CustomResponse<TokenResponse>
POST /api/v1/authentication/user/refresh-token Refresh Token for Admin or User TokenRefreshRequest CustomResponse<TokenResponse>
POST /api/v1/authentication/user/logout Logout for Admin or User TokenInvalidateRequest CustomResponse<Void>
POST /api/v1/leaverequests Create a new leave request CreateLeaveRequest - CustomResponse<LeaveRequestResponse>
GET /api/v1/leaverequests/{id} Retrieve leave request by ID - id (UUID) CustomResponse<LeaveRequestResponse>
GET /api/v1/leaverequests/users/{userId} Retrieve paginated leave requests for a user LeaveRequestPagingRequest userId CustomResponse<CustomPagingResponse<LeaveRequestResponse>>
PATCH /api/v1/leaverequests/{leaveRequestId}/status Update the status of a leave request Query Parameter: status (LeaveStatus) leaveRequestId CustomResponse<LeaveRequestResponse>
GET /api/v1/leaverequests/remaining/{userId} Retrieve remaining leave days for a user - userId (UUID) CustomResponse<Long>

Technologies


  • Java 21
  • Spring Boot 3.0
  • Restful API
  • Open Api (Swagger)
  • Maven
  • Junit5
  • Mockito
  • Integration Tests
  • Docker
  • Docker Compose
  • CI/CD (Github Actions)
  • Postman
  • Prometheus
  • Grafana
  • Kubernetes
  • JaCoCo (Test Report)

Postman

Import postman collection under postman_collection folder

Prerequisites

Define Variable in .env file

WORK_PERMISSION_DB_IP=localhost
WORK_PERMISSION_DB_PORT=3306
DATABASE_USERNAME={MY_SQL_DATABASE_USERNAME}
DATABASE_PASSWORD={MY_SQL_DATABASE_PASSWORD}

Open Api (Swagger)

http://localhost:2552/swagger-ui/index.html

JaCoCo (Test Report)

After the command named mvn clean install completes, the JaCoCo report will be available at:

target/site/jacoco/index.html

Navigate to the target/site/jacoco/ directory.

Open the index.html file in your browser to view the detailed coverage report.


Maven, Docker and Kubernetes Running Process

Maven Run

To build and run the application with Maven, please follow the directions shown below;

$ cd pdfcompare
$ mvn clean install
$ mvn spring-boot:run

Docker Run

The application can be built and run by the Docker engine. The Dockerfile has multistage build, so you do not need to build and run separately.

Please follow directions shown below in order to build and run the application with Docker Compose file;

$ cd pdfcompare
$ docker-compose up -d

If you change anything in the project and run it on Docker, you can also use this command shown below

$ cd pdfcompare
$ docker-compose up --build

To monitor the application, you can use the following tools:

  • Prometheus:
    Open in your browser at http://localhost:9090
    Prometheus collects and stores application metrics.

  • Grafana:
    Open in your browser at http://localhost:3000
    Grafana provides a dashboard for visualizing the metrics.
    Default credentials:

    • Username: admin
    • Password: admin
  • Define prometheus data source url, use this link shown below

http://prometheus:9090

Kubernetes Run

To build and run the application with Maven, please follow the directions shown below;

  • Start Minikube
$ minikube start
  • Open Minikube Dashboard
$ minikube dashboard
  • To deploy the application on Kubernetes, apply the Kubernetes configuration file underneath k8s folder
$ kubectl apply -f k8s
  • To open Prometheus, click tunnel url link provided by the command shown below to reach out Prometheus
minikube service prometheus-service
  • To open Grafana, click tunnel url link provided by the command shown below to reach out Prometheus
minikube service grafana-service
  • Define prometheus data source url, use this link shown below
http://prometheus-service.default.svc.cluster.local:9090

Docker Image Location

https://hub.docker.com/repository/docker/noyandocker/workpermission/general

Screenshots

Click here to show the screenshots of project

Figure 1

Figure 2

Figure 3

Figure 4

Figure 5

Figure 6

Figure 7

Figure 8

Figure 9

Figure 10

Figure 11

Figure 12

Figure 13

Figure 14

Figure 15

Figure 16

Figure 17

Figure 18

Figure 19

Figure 20

Contributors

About

Case Study - Work Permission (Java 21, Spring Boot, MySQL, JUnit, AOP, Jacoco, Prometheus,Grafana, Docker, Kubernetes, Github Action (CI/CD))

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published