A comprehensive Spring Boot-based payroll management system designed to handle customer information, product orders, and payroll processing with enterprise-grade security and cloud integration.
- Overview
- Architecture
- Features
- Technologies Used
- Prerequisites
- Installation & Setup
- Running the Application
- API Endpoints
- GCP Integration
- Project Structure
- Configuration
- Contributing
- License
The Payroll Management System is a microservices-based application built with Spring Boot that provides a robust platform for managing employee/customer data, product catalogs, order processing, and payroll operations. The system integrates with Google Cloud Platform (GCP) for enhanced scalability, reliability, and cloud-native capabilities.
This application follows a layered architecture pattern:
- Web Layer (
webpackage): REST controllers handling HTTP requests - Service Layer (
servicepackage): Business logic and processing - Repository Layer (
repositorypackage): Data access using Spring Data JPA - Model Layer (
modelpackage): JPA entities representing domain objects - Config Layer (
configpackage): Security and application configuration
- Customer Management: Create, retrieve, and manage customer records
- Product Catalog: Maintain product information with pricing
- Order Processing: Handle order creation and tracking
- Security: Spring Security integration for authentication and authorization
- RESTful APIs: Comprehensive REST endpoints for all operations
- Cloud-Ready: GCP integration for production deployment
- Database Integration: JPA/Hibernate for seamless database operations
- Java 17+
- Spring Boot 3.x
- Spring Data JPA
- Spring Security
- Hibernate
- Lombok
- H2/PostgreSQL Database
- Maven
- Google Cloud Platform (GCP)
- Cloud SQL
- Cloud Run
- Cloud Storage
- Cloud Logging
Before running this application, ensure you have the following installed:
- Java Development Kit (JDK) 17 or higher
- Maven 3.8+
- Git
- IDE (IntelliJ IDEA, Eclipse, or VS Code)
- Google Cloud SDK (for GCP deployment)
- PostgreSQL (for production) or H2 (for development)
git clone <repository-url>
cd payroll-management-systemCreate or update application.properties or application.yml:
# Server Configuration
server.port=8080
# Database Configuration (Local Development)
spring.datasource.url=jdbc:h2:mem:payrolldb
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
# JPA Configuration
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.format_sql=true
# H2 Console (Development Only)
spring.h2.console.enabled=true
spring.h2.console.path=/h2-consolemvn clean installmvn spring-boot:runOr run the compiled JAR:
java -jar target/payroll-management-system-0.0.1-SNAPSHOT.jarThe application will start on http://localhost:8080
Access the H2 database console at: http://localhost:8080/h2-console
| Method | Endpoint | Description |
|---|---|---|
| GET | /all |
Retrieve all customers |
| POST | /add |
Add a new customer |
| GET | /get/{id} |
Get customer by ID |
| GET | /getbyname/?name={name} |
Get customer by name |
| GET | /getbynameandssn/?name={name}&ssn={ssn} |
Get customer by name and SSN |
POST /add
Content-Type: application/json
{
"name": "John Doe",
"ssn": "123-45-6789",
"productSet": [
{
"pname": "Health Insurance",
"cost": "500"
}
]
}Endpoints available through UserController (to be documented based on implementation)
This application leverages Google Cloud Platform services for production deployment and enhanced capabilities:
Purpose: Managed relational database for production data storage
Configuration:
# application-prod.properties
spring.datasource.url=jdbc:postgresql:///<DATABASE_NAME>?cloudSqlInstance=<INSTANCE_CONNECTION_NAME>&socketFactory=com.google.cloud.sql.postgres.SocketFactory
spring.datasource.username=${DB_USER}
spring.datasource.password=${DB_PASS}
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialectSetup Steps:
# Create Cloud SQL instance
gcloud sql instances create payroll-db \
--database-version=POSTGRES_15 \
--tier=db-f1-micro \
--region=us-central1
# Create database
gcloud sql databases create payrolldb --instance=payroll-db
# Create user
gcloud sql users create payrolluser \
--instance=payroll-db \
--password=<secure-password>Purpose: Serverless container deployment for automatic scaling
Deployment:
# Build container image
gcloud builds submit --tag gcr.io/<PROJECT_ID>/payroll-app
# Deploy to Cloud Run
gcloud run deploy payroll-service \
--image gcr.io/<PROJECT_ID>/payroll-app \
--platform managed \
--region us-central1 \
--allow-unauthenticated \
--add-cloudsql-instances <INSTANCE_CONNECTION_NAME>Purpose: Store application logs, reports, and file uploads
// Example integration in service layer
@Service
public class StorageService {
private final Storage storage = StorageOptions.getDefaultInstance().getService();
public void uploadPayrollReport(String fileName, byte[] data) {
BlobId blobId = BlobId.of("payroll-reports-bucket", fileName);
BlobInfo blobInfo = BlobInfo.newBuilder(blobId).build();
storage.create(blobInfo, data);
}
}Purpose: Centralized logging and monitoring
Add Dependencies:
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>spring-cloud-gcp-starter-logging</artifactId>
</dependency>Purpose: Secure storage of sensitive configuration
# Store database password
echo -n "your-db-password" | gcloud secrets create db-password --data-file=-
# Grant access to Cloud Run service account
gcloud secrets add-iam-policy-binding db-password \
--member="serviceAccount:<SERVICE_ACCOUNT>" \
--role="roles/secretmanager.secretAccessor"# Set project
gcloud config set project <PROJECT_ID>
# Enable required APIs
gcloud services enable sqladmin.googleapis.com
gcloud services enable run.googleapis.com
gcloud services enable cloudbuild.googleapis.com
gcloud services enable secretmanager.googleapis.comcom.ukg
βββ Main.java # Application entry point
βββ config/
β βββ SecurityConfig.java # Security configuration
βββ model/
β βββ Customer.java # Customer entity
β βββ Product.java # Product entity
β βββ Order.java # Order entity
βββ repository/
β βββ CustomerRepository.java # Data access layer
βββ service/
β βββ CustomerService.java # Business logic layer
βββ web/
βββ CustomerController.java # Customer REST endpoints
βββ UserController.java # User REST endpoints
For production deployment with Cloud SQL:
spring:
datasource:
url: jdbc:postgresql:///<DATABASE_NAME>?cloudSqlInstance=<INSTANCE_CONNECTION_NAME>&socketFactory=com.google.cloud.sql.postgres.SocketFactory
username: ${DB_USER:payrolluser}
password: ${DB_PASS}
jpa:
hibernate:
ddl-auto: validate
show-sql: falseImplement in SecurityConfig.java for authentication and authorization requirements.
Set the following environment variables for GCP deployment:
DB_USER: Database usernameDB_PASS: Database passwordGOOGLE_APPLICATION_CREDENTIALS: Path to service account key (for local testing)GCP_PROJECT_ID: Your GCP project ID
# Run all tests
mvn test
# Run with coverage
mvn test jacoco:report- All entities use Lombok annotations (
@Data) to reduce boilerplate code - The
Customerentity has a one-to-many relationship withProductusing eager fetching - Security configuration should be properly implemented in
SecurityConfig.javabefore production deployment - Consider implementing proper error handling and validation
- Add pagination for list endpoints in production
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
For issues and questions, please create an issue in the repository or contact the development team.
Built with β€οΈ using Spring Boot and Google Cloud Platform