Skip to content

lponik/task-tracker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Task Tracker API

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.

What This Project Does

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.

Tech Stack

  • Java + Spring Boot
  • PostgreSQL
  • Spring Data JPA (Hibernate)
  • DTO pattern
  • Bean Validation (@Valid, @NotBlank, @Size, @FutureOrPresent)
  • Global exception handling with @ControllerAdvice

Project Structure

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

Why This Structure?

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.

Key Concepts (Simple Version)

  • 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.

Request Flow

Client → Controller → Service → Repository → Database → Response

Validation and Error Handling

  • Validation is applied to incoming request bodies using @Valid.
  • Field rules like @NotBlank and @Size prevent 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

Setup Instructions

1) Start PostgreSQL with Docker

docker run --name task-tracker-db \
  -e POSTGRES_USER=postgres \
  -e POSTGRES_PASSWORD=postgres \
  -e POSTGRES_DB=task_tracker \
  -p 5432:5432 \
  -d postgres:16

2) Start the Spring Boot app

From the project root:

./mvnw spring-boot:run

The API runs at: http://localhost:8080

API Endpoints

  • POST /api/tasks
  • GET /api/tasks
  • GET /api/tasks/{id}
  • PUT /api/tasks/{id}
  • DELETE /api/tasks/{id}

Example Request Body (Create/Update)

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

About

A beginner-level Spring Boot REST API for managing tasks (create, read, update, delete).

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages