Skip to content

Latest commit

ย 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿš€ TasksApp - Enterprise-Grade Task Management REST API

Java Spring Boot MySQL Docker Coverage

TasksApp is a robust, production-ready RESTful API designed for efficient task and to-do list management. Built with Java 21 and Spring Boot 3, this project demonstrates modern backend engineering practices, including clean architecture, comprehensive automated testing, and secure, containerized deployment.


โœจ Key Features & Technical Highlights

  • Clean Architecture: Strict separation of concerns using the Layered Architecture pattern (Controllers, Services, Repositories).
  • Domain Isolation: Implementation of the DTO Pattern using Java Records and explicit Mappers to decouple the database entities from the presentation layer.
  • Resilient Infrastructure: Fully containerized environment using Docker & Docker Compose with persistent volumes, database healthchecks, and memory limits.
  • Security First: Zero-trust configuration using .env files for secrets management and a non-root user strategy within the Dockerfile.
  • Idempotent Data Seeding: Automated test data initialization via CommandLineRunner ensuring safe execution across multiple deployments.
  • Deterministic Testing: High-quality unit test suite utilizing Mockito, JUnit 5, the Factory Pattern (Object Mother), and a fixed TestClock to prevent flaky tests.

๐Ÿ› ๏ธ Tech Stack

Backend

  • Java 21 (LTS)
  • Spring Boot 3 (Web, Data JPA, Validation)
  • Hibernate (ORM)
  • Lombok (Boilerplate reduction)

Database & DevOps

  • MySQL (Relational Database)
  • Docker & Docker Compose (Containerization & Orchestration)
  • Maven (Dependency & Build Management)

Testing & Documentation

  • JUnit 5 & Mockito (Unit Testing)
  • JaCoCo (Code Coverage Analysis)
  • Springdoc OpenAPI (Swagger UI)
  • Postman (API Collection included)

๐Ÿ“‚ Project Structure

The project follows a standardized layered architectural pattern:

๐Ÿ“ฆ tasksapp
โ”ฃ ๐Ÿ“‚ src/main/java/com/matiasbarraza/tasksapp
โ”ƒ โ”ฃ ๐Ÿ“‚ config        # Global configurations (Swagger, Clock, Data Seeding)
โ”ƒ โ”ฃ ๐Ÿ“‚ controllers   # REST API Endpoints
โ”ƒ โ”ฃ ๐Ÿ“‚ domain        # Entities, Enums, and DTO Records
โ”ƒ โ”ฃ ๐Ÿ“‚ exceptions    # Global exception handling architecture
โ”ƒ โ”ฃ ๐Ÿ“‚ mappers       # DTO to Entity mapping logic
โ”ƒ โ”ฃ ๐Ÿ“‚ repositories  # Spring Data JPA Interfaces
โ”ƒ โ”— ๐Ÿ“‚ services      # Business logic implementation
โ”ฃ ๐Ÿ“‚ postman         # Postman collection for manual testing
โ”ฃ ๐Ÿ“œ docker-compose.yml
โ”ฃ ๐Ÿ“œ Dockerfile
โ”ฃ ๐Ÿ“œ .env.template
โ”— ๐Ÿ“œ pom.xml

๐Ÿ“– API Documentation (Swagger)

The API is fully documented using the OpenAPI specification. Once the application is running, you can explore and interact with all endpoints directly through the Swagger UI web portal.

๐Ÿš€ Access Swagger UI

๐Ÿ“Œ Core Resources & Endpoints

Resource HTTP Methods Description
/api/v1/task-lists GET, POST, PUT, DELETE Manage task lists.
/api/v1/task-lists/{taskListId}/tasks GET, POST, PUT, DELETE Manage tasks within a specific list.

๐Ÿ“ธ UI Preview

Swagger UI Screenshot


๐Ÿ›ก๏ธ Validation & Exception Handling

Request Validation

Incoming requests are rigorously validated at the controller layer using Jakarta Validation constraints to ensure data integrity before reaching the service layer.

  • Required fields verification.
  • Non-empty titles and maximum character length restrictions.
  • Date constraints (e.g., ensuring due dates are scheduled in the future).

Centralized Exception Handler

A robust exception handling mechanism is implemented globally using @ControllerAdvice. This catches system anomalies, validation failures, or illegal arguments, translating them into standard, predictable JSON responses.

๐Ÿ›‘ Example Validation Error Response:

{
    "status": 400,
    "message": "Title is required",
    "details": "uri=/api/v1/tasks",
    "timestamp": "2026-07-07T12:00:00"
}

๐Ÿงช Testing & Code Coverage

Quality assurance is a core pillar of this codebase. The business layer is thoroughly covered against edge cases and invalid parameters.

  • Coverage Target: Strict >80% line coverage enforced by JaCoCo (excluding structural configuration and plain DTO classes).
  • Deterministic Execution: Time-sensitive business rules are verified using a custom TestClock to ensure consistent assertions regardless of the host execution environment.

JaCoCo Coverage Report


๐Ÿ“ฎ Postman Collection

For rapid manual testing, a complete Postman collection is included directly within the repository.

  • File Location: postman/TasksAppCollection.json
  • Features: Pre-configured payloads and parameters for every single available endpoint.

๐Ÿ“ธ Postman Preview

Postman Collection


๐Ÿ”’ Security & DevOps Considerations

Non-Root Container Execution

To align with security best practices, the application Docker image drops root privileges during the build stage and runs under a dedicated, isolated environment user.

RUN addgroup -S spring && adduser -S spring -G spring
USER spring:spring
  • Benefits: Drastically reduced attack surface, tight container isolation, and production-grade reliability.

Environment Management

Configuration parameters and sensitive database credentials are fully decoupled from the code via an environment file.

# Example .env layout
DB_URL=jdbc:mysql://mysql:3306/tasks_db?createDatabaseIfNotExist=true&useSSL=false&serverTimezone=UTC
DB_USER=tasksuser
DB_PASS=taskspassword
MYSQL_ROOT_PASSWORD=root
MYSQL_DATABASE=tasks_db

๐Ÿš€ Getting Started

Follow these steps to spin up the application on your workspace.

Prerequisites

  • Docker & Docker Compose installed.
  • (Optional) Java 21 SDK and Maven if you wish to run the app natively outside containers.

Setup Environment

  1. Clone the repository:
    git clone https://github.com/Matias-Barraza/tasksapp.git
    cd tasksapp
  2. Initialize your local configuration file from the template:
    cp .env.template .env
    (The default parameters are pre-configured to automatically link with the Docker infrastructure).

Execution Options

Option A: Running with Docker Compose (Recommended)

This compiles the application using a multi-stage Dockerfile and deploys the backend alongside a health-checked MySQL instance.

docker compose up -d --build
  • API Base URL: http://localhost:8080/api/v1/
  • Swagger Documentation: http://localhost:8080/api/swagger-ui/index.html

Option B: Running Locally (Native Development)

Ensure you have a local instance of MySQL matching the credentials defined in your .env file before executing:

./mvnw spring-boot:run

๐Ÿ”ฎ Future Improvements

Planned roadmap items to further expand the technical depth of this project:

  • Security Enhancement: Integrate Spring Security with stateful/stateless JWT Authentication & Role-Based Authorization.
  • Database Versioning: Implement Flyway or Liquibase database migrations.
  • Advanced Testing: Integrate Testcontainers for real-database integration tests.
  • CI/CD Pipeline: Configure GitHub Actions for automated building, linting, and coverage reporting.
  • API Features: Introduce Pagination, Advanced Filtering, and dynamic Sorting to the endpoints.
  • Operations: Add Rate Limiting, request throttling, and comprehensive metric monitoring/observability tools.

๐Ÿ‘จโ€๐Ÿ’ป Author

Matias Barraza

About

RESTful API for task management using Java 21, Spring Boot, MySQL, and Hibernate. Layered Architecture, DTO pattern, Docker Compose setup, and Swagger/OpenAPI documentation.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages