Loading repository data…
Loading repository data…
ekadharmayana / repository
Java 21 + Spring Boot REST API for employee CRUD, with PostgreSQL persistence, DTO-based clean architecture, Swagger docs, Docker setup, and GitHub Actions CI.
A professional, production-ready RESTful backend system for managing employee records.
Built with modern Java standards, focusing on clean architecture, separation of concerns (DTO pattern), and automated testing pipelines.
Controller, Service, and Repository layers.git clone https://github.com/ekadharmayana/employee-manager.git
cd employee-manager
We use Docker Compose to start PostgreSQL in isolation:
docker-compose up -d
The database is now accessible at localhost:5432, Default credentials are configured in application.properties.
Use the Maven wrapper to build and start the application (no local Maven installation required).
Mac / Linux:
./mvnw spring-boot:run
Windows (CMD/PowerShell):
mvnw spring-boot:run
The API will start at: http://localhost:8080
This project uses JUnit 5 and Mockito for unit testing to ensure business logic reliability.
To run all tests via terminal:
./mvnw test
Note: This will execute the build process and run all defined test cases, providing summary of passes and failures.
The project includes Swagger UI for interactive API exploration. Once the application is running, access the live documentation here:
👉 http://localhost:8080/swagger-ui/index.html
You can test the API using Postman, curl, or any HTTP client.
| Method | Endpoints | Description | Status Code |
|---|---|---|---|
GET | /api/employees | Retrieve a list of all employee | 200 OK |
GET | /api/employees/{id} | Get specific employee details | 200 OK / 404 |
POST | /api/employees | Create a new employee | 201 Created |
PUT | /api/employees/{id} | Update an existing employee | 200 OK / 404 |
DELETE | /api/employees/{id} | Delete an employee | 204 No Content |
POST /api/employees
{
"firstName": "Max",
"lastName": "Mustermann",
"email": "max.mustermann@example.com"
}
Note: The salary field is hidden by design (DTO Pattern).
{
"id": 1,
"firstName": "Max",
"lastName": "Mustermann",
"email": "max.mustermann@example.com"
}
GET /api/employees/999
{
"timestamp": "2026-02-11T12:00:00",
"status": 404,
"error": "Not Found",
"message": "Employee not found with id: 999",
"path": "uri=/api/employees/999"
}
The project follows a Layered Architecture to ensure maintainability and scalability.
src/main/java/com/codingpartner/employeemanager
├── api # Global Exception Handling & Error Response Wrappers
├── controller # REST Controllers (Handles HTTP Requests)
├── dto # Data Transfer Objects (API Contract)
├── entity # JPA Entities (Database Schema)
├── exception # Custom Exceptions (e.g., NotFoundException)
├── repository # Spring Data Repositories (Database Access)
└── service # Business Logic (Validation, Mapping Entity <-> DTO)
Application settings are located in src/main/resources/application.properties.
8080jdbc:postgresql://localhost:5432/employeedbupdate (Automatically creates schema)Eka Dharma Yana