GitHunt
VI

vikas9013/EmployeePayrollSystem

Production-ready Spring Boot REST API for Employee Payroll Management with JWT Security, Redis Caching, Flyway Migrations, Soft Delete, Rate Limiting, Structured Logging, and an AI-Powered Onboarding Pipeline using Groq (LLaMA 3.3-70b).

๐Ÿงพ Employee Payroll System

A Spring Boot REST API that manages employee payroll for both full-time and part-time employees โ€” with a fully Automated AI-Powered Onboarding Pipeline that creates a work email, sends a Slack invite, assigns training modules, configures payroll, and generates a personalized AI welcome message using Groq (LLaMA 3.3) whenever a new employee is hired.


๐Ÿš€ Tech Stack

Technology Details
Java 21
Spring Boot 3.3.4
Spring Data JPA Hibernate ORM
PostgreSQL Relational Database
Spring WebFlux WebClient for AI API calls
Spring Validation Request body validation
Groq API Free AI โ€” LLaMA 3.3 70B
SpringDoc OpenAPI Swagger UI Documentation
Maven Build tool

๐Ÿง  OOP Concepts Demonstrated

Concept How It's Used
Abstraction Employee is an abstract class with abstract calculateSalary() method
Inheritance FullTimeEmployee and PartTimeEmployee extend Employee
Polymorphism Each subclass overrides calculateSalary() with its own logic
Encapsulation All fields are private with public getters/setters

๐Ÿ“ Project Structure

src/
โ””โ”€โ”€ main/java/com/vikas/
    โ”œโ”€โ”€ PayrollApplication.java
    โ”œโ”€โ”€ config/
    โ”‚   โ””โ”€โ”€ SwaggerConfig.java               # Swagger UI configuration
    โ”œโ”€โ”€ controller/
    โ”‚   โ””โ”€โ”€ EmployeeController.java
    โ”œโ”€โ”€ service/
    โ”‚   โ”œโ”€โ”€ EmployeeService.java
    โ”‚   โ”œโ”€โ”€ OnboardingService.java
    โ”‚   โ”œโ”€โ”€ AIOnboardingService.java         # AI message via Groq
    โ”‚   โ”œโ”€โ”€ EmailService.java
    โ”‚   โ”œโ”€โ”€ SlackService.java
    โ”‚   โ”œโ”€โ”€ TrainingService.java
    โ”‚   โ””โ”€โ”€ PayrollSetupService.java
    โ”œโ”€โ”€ entity/
    โ”‚   โ”œโ”€โ”€ Employee.java
    โ”‚   โ”œโ”€โ”€ FullTimeEmployee.java
    โ”‚   โ””โ”€โ”€ PartTimeEmployee.java
    โ”œโ”€โ”€ repository/
    โ”‚   โ””โ”€โ”€ EmployeeRepository.java
    โ”œโ”€โ”€ dto/
    โ”‚   โ”œโ”€โ”€ EmployeeRequestDTO.java
    โ”‚   โ”œโ”€โ”€ EmployeeResponseDTO.java
    โ”‚   โ”œโ”€โ”€ SalaryResponseDTO.java
    โ”‚   โ””โ”€โ”€ OnboardingResponseDTO.java
    โ”œโ”€โ”€ enums/
    โ”‚   โ””โ”€โ”€ EmployeeType.java
    โ””โ”€โ”€ ExceptionHandler/
        โ”œโ”€โ”€ GlobalExceptionHandler.java
        โ””โ”€โ”€ OnboardingException.java

โš™๏ธ Setup & Configuration

Prerequisites

  • Java 21+
  • Maven
  • PostgreSQL running locally
  • Groq API Key โ€” free at console.groq.com

1. Clone the repository

git clone https://github.com/vikas9013/EmployeePayrollSystem.git
cd EmployeePayrollSystem

2. Create the database

CREATE DATABASE payrolldb;

3. Configure credentials

Copy the example file:

cp src/main/resources/application.properties.example src/main/resources/application.properties

Set these environment variables:

Variable Description
DB_USERNAME Your PostgreSQL username
DB_PASSWORD Your PostgreSQL password
GROQ_API_KEY Your Groq API key from console.groq.com

Windows CMD:

set DB_USERNAME=postgres
set DB_PASSWORD=yourpassword
set GROQ_API_KEY=gsk_your_key_here

Mac/Linux:

export DB_USERNAME=postgres
export DB_PASSWORD=yourpassword
export GROQ_API_KEY=gsk_your_key_here

4. Run the application

mvn spring-boot:run

App starts at: http://localhost:8080


๐Ÿ“– Swagger UI โ€” API Documentation

This project includes Swagger UI powered by SpringDoc OpenAPI for interactive API documentation and testing.

URL Description
http://localhost:8080/swagger-ui.html Interactive Swagger UI
http://localhost:8080/v3/api-docs Raw OpenAPI JSON spec

How to use Swagger UI

  1. Start the application
  2. Open http://localhost:8080/swagger-ui.html in your browser
  3. Click on any endpoint to expand it
  4. Click "Try it out"
  5. Fill in the request body or parameters
  6. Click "Execute" to test the API live

๐Ÿ“ก API Endpoints

Method Endpoint Description
GET /api/employees Get all employees
GET /api/employees/{id} Get employee by ID
GET /api/employees/{id}/salary Get salary of an employee
POST /api/employees/onboard Add employee + run full onboarding pipeline
PUT /api/employees/{id} Update an employee
DELETE /api/employees/{id} Remove an employee

๐Ÿ“ Sample Requests

Onboard a Full-Time Employee

POST /api/employees/onboard
{
  "name": "Vikas Singh Rawat",
  "designation": "Software Engineer",
  "type": "FULLTIME",
  "monthlySalary": 85000,
  "hoursWorked": 0,
  "hourlyRate": 0
}

Onboard a Part-Time Employee

POST /api/employees/onboard
{
  "name": "Rahul Mehta",
  "designation": "Intern",
  "type": "PARTTIME",
  "monthlySalary": 0,
  "hoursWorked": 40,
  "hourlyRate": 200
}

Success Response

{
  "employeeId": 1,
  "employeeName": "Vikas Singh Rawat",
  "workEmail": "vikas.singh.rawat@company.com",
  "slackInviteSent": true,
  "trainingAssigned": true,
  "payrollConfigured": true,
  "message": "Onboarding completed successfully for Vikas Singh Rawat",
  "aiOnboardingMessage": "Welcome aboard, Vikas! We are thrilled to have you join our Engineering team."
}

๐Ÿงช Testing the API

Open http://localhost:8080/swagger-ui.html and use the Try it out button on any endpoint.

Using curl โ€” Windows CMD

Get all employees:

curl -X GET http://localhost:8080/api/employees

Get employee by ID:

curl -X GET http://localhost:8080/api/employees/1

Get employee salary:

curl -X GET http://localhost:8080/api/employees/1/salary

Onboard Full-Time Employee:

curl -X POST http://localhost:8080/api/employees/onboard -H "Content-Type: application/json" -d "{\"name\": \"Vikas\", \"designation\": \"Software Engineer\", \"type\": \"FULLTIME\", \"monthlySalary\": 85000, \"hoursWorked\": 0, \"hourlyRate\": 0}"

Onboard Part-Time Employee:

curl -X POST http://localhost:8080/api/employees/onboard -H "Content-Type: application/json" -d "{\"name\": \"Rahul\", \"designation\": \"Intern\", \"type\": \"PARTTIME\", \"monthlySalary\": 0, \"hoursWorked\": 40, \"hourlyRate\": 200}"

Update Employee:

curl -X PUT http://localhost:8080/api/employees/1 -H "Content-Type: application/json" -d "{\"name\": \"Vikas Updated\", \"designation\": \"Senior Engineer\", \"type\": \"FULLTIME\", \"monthlySalary\": 95000, \"hoursWorked\": 0, \"hourlyRate\": 0}"

Delete Employee:

curl -X DELETE http://localhost:8080/api/employees/1
  1. POST /onboard โ†’ create an employee, note the id in response
  2. GET /api/employees โ†’ confirm employee is listed
  3. GET /api/employees/{id} โ†’ fetch by id
  4. GET /api/employees/{id}/salary โ†’ check salary calculation
  5. PUT /api/employees/{id} โ†’ update details
  6. DELETE /api/employees/{id} โ†’ remove employee

๐Ÿค– AI-Powered Onboarding Pipeline

When POST /api/employees/onboard is called, 5 steps run automatically:

New Employee Saved to DB
        โ”‚
        โ–ผ
1. EmailService           โ†’ Creates work email (name@company.com)
        โ”‚
        โ–ผ
2. SlackService           โ†’ Sends Slack workspace invite
        โ”‚
        โ–ผ
3. TrainingService        โ†’ Assigns training modules by designation
        โ”‚
        โ–ผ
4. PayrollSetupService    โ†’ Configures payroll (FULLTIME or PARTTIME)
        โ”‚
        โ–ผ
5. AIOnboardingService    โ†’ Generates personalized welcome message via Groq AI
        โ”‚
        โ–ผ
   OnboardingResponseDTO returned โœ…

Training Modules by Designation

Designation Modules Assigned
Engineer / Developer / SDE Company Orientation, Secure Coding Practices, Git Workflow
Manager / Team Lead Company Orientation, Leadership Fundamentals, HR Policies
HR / Human Resources Company Orientation, Recruitment Basics, Compliance Training
Any other Company Orientation, Code of Conduct

๐Ÿ—„๏ธ Database Schema

Table Contents
employees Base data โ€” id, name, designation
fulltime_employees Monthly salary
parttime_employees Hours worked + hourly rate

๐Ÿ”’ Security Notes

  • Never commit application.properties with real credentials
  • Always use environment variables for secrets
  • application.properties is listed in .gitignore
  • Use application.properties.example as a safe template

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

Vikas Singh Rawat
GitHub ยท LinkedIn

vikas9013/EmployeePayrollSystem | GitHunt