A RESTful API for task management built with Java 17 and Spring Boot 3.2.
Todo API is a backend project that implements a full CRUD for task management, following development best practices such as MVC pattern, layered architecture, DTOs, global exception handling, and data validation.
Built as a study project to demonstrate the Spring Boot ecosystem with an in-memory H2 database.
| Technology | Version | Purpose |
|---|---|---|
| Java | 17 | Main language |
| Spring Boot | 3.2.4 | Core framework |
| Spring Data JPA | 3.2.4 | Data persistence |
| Spring Validation | 3.2.4 | DTO validation |
| H2 Database | Runtime | In-memory database |
| Lombok | Latest | Boilerplate reduction |
| JUnit 5 | Latest | Unit testing |
| Mockito | Latest | Dependency mocking |
src/main/java/com/example/todoapi/
โ
โโโ controller/ # Presentation layer โ handles HTTP requests
โโโ service/ # Business layer โ application logic and rules
โ โโโ impl/ # Service implementations
โโโ repository/ # Data layer โ database communication
โโโ model/ # JPA entities
โโโ dto/ # Data transfer objects
โ โโโ TaskRequestDTO # Input data
โ โโโ TaskResponseDTO # Output data
โโโ exception/ # Global error handling
โโโ TaskNotFoundException
โโโ ErrorResponse
โโโ GlobalExceptionHandler
git clone https://github.com/henriquebl/todo-api.git
cd todo-api./mvnw spring-boot:run./mvnw clean package
java -jar target/todo-api-0.0.1-SNAPSHOT.jarThe application will be available at http://localhost:8080
| Method | Endpoint | Description | Status |
|---|---|---|---|
GET |
/api/tasks |
List all tasks | 200 OK |
GET |
/api/tasks?completed=true |
Filter by status | 200 OK |
GET |
/api/tasks/{id} |
Get task by ID | 200 OK |
POST |
/api/tasks |
Create a new task | 201 Created |
PUT |
/api/tasks/{id} |
Update an existing task | 200 OK |
DELETE |
/api/tasks/{id} |
Delete a task | 204 No Content |
POST /api/tasks
Content-Type: application/json
{
"title": "Study Spring Boot",
"description": "Finish the To-Do List project",
"completed": false
}Response 201 Created:
{
"id": 1,
"title": "Study Spring Boot",
"description": "Finish the To-Do List project",
"completed": false,
"createdAt": "2026-03-20T02:30:00",
"updatedAt": "2026-03-20T02:30:00"
}GET /api/tasksResponse 200 OK:
[
{
"id": 1,
"title": "Study Spring Boot",
"description": "Finish the To-Do List project",
"completed": false,
"createdAt": "2026-03-20T02:30:00",
"updatedAt": "2026-03-20T02:30:00"
}
]PUT /api/tasks/1
Content-Type: application/json
{
"title": "Study Spring Boot",
"description": "Finish the To-Do List project",
"completed": true
}DELETE /api/tasks/1Response 204 No Content โ no body.
{
"status": 404,
"message": "Task not found with id: 99",
"timestamp": "2026-03-20T02:30:00"
}{
"status": 400,
"message": "Validation error",
"timestamp": "2026-03-20T02:30:00",
"errors": [
"title: Title must be between 3 and 100 characters"
]
}This project uses H2 in-memory database โ data is lost when the application restarts.
Access the visual console at: http://localhost:8080/h2-console
| Field | Value |
|---|---|
| JDBC URL | jdbc:h2:mem:tododb |
| User Name | sa |
| Password | (leave blank) |
# Run all tests
./mvnw test
# Run with coverage report
./mvnw test jacoco:reportTests cover the service layer using JUnit 5 and Mockito, validating both success scenarios and exception handling.
Located at src/main/resources/application.properties:
server.port=8080
spring.jpa.hibernate.ddl-auto=create-drop
spring.jpa.show-sql=true- Authentication with Spring Security + JWT
- API documentation with Swagger / OpenAPI
- Migrate to PostgreSQL
- Pagination and sorting on list endpoints
- Deploy to Railway or Render
Made by Henrique
This project is licensed under the MIT License. See the LICENSE file for details.