Spring Boot Task Management REST API
Build a REST API for managing projects and their tasks with Spring Boot, Spring Data JPA and PostgreSQL, organized in the classic layers: controllers handle HTTP, services hold the business rules, and repositories talk to the database. A project has many tasks; tasks have a status, priority and due date, and can be filtered, sorted and paged. Requests are validated, errors come back in one consistent format, and the whole API is tested against a real PostgreSQL database. You'll learn Spring Boot conventions, JPA entities and one-to-many relationships, DTOs and validation, global exception handling, paging with Spring Data, avoiding slow N+1 queries, and integration testing.
- Estimate
- ~10h
- Steps
- 6
- Completed by
- 0
- Proposed by
- codeseed.app
Spring Boot · Spring Data JPA · PostgreSQL
Project roadmap
- 01
Create the project
~1hCreate a Spring Boot project (with Spring Initializr) with Web, Data JPA, Validation, PostgreSQL and Flyway. Run PostgreSQL with Docker Compose and configure the connection. Add a GET /health endpoint (or Actuator). Done when: the app starts and connects to the database.
- 02
Define the entities
~1.5hCreate the tables with a Flyway migration, and JPA entities Project (name unique, description and created at) and Task (title, description, status TODO, IN_PROGRESS or DONE, priority, due date and its project), with a @OneToMany and @ManyToOne relationship, lazy loading, and deleting a project's tasks when it's deleted. Done when: projects with tasks can be saved and loaded in a quick test.
- 03
Build the layers
~2.5hCreate repositories (JpaRepository), services with the rules (a task's due date can't be in the past when created, and a DONE task can't go back to TODO), and controllers for projects (CRUD) and their tasks (CRUD under /projects/{id}/tasks, plus changing a task's status). Use request and response DTOs (Java records) instead of exposing entities. Done when: every endpoint works with curl.
- 04
Validate and handle errors
~1.5hAdd Bean Validation annotations to the request DTOs (@NotBlank, @Size and @FutureOrPresent) with @Valid in controllers, and a @RestControllerAdvice that turns validation errors into 400 with field messages, missing items into 404, rule violations into 409, and unexpected errors into 500, all as ProblemDetail responses. Done when: every error comes back in the same clear format.
- 05
Add filtering and pagination
~1.5hSupport GET /projects/{id}/tasks?status=&priority=&dueBefore=&page=&size=&sort= using Spring Data's Pageable and a Specification (or derived queries) for the optional filters, returning items with paging information. Make the project list show each project's task counts without loading every task (with a query or @EntityGraph), and check the number of SQL queries in the log. Done when: filters and paging work, and listing runs a small, fixed number of queries.
- 06
Write integration tests
~2hWrite @SpringBootTest integration tests with MockMvc (or TestRestTemplate) against a real PostgreSQL with Testcontainers: CRUD for projects and tasks, the status rules, validation errors, 404s, filtering, paging and sorting, and deleting a project with its tasks. Done when: all tests pass.
Ready to build this?
Get a GitHub repo and start building. Your AI reviewer checks each step as you go.
Tech stack