Skip to content

aasyhadi/hris-api

Repository files navigation

HRIS API - Spring Boot

Backend REST API Human Resource Information System (HRIS) menggunakan Java Spring Boot, Spring Security JWT, MySQL, JPA/Hibernate, Swagger OpenAPI, Audit Log, dan Unit Testing.


Tech Stack

  • Java 21
  • Spring Boot 3.x
  • Spring Security
  • JWT Authentication
  • Spring Data JPA
  • MySQL 8
  • Swagger / OpenAPI
  • Lombok
  • JUnit 5
  • Mockito
  • Docker
  • Docker Compose

Features

Authentication & Authorization

  • User Registration
  • User Login
  • JWT Access Token
  • JWT Refresh Token
  • Role Based Access Control (RBAC)
  • Spring Security
  • Protected API Endpoints

Roles:

  • ADMIN
  • HR
  • EMPLOYEE

Department Management

  • Create Department
  • Get All Departments
  • Get Department By Id
  • Update Department
  • Delete Department

Position Management

  • Create Position
  • Get All Positions
  • Get Position By Id
  • Update Position
  • Delete Position

Employee Management

  • Create Employee
  • Get Employee By Id
  • Get All Employees
  • Update Employee
  • Delete Employee

Fields:

  • Employee Number
  • Full Name
  • Email
  • Phone
  • Hire Date
  • Salary
  • Status
  • Department
  • Position
  • Photo

Search & Pagination

Employee Search:

  • Keyword Search
  • Pagination
  • Sorting
  • Filtering

Example:

GET /api/employees/search?keyword=budi&page=0&size=10&sortBy=fullName&direction=asc


Employee Dashboard

Endpoint:

GET /api/dashboard

Response:

  • Total Employees
  • Active Employees
  • Resigned Employees
  • Total Departments
  • Total Positions
  • Total Activities

Profile Management

  • Get Current User Profile
  • Update Profile
  • Change Password
  • Update Role

Endpoints:

GET /api/users/me

PUT /api/users/profile

PUT /api/users/change-password

PUT /api/users/{id}/role


Employee Photo Upload

Upload employee photo:

POST /api/employees/{id}/photo

Validation:

  • JPG
  • PNG
  • Max 2 MB

Audit Log

Track all activities:

  • CREATE
  • UPDATE
  • DELETE

Stored Information:

  • Username
  • Action
  • Entity Name
  • Entity Id
  • Created At

Activity Log

Endpoints:

GET /api/activity-logs

GET /api/activity-logs/search

GET /api/activity-logs/filter

GET /api/activity-logs/date

GET /api/activity-logs/advanced

Features:

  • Pagination
  • Sorting
  • Keyword Search
  • Filter By Username
  • Filter By Action
  • Filter By Date Range

API Documentation

Swagger UI:

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

OpenAPI JSON:

http://localhost:8080/v3/api-docs


Project Structure

src/main/java/com/hris

├── config

├── controller

├── dto

├── entity

├── exception

├── repository

├── response

├── security

└── service


Running Locally

Clone Repository

git clone https://github.com/your-username/hris-api.git
cd hris-api

Configure Database

Create MySQL database:

CREATE DATABASE hris_db;

Update:

application.properties

spring.datasource.url=jdbc:mysql://localhost:3306/hris_db
spring.datasource.username=root
spring.datasource.password=your_password

Run Application

Using Maven Wrapper:

mvnw.cmd spring-boot:run

Or:

./mvnw spring-boot:run

Testing

Run all tests:

mvnw.cmd test

Current Tests:

  • DepartmentServiceTest
  • PositionServiceTest
  • EmployeeServiceTest
  • AuthServiceTest
  • DepartmentControllerTest
  • PositionControllerTest
  • EmployeeControllerTest

Docker

Build:

docker compose build

Run:

docker compose up

Swagger:

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


Security

Authentication:

POST /api/auth/login

Response:

{
  "accessToken": "...",
  "refreshToken": "...",
  "email": "admin@hris.com",
  "role": "ADMIN"
}

Use:

Authorization: Bearer <access_token>

Future Improvements

  • Soft Delete
  • Global Auditing
  • CreatedBy / UpdatedBy
  • Docker Registry
  • GitHub Actions CI/CD
  • Redis Cache
  • Email Notification
  • Multi Tenant Support
  • Kubernetes Deployment

Learning Outcomes

Project ini mencakup kompetensi:

  • Java Backend Development
  • Spring Boot REST API
  • Spring Security JWT
  • RBAC Authorization
  • File Upload
  • Swagger OpenAPI
  • JPA / Hibernate
  • Unit Testing
  • Controller Testing
  • Audit Logging
  • Docker Fundamentals

About

Backend REST API Human Resource Information System (HRIS) menggunakan Java Spring Boot, Spring Security JWT, MySQL, JPA/Hibernate, Swagger OpenAPI, Audit Log, dan Unit Testing.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors