Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hanka Robotics - Employee Management API

A robust RESTful API built with Spring Boot to handle employee management systems. This service manages CRUD operations for employees, provides data validation, maps between Data Transfer Objects (DTOs) and Entities using ModelMapper, and handles application-specific exceptions globally.


🚀 Features

  • Full CRUD Operations: Create, Read, Update, and Delete employee records.
  • Bulk Ingestion: Create multiple employee records in a single API call.
  • Data Validation: Built-in request body validation via jakarta.validation.
  • Robust Error Handling: Centralized exception mapping returning clear, readable JSON error structures.
  • Layered Architecture: Strictly separates the Web layer (Controllers), Business layer (Services), and Data layer (Entities/DTOs).

🛠️ Tech Stack

  • Java 17+
  • Spring Boot (Spring Web, Spring Data JPA)
  • Jakarta Validation
  • ModelMapper (Object Mapping)
  • Database: Compatible with relational databases (e.g., PostgreSQL, MySQL, H2) via JPA

📋 API Endpoints

All endpoints use the base path: /api/employees

Method Endpoint Description Success Status
POST /api/employees Create a single employee 201 Created
POST /api/employees/bulk Create multiple employees in bulk 200 OK
GET /api/employees Fetch all employees 200 OK
GET /api/employees/{id} Fetch an employee by ID 200 OK
PUT /api/employees/{id} Update an existing employee 200 OK
DELETE /api/employees/{id} Delete an employee by ID 204 No Content

💡 Request/Response Payloads

1. Employee Data Model

When interacting with the API, requests and responses typically resemble the following JSON format:

{
  "firstName": "John",
  "lastName": "Doe",
  "email": "john.doe@hankarobotics.com",
  "salary": 85000.00,
  "department": "R&D",
  "position": "Robotics Engineer"
}

💡 Request/Response Payloads

Error Response Examples

  • Validation Failures (400 Bad Request)

    {
      "email": "must be a well-formed email address",
      "firstName": "must not be blank"
    }
  • Resource Not Found (404 Not Found)

    {
      "error": "Employee with ID 42 not found."
    }
  • Duplicate Resource (400 Bad Request)

    {
      "error": "An employee with this email already exists."
    }

🏗️ Architecture & Package Structure

The project strictly follows standard Spring Boot layered conventions to separate web concerns, business logic, and database entities:

org.hanka.robotics
 │
 ├── controllers  # REST Controllers exposing the API endpoints
 ├── service      # Service interfaces specifying business logic
 ├── entity       # Database JPA entities (mapped to 'employees' table)
 ├── dto          # Data Transfer Objects for decoupled API request/response
 ├── converter    # ModelMapper configurations translating Entity <-> DTO
 └── exceptions   # Custom domain exceptions and Global Exception Handler

⚙️ Getting Started

Prerequisites

  • Java 17 or higher
  • Maven 3.6+

Build and Run

  1. Clone the repository:
    git clone [https://github.com/your-username/your-repo-name.git](https://github.com/your-username/your-repo-name.git)
    cd your-repo-name

2.Run the application:

mvn spring-boot:run

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages