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.
- 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)
- Create user
- List users with pagination
- Get user by ID
- Email uniqueness validation
- 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)
- Request validation using annotations
- Proper HTTP status codes (201, 400, 404, 409)
- Meaningful error responses
- PostgreSQL as the primary persistent datastore
- Schema managed strictly using Flyway migrations
- Hibernate used only for ORM and schema validation
- 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
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
- Java 17+
- Maven 3.8+
- PostgreSQL 16.x
- Git
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
Flyway migrations run automatically on application startup.
Ensure migration files exist under:
src/main/resources/db/migration
mvn clean install
mvn spring-boot:runApplication starts at:
http://localhost:8080
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
POST /api/usersGET /api/usersGET /api/users/{id}
POST /api/tasksGET /api/tasksGET /api/tasks/{id}PUT /api/tasks/{id}PATCH /api/tasks/{id}/statusDELETE /api/tasks/{id}
A Postman collection is included in the repository.
Steps:
- Import the collection into Postman
- Set environment variables (base URL, API key if applicable)
- Execute requests
This project covers:
- Correct REST API design
- Validation and exception handling
- Database usage with migrations
- Clean code structure and readability
- Flyway is the single source of truth for database schema
- Hibernate runs in
validatemode - Redis is used strictly as a caching layer
- Application follows a clean layered architecture
Akash Kobal Backend / Full Stack Developer
This project is created for assessment purposes.