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 EmployeePayrollSystem2. Create the database
CREATE DATABASE payrolldb;3. Configure credentials
Copy the example file:
cp src/main/resources/application.properties.example src/main/resources/application.propertiesSet 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_hereMac/Linux:
export DB_USERNAME=postgres
export DB_PASSWORD=yourpassword
export GROQ_API_KEY=gsk_your_key_here4. Run the application
mvn spring-boot:runApp 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
- Start the application
- Open
http://localhost:8080/swagger-ui.htmlin your browser - Click on any endpoint to expand it
- Click "Try it out"
- Fill in the request body or parameters
- 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
Using Swagger UI (Recommended)
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/employeesGet employee by ID:
curl -X GET http://localhost:8080/api/employees/1Get employee salary:
curl -X GET http://localhost:8080/api/employees/1/salaryOnboard 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/1Recommended Testing Order
POST /onboardโ create an employee, note theidin responseGET /api/employeesโ confirm employee is listedGET /api/employees/{id}โ fetch by idGET /api/employees/{id}/salaryโ check salary calculationPUT /api/employees/{id}โ update detailsDELETE /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.propertieswith real credentials - Always use environment variables for secrets
application.propertiesis listed in.gitignore- Use
application.properties.exampleas a safe template