Skip to content

Rohan10027/Payroll-Integration

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 

Repository files navigation

Payroll Management System

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.

πŸ“‹ Table of Contents

🎯 Overview

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.

πŸ—οΈ Architecture

This application follows a layered architecture pattern:

  • Web Layer (web package): REST controllers handling HTTP requests
  • Service Layer (service package): Business logic and processing
  • Repository Layer (repository package): Data access using Spring Data JPA
  • Model Layer (model package): JPA entities representing domain objects
  • Config Layer (config package): Security and application configuration

✨ Features

  • 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

πŸ› οΈ Technologies Used

  • 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

πŸ“¦ Prerequisites

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)

πŸš€ Installation & Setup

1. Clone the Repository

git clone <repository-url>
cd payroll-management-system

2. Configure Application Properties

Create 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-console

3. Build the Project

mvn clean install

πŸƒ Running the Application

Local Development

mvn spring-boot:run

Or run the compiled JAR:

java -jar target/payroll-management-system-0.0.1-SNAPSHOT.jar

The application will start on http://localhost:8080

Development with H2 Console

Access the H2 database console at: http://localhost:8080/h2-console

πŸ“‘ API Endpoints

Customer Management

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

Example Request - Add Customer

POST /add
Content-Type: application/json

{
  "name": "John Doe",
  "ssn": "123-45-6789",
  "productSet": [
    {
      "pname": "Health Insurance",
      "cost": "500"
    }
  ]
}

User Management

Endpoints available through UserController (to be documented based on implementation)

☁️ GCP Integration

Overview

This application leverages Google Cloud Platform services for production deployment and enhanced capabilities:

1. Cloud SQL (PostgreSQL)

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.PostgreSQLDialect

Setup 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>

2. Cloud Run

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>

3. Cloud Storage

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);
    }
}

4. Cloud Logging

Purpose: Centralized logging and monitoring

Add Dependencies:

<dependency>
    <groupId>com.google.cloud</groupId>
    <artifactId>spring-cloud-gcp-starter-logging</artifactId>
</dependency>

5. Secret Manager

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"

GCP Project Setup

# 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.com

πŸ“ Project Structure

com.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

βš™οΈ Configuration

Production Database Configuration

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: false

Security Configuration

Implement in SecurityConfig.java for authentication and authorization requirements.

Environment Variables

Set the following environment variables for GCP deployment:

  • DB_USER: Database username
  • DB_PASS: Database password
  • GOOGLE_APPLICATION_CREDENTIALS: Path to service account key (for local testing)
  • GCP_PROJECT_ID: Your GCP project ID

πŸ§ͺ Testing

# Run all tests
mvn test

# Run with coverage
mvn test jacoco:report

πŸ“ Additional Notes

  • All entities use Lombok annotations (@Data) to reduce boilerplate code
  • The Customer entity has a one-to-many relationship with Product using eager fetching
  • Security configuration should be properly implemented in SecurityConfig.java before production deployment
  • Consider implementing proper error handling and validation
  • Add pagination for list endpoints in production

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ“ž Support

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

About

Payroll-Integration

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published