REST API for an online store built with Spring Boot 3 and Java 17. A portfolio project showcasing clean architecture, professional engineering practices, and conscious technical decisions.
- Clean layered architecture (Controller → Service → Repository)
- Complete separation of concerns – no JPA entities exposed outside the service layer
- DTOs implemented as Java Records
- Mapping with MapStruct
- Database schema management with Flyway
- Integration tests with Testcontainers (real PostgreSQL, no H2)
- Price and product data snapshots in orders (historical consistency)
- Guest checkout support
- Global exception handling using RFC 7807 (Problem Detail)
- Spring Boot Actuator with health, info and metrics
- Comprehensive API documentation with Swagger UI
- Well-structured unit and integration tests
- Java 17
- Spring Boot 3.5
- Spring Data JPA & Hibernate 6
- PostgreSQL 16
- Flyway
- MapStruct
- Lombok
- Testcontainers
- Swagger / OpenAPI 3
- Docker & Docker Compose
# 1. Clone the repository
git clone https://github.com/marand85/online-shop.git
cd online-shop
# 2. Start the application with Docker Compose (PostgreSQL + Backend)
cd infra
docker compose up -dThe application will be available at:
http://localhost:8080
Interactive API documentation:
http://localhost:8080/swagger-ui.html
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/categories |
Get all categories |
| GET | /api/products |
Get products (paginated, filtered, searchable) |
| GET | /api/products/{id} |
Get product details |
| POST | /api/orders |
Create new order (guest checkout) |
| GET | /api/orders/{orderNumber} |
Get order by order number |
The project includes both unit and integration tests:
- Unit tests –
OrderServiceTest - Integration tests –
OrderControllerIT,CategoryRepositoryIT(using Testcontainers with real PostgreSQL)
Run tests with:
./mvnw test- Strict separation between domain models and API contracts
- No
@Dataon JPA entities (conscious decision to avoidequals()/hashCode()pitfalls) open-in-view: falseto prevent lazy loading issues- Price snapshots in order items to ensure historical consistency
- Deterministic test data with explicit IDs
Mariusz Andrzejewski
- GitHub: https://github.com/marand85
This project is part of a three-project portfolio, each demonstrating different skills:
- This project – Clean REST API architecture and testing
- Blog – Spring MVC + Thymeleaf (SSR)
- Banking System – Event-driven architecture with Kafka and microservices