Production-style backend REST API built with Java and PostgreSQL. Focus on clean architecture, scalability, and database performance.
Overview
RESTful API for managing products and categories. Built with Spring Boot 3 and PostgreSQL. Implements full CRUD operations with pagination, validation, and centralized error handling.
Architecture
Standard layered architecture: Controller, Service, Repository. DTOs decouple the API contract from the persistence model. Manual entity-to-DTO mapping keeps the service layer in control of what gets exposed.
Key Features
Product CRUD with SKU and name uniqueness enforcement. Category management with cascade validation. Pagination with configurable page sizes. Request validation using Jakarta Bean Validation. Global exception handling via @RestControllerAdvice.
Technical Highlights
DTO Projection via JPQL constructor expressions to avoid fetching full entities for list views. JOIN FETCH to prevent N+1 queries when loading products with categories. @BatchSize for collection batching. Time-ordered UUIDs for index-friendly primary keys. @Transactional(readOnly = true) on all query operations.
Performance
Generated and queried 100,000+ PostgreSQL records. Used EXPLAIN ANALYZE to study query plans. Optimized with DTO projections to reduce column fetching and JOIN FETCH to eliminate N+1 queries.