A beginner-level Spring Boot REST API for managing tasks (create, read, update, delete).
This project is meant to show clean backend structure and core API concepts in a simple way.
The API lets a client:
- create a task
- view all tasks
- view one task by ID
- update a task
- delete a task
Each task has fields like title, description, status, and due date.
- Java + Spring Boot
- PostgreSQL
- Spring Data JPA (Hibernate)
- DTO pattern
- Bean Validation (
@Valid,@NotBlank,@Size,@FutureOrPresent) - Global exception handling with
@ControllerAdvice
src/main/java/com/example/tasktracker
├── controller # handles HTTP requests/responses
├── service # business logic
├── repository # database access (JPA)
├── model # entity classes (database tables)
├── dto # request/response objects
└── exception # custom exceptions + global error handler
This layered structure is used so each part has one clear job:
- Separation of concerns: controller, service, and database logic are not mixed together.
- Cleaner code: easier to read, debug, and test.
- Scalable design: this is the same style used in many real backend projects.
- Controller: receives API requests (
GET,POST, etc.) and returns responses. - Service: contains the application rules (for example, duplicate title checks).
- Repository: talks to the database using Spring Data JPA methods.
- DTOs: objects used for API input/output.
We use DTOs instead of entities so API models stay clean and independent from database models.
Client → Controller → Service → Repository → Database → Response
- Validation is applied to incoming request bodies using
@Valid. - Field rules like
@NotBlankand@Sizeprevent bad input. - A global handler (
@ControllerAdvice) returns consistent API errors.
Common responses:
- 400 Bad Request: validation failed (invalid input)
- 404 Not Found: task ID does not exist
- 409 Conflict: duplicate task title
docker run --name task-tracker-db \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=postgres \
-e POSTGRES_DB=task_tracker \
-p 5432:5432 \
-d postgres:16From the project root:
./mvnw spring-boot:runThe API runs at: http://localhost:8080
POST /api/tasksGET /api/tasksGET /api/tasks/{id}PUT /api/tasks/{id}DELETE /api/tasks/{id}
{
"title": "Study Spring Boot",
"description": "Review controller and service layers",
"status": "TODO",
"dueDate": "2026-05-01"
}This project is focused on learning backend fundamentals with clean architecture and practical REST API patterns.