Stop 14 · Spring Boot & Backend DevelopmentProjects · 1/2

Task Manager REST API

Part of the Java Roadmap

In short

This is the project that proves you can build a real backend: layered code, a database, validation, clean errors and tests. Small enough to finish in a week, solid enough to discuss for twenty minutes in an interview.

A Spring Boot API for creating, updating, filtering and completing tasks, backed by MySQL or PostgreSQL. It shows you can build a clean, layered backend with tests.

The jaadu moves colourful sticky notes across three columns on a big office whiteboard while teammates sip chai and watch.

Think of it like this

The team whiteboard

A startup team in Kochi keeps a whiteboard with sticky notes for every task: who owns it, when it's due and whether it's done. People add notes, move them, and peel them off when finished. Your API is that whiteboard for an app, with each endpoint a way to add, move or finish a note.

The big ideas

What you need to know

Enum for status

Store status as @Enumerated(EnumType.STRING) so the database holds readable values, not numbers.

Filtering and paging

GET /api/tasks?status=TODO&page=0&size=10 using a Pageable repository method.

A business rule

A DONE task can't move back to TODO. Enforce it in the service and return 409 Conflict.

Tests that matter

Test the rule, the 404 for a missing task and a validation error. Mention coverage in your README.

How it works

Build plan

  1. 1

    Model

    Task entity: id, title, description, status (TODO, IN_PROGRESS, DONE), priority, dueDate, timestamps.

  2. 2

    Schema

    Flyway V1 creates the tasks table in PostgreSQL or MySQL.

  3. 3

    Layers

    TaskRepository, TaskService with business rules, TaskController with DTO records.

  4. 4

    Quality

    Validation on requests, a GlobalExceptionHandler and filtering with ?status=DONE&page=0.

  5. 5

    Proof

    Controller and service tests, Swagger UI, a Dockerfile and a README with sample requests.

See it in code

Walk through the code

java
1import jakarta.persistence.*;2import jakarta.validation.constraints.*;3import java.time.LocalDate;4 5enum Status { TODO, IN_PROGRESS, DONE }6 7@Entity8class Task {9    @Id @GeneratedValue(strategy = GenerationType.IDENTITY)10    Long id;11    String title;12    @Enumerated(EnumType.STRING)13    Status status = Status.TODO;14    LocalDate dueDate;15}16 17record CreateTaskRequest(@NotBlank @Size(max = 120) String title,18                         @FutureOrPresent LocalDate dueDate) {}19 20class TaskService {21    private final TaskRepository repo;22    TaskService(TaskRepository repo) { this.repo = repo; }23 24    @org.springframework.transaction.annotation.Transactional25    public Task changeStatus(Long id, Status next) {26        Task task = repo.findById(id).orElseThrow(() -> new TaskNotFoundException(id));27        if (task.status == Status.DONE && next == Status.TODO) {28            throw new InvalidTransitionException("A finished task cannot go back to TODO");29        }30        task.status = next;   // dirty checking saves it at commit31        return task;32    }33}

1/6A small enum keeps status values fixed and type-safe.

The core pieces, simplified with package-private fields. Add the controller, exception handler and tests from earlier lessons. Mark TaskService with @Service in your project.

Save yourself the pain

Common mistakes

Oops

Putting all logic in the controller.

Do this instead

Controllers handle HTTP. Rules like status transitions belong in the service, where they're easy to test.

Oops

Using @Enumerated(EnumType.ORDINAL) or the default.

Do this instead

Ordinal stores 0, 1, 2. Reordering the enum later silently corrupts data. Use STRING.

Oops

Shipping without a README.

Do this instead

Add setup steps, an endpoint table, sample curl requests and a screenshot of Swagger UI.

Your mission

Ship the Task Manager

~300 min

Quick check

Why store the status enum with EnumType.STRING?

Go deeper

  1. 1Use controller, service and repository layers with DTOs.
  2. 2Add validation, global error handling and pagination.
  3. 3Write unit tests with Mockito and document endpoints with Swagger (springdoc-openapi).

More projects at this stop

Stuck on this topic? Ask an Insider

Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.

Download
InsideEdge