TaskManagerAPI is a production-ready RESTful API built with Spring Boot 3.x for managing tasks. It supports full CRUD operations, validation, centralized exception handling, search, filtering, pagination, sorting, DTO-based request/response models, MySQL persistence, and Swagger/OpenAPI documentation.
The project follows a clean layered architecture with clear separation between the controller, service, repository, DTO, mapper, entity, configuration, and exception handling layers.
- β Create, read, update, and delete tasks
- π Search tasks by title
- π§ Filter tasks by status and priority
- π Pagination and sorting support
- π§± DTO layer for clean API contracts
- π‘οΈ Request validation using Jakarta Bean Validation
- π Global exception handling with structured error responses
- ποΈ MySQL database integration
- βοΈ Spring Data JPA and Hibernate ORM
- π Swagger/OpenAPI API documentation
- π§ͺ Unit testing with JUnit 5 and Mockito
| Category | Technology |
|---|---|
| Language | Java 21 |
| Framework | Spring Boot 3.5.x |
| Build Tool | Maven |
| Database | MySQL |
| ORM | Hibernate |
| Persistence | Spring Data JPA |
| Validation | Jakarta Bean Validation |
| API Docs | Springdoc OpenAPI / Swagger UI |
| Testing | JUnit 5, Mockito, Spring Boot Test |
| Utilities | Lombok |
TaskManagerAPI
|-- src
| |-- main
| | |-- java/com/example/taskmanagerapi
| | | |-- config
| | | | `-- OpenApiConfig.java
| | | |-- controller
| | | | `-- TaskController.java
| | | |-- dto
| | | | |-- TaskRequestDto.java
| | | | `-- TaskResponseDto.java
| | | |-- entity
| | | | |-- Task.java
| | | | |-- Priority.java
| | | | `-- Status.java
| | | |-- exception
| | | | |-- GlobalExceptionHandler.java
| | | | `-- ResourceNotFoundException.java
| | | |-- mapper
| | | | `-- TaskMapper.java
| | | |-- repository
| | | | `-- TaskRepository.java
| | | |-- service
| | | | |-- TaskService.java
| | | | `-- TaskServiceImpl.java
| | | `-- TaskManagerApiApplication.java
| | `-- resources
| | `-- application.properties
| `-- test
| `-- java/com/example/taskmanagerapi
| |-- controller
| | `-- TaskControllerTest.java
| |-- service
| | `-- TaskServiceImplTest.java
| `-- TaskManagerApiApplicationTests.java
|-- pom.xml
|-- mvnw
|-- mvnw.cmd
`-- README.md
| Layer | Responsibility |
|---|---|
| Controller | Exposes REST endpoints and handles HTTP requests |
| Service | Contains business logic and coordinates persistence operations |
| Repository | Provides database access through Spring Data JPA |
| DTO | Defines request and response contracts |
| Mapper | Converts between entity and DTO models |
| Entity | Represents the database table model |
| Exception | Handles application errors consistently |
| Config | Contains application-level configuration such as OpenAPI setup |
Base URL:
http://localhost:8080/api/tasks
| Method | Endpoint | Description | Request Body | Success Response |
|---|---|---|---|---|
POST |
/api/tasks |
Create a new task | TaskRequestDto |
201 Created |
GET |
/api/tasks |
Get all tasks with pagination and sorting | None | 200 OK |
GET |
/api/tasks/{id} |
Get a task by ID | None | 200 OK |
PUT |
/api/tasks/{id} |
Update an existing task by ID | TaskRequestDto |
200 OK |
DELETE |
/api/tasks/{id} |
Delete a task by ID | None | 204 No Content |
GET |
/api/tasks/status/{status} |
Filter tasks by status | None | 200 OK |
GET |
/api/tasks/priority/{priority} |
Filter tasks by priority | None | 200 OK |
GET |
/api/tasks/search?title={title} |
Search tasks by title | None | 200 OK |
GET /api/tasks?page=0&size=5&sortBy=createdAt&direction=desc| Parameter | Type | Default | Description |
|---|---|---|---|
page |
Integer | 0 |
Zero-based page number |
size |
Integer | 5 |
Number of records per page |
sortBy |
String | createdAt |
Sort field. Supported values: id, title, priority, status, dueDate, createdAt |
direction |
String | desc |
Sort direction: asc or desc |
| Enum | Supported Values |
|---|---|
Priority |
LOW, MEDIUM, HIGH |
Status |
PENDING, IN_PROGRESS, COMPLETED |
{
"title": "Build TaskManagerAPI",
"description": "Implement CRUD APIs with validation and Swagger documentation",
"priority": "HIGH",
"status": "IN_PROGRESS",
"dueDate": "2026-06-30"
}{
"id": 1,
"title": "Build TaskManagerAPI",
"description": "Implement CRUD APIs with validation and Swagger documentation",
"priority": "HIGH",
"status": "IN_PROGRESS",
"dueDate": "2026-06-30",
"createdAt": "2026-06-15T12:30:00"
}{
"status": 400,
"errors": {
"title": "Title is required",
"priority": "Priority is required"
}
}{
"timestamp": "2026-06-15T12:30:00",
"status": 404,
"error": "Not Found",
"message": "Task not found with id: 1"
}Swagger UI is available after the application starts:
http://localhost:8080/swagger-ui/index.html
Add your Swagger UI screenshot here:
Recommended path:
docs/images/swagger-ui.png
Database name used by the application:
CREATE DATABASE taskmanagerdb;| Column | Type | Constraints | Description |
|---|---|---|---|
id |
BIGINT |
Primary key, auto-increment | Unique task identifier |
title |
VARCHAR(100) |
Not null | Task title |
description |
TEXT |
Nullable | Task description |
priority |
VARCHAR |
Not null | Task priority: LOW, MEDIUM, HIGH |
status |
VARCHAR |
Not null | Task status: PENDING, IN_PROGRESS, COMPLETED |
due_date |
DATE |
Nullable | Task due date |
created_at |
DATETIME |
Not null, not updatable | Task creation timestamp |
Hibernate can create/update this table automatically because the project uses:
spring.jpa.hibernate.ddl-auto=updateManual schema reference:
CREATE TABLE tasks (
id BIGINT NOT NULL AUTO_INCREMENT,
title VARCHAR(100) NOT NULL,
description TEXT,
priority VARCHAR(255) NOT NULL,
status VARCHAR(255) NOT NULL,
due_date DATE,
created_at DATETIME NOT NULL,
PRIMARY KEY (id)
);- Java 21+
- Maven 3.9+ or the included Maven Wrapper
- MySQL 8+
- Git
git clone https://github.com/your-username/TaskManagerAPI.git
cd TaskManagerAPICREATE DATABASE taskmanagerdb;Update src/main/resources/application.properties with your MySQL credentials:
spring.application.name=TaskManagerAPI
spring.datasource.url=jdbc:mysql://localhost:3306/taskmanagerdb
spring.datasource.username=root
spring.datasource.password=root@123
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.format_sql=trueUsing Maven Wrapper:
./mvnw clean installOn Windows:
.\mvnw.cmd clean installUsing Maven Wrapper:
./mvnw spring-boot:runOn Windows:
.\mvnw.cmd spring-boot:runThe API will start at:
http://localhost:8080
Swagger UI:
http://localhost:8080/swagger-ui/index.html
OpenAPI JSON:
http://localhost:8080/v3/api-docs
Run the full test suite:
./mvnw testOn Windows:
.\mvnw.cmd testRun a specific test class:
.\mvnw.cmd -Dtest=TaskServiceImplTest test| Field | Rule |
|---|---|
title |
Required, must be between 3 and 100 characters |
description |
Optional, maximum 500 characters |
priority |
Required, must be one of LOW, MEDIUM, HIGH |
status |
Required, must be one of PENDING, IN_PROGRESS, COMPLETED |
dueDate |
Optional, must be today or a future date |
- π Add Spring Security with JWT authentication
- π€ Add user registration and task ownership
- π§© Add role-based authorization
- π¦ Add Docker and Docker Compose support
- π οΈ Add Flyway or Liquibase database migrations
- π Add API metrics with Spring Boot Actuator
- π§ͺ Add integration tests with Testcontainers
- π Add CI/CD workflow using GitHub Actions
- βοΈ Add deployment guide for cloud platforms
Sreeja R
- GitHub: Add your GitHub profile
- LinkedIn: Add your LinkedIn profile
This project is available for educational and portfolio use. Add a license file if you plan to distribute or reuse it publicly.