Skip to content

AkashKobal/sentra-assessment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Task Management API – Backend Assignment

This repository contains a Spring Boot–based REST API for a Task Management System, built as part of a backend assessment. The project demonstrates clean API design, validation, database interaction, migrations, and structured code following backend best practices.


🚀 Tech Stack

  • Java 17
  • Spring Boot 4.0.1
  • Spring Web MVC
  • Spring Data JPA (Hibernate 7)
  • PostgreSQL 16
  • Flyway 11 (Database migrations)
  • Redis (Caching layer – cache-aside pattern)
  • Spring Data Redis
  • Maven
  • Lombok
  • Postman (API testing)

📦 Features

User Management

  • Create user
  • List users with pagination
  • Get user by ID
  • Email uniqueness validation

Task Management

  • Create task
  • Get task by ID
  • List tasks with pagination and filters
  • Update task details
  • Update task status
  • Delete task
  • Assign task to user (optional)

Validation & Error Handling

  • Request validation using annotations
  • Proper HTTP status codes (201, 400, 404, 409)
  • Meaningful error responses

Database

  • PostgreSQL as the primary persistent datastore
  • Schema managed strictly using Flyway migrations
  • Hibernate used only for ORM and schema validation

Caching (Redis)

  • Redis is used as a cache layer to optimize read operations
  • Implements the cache-aside pattern
  • Frequently accessed Users and Tasks are cached
  • Cache entries are invalidated or updated on write operations
  • Redis configuration handled via RedisConfig

🗂 Project Structure

src/main/java
 └── com.example.demo
     ├── config
     ├── controller
     ├── domain
     ├── dto
     ├── exception
     ├── mapper
     ├── repository
     ├── service
     ├── util
     └── SentraAssessmentApplication.java

src/main/resources
 ├── db/migration
 │   ├── V1__create_users_table.sql
 │   ├── V2__create_tasks_table.sql
 │   └── V3__add_indexes.sql
 └── application.properties

🛠 Setup Instructions

1️⃣ Prerequisites

  • Java 17+
  • Maven 3.8+
  • PostgreSQL 16.x
  • Git

2️⃣ Database Setup

Create a PostgreSQL database:

CREATE DATABASE sentra;

Update application.properties:

spring.application.name=sentra-assessment

server.port=8080

spring.datasource.url=jdbc:postgresql://localhost:5432/sentra
spring.datasource.username=postgres
spring.datasource.password=Akash@123

spring.jpa.hibernate.ddl-auto=update
spring.jpa.open-in-view=false
spring.jpa.show-sql=false
spring.jpa.properties.hibernate.format_sql=true

spring.flyway.enabled=true
spring.flyway.locations=classpath:db/migration
spring.flyway.baseline-on-migrate=true

spring.data.redis.host=localhost
spring.data.redis.port=6379
spring.data.redis.timeout=2000

management.endpoints.web.exposure.include=health,info

3️⃣ Run Database Migrations

Flyway migrations run automatically on application startup.

Ensure migration files exist under:

src/main/resources/db/migration

4️⃣ Build & Run Application

mvn clean install
mvn spring-boot:run

Application starts at:

http://localhost:8080

🔐 Authentication (Simple)

A static API key–based authentication mechanism is implemented.

Requests must include:

X-API-KEY: <configured-api-key>
  • Implemented using ApiKeyFilter
  • Unauthorized requests are rejected with proper HTTP status codes

📬 API Endpoints

User APIs

  • POST /api/users
  • GET /api/users
  • GET /api/users/{id}

Task APIs

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

🧪 API Testing

A Postman collection is included in the repository.

Steps:

  1. Import the collection into Postman
  2. Set environment variables (base URL, API key if applicable)
  3. Execute requests

✅ Evaluation Alignment

This project covers:

  • Correct REST API design
  • Validation and exception handling
  • Database usage with migrations
  • Clean code structure and readability

📌 Notes

  • Flyway is the single source of truth for database schema
  • Hibernate runs in validate mode
  • Redis is used strictly as a caching layer
  • Application follows a clean layered architecture

👤 Author

Akash Kobal Backend / Full Stack Developer


📄 License

This project is created for assessment purposes.

About

Spring Boot REST API for a Task Management system showcasing clean architecture, validation, PostgreSQL, Flyway migrations, and Redis caching.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages