Skip to content

sreejar3011/TaskManagerAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

βœ… TaskManagerAPI

Java Spring Boot Maven MySQL JUnit 5 Swagger

πŸ“Œ Project Overview

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.

✨ Features

  • βœ… 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

πŸ› οΈ Tech Stack

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

πŸ—οΈ Project Architecture

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 Responsibilities

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

πŸ“‘ API Endpoints

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

Query Parameters

Get All Tasks

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 Values

Enum Supported Values
Priority LOW, MEDIUM, HIGH
Status PENDING, IN_PROGRESS, COMPLETED

Sample Request

{
  "title": "Build TaskManagerAPI",
  "description": "Implement CRUD APIs with validation and Swagger documentation",
  "priority": "HIGH",
  "status": "IN_PROGRESS",
  "dueDate": "2026-06-30"
}

Sample Response

{
  "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"
}

Error Response Examples

Validation Error

{
  "status": 400,
  "errors": {
    "title": "Title is required",
    "priority": "Priority is required"
  }
}

Not Found Error

{
  "timestamp": "2026-06-15T12:30:00",
  "status": 404,
  "error": "Not Found",
  "message": "Task not found with id: 1"
}

πŸ“š Swagger UI Screenshot

Swagger UI is available after the application starts:

http://localhost:8080/swagger-ui/index.html

Add your Swagger UI screenshot here:

![Swagger UI](docs/images/swagger-ui.png)

Recommended path: docs/images/swagger-ui.png

πŸ—„οΈ Database Schema

Database name used by the application:

CREATE DATABASE taskmanagerdb;

tasks Table

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=update

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

πŸš€ Installation & Setup

Prerequisites

  • Java 21+
  • Maven 3.9+ or the included Maven Wrapper
  • MySQL 8+
  • Git

1. Clone the Repository

git clone https://github.com/your-username/TaskManagerAPI.git
cd TaskManagerAPI

2. Create the MySQL Database

CREATE DATABASE taskmanagerdb;

3. Configure Database Credentials

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=true

4. Install Dependencies

Using Maven Wrapper:

./mvnw clean install

On Windows:

.\mvnw.cmd clean install

▢️ Running the Application

Using Maven Wrapper:

./mvnw spring-boot:run

On Windows:

.\mvnw.cmd spring-boot:run

The API will start at:

http://localhost:8080

Swagger UI:

http://localhost:8080/swagger-ui/index.html

OpenAPI JSON:

http://localhost:8080/v3/api-docs

πŸ§ͺ Running Tests

Run the full test suite:

./mvnw test

On Windows:

.\mvnw.cmd test

Run a specific test class:

.\mvnw.cmd -Dtest=TaskServiceImplTest test

🧾 Validation Rules

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

🧭 Future Enhancements

  • πŸ” 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

πŸ‘€ Author

Sreeja R

πŸ“„ License

This project is available for educational and portfolio use. Add a license file if you plan to distribute or reuse it publicly.

About

A scalable Task Management REST API developed using Spring Boot, MySQL, Spring Data JPA, Hibernate, and Swagger, featuring CRUD operations, search, filtering, pagination, and sorting.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages