This project is a comprehensive RESTful API for managing store orders, simulating a real-world e-commerce ecosystem.
The main goal was to develop a robust application utilizing best practices within the Spring Boot 3 and Java 21 ecosystem, focusing heavily on:
- Layered Architecture (Controllers, Services, Repositories).
- Global Exception Handling for standardized HTTP responses.
- DTO (Data Transfer Object) Pattern for security and entity decoupling.
- Dependency Injection via constructor (Industry Best Practice).
- Complex Object-Relational Mapping (ORM) (Many-to-Many associations with extra attributes).
- Java 21 (LTS)
- Spring Boot 3.4.2
- Spring Data JPA / Hibernate
- Database: SQL Server (Production) / H2 Database (Testing)
- Maven (Dependency Management)
The system successfully resolves the challenge of Many-to-Many associations with extra attributes (in the OrderItem class), ensuring strict data integrity between Orders and Products.
Main Entities:
User(Client)OrderProductCategoryPayment(1:1 Relationship)
- Java 21 or higher installed.
- Maven installed.
- SQL Server (Optional - the project is configured to run with an in-memory H2 database by default for quick testing).
-
Clone the repository:
git clone https://github.com/Lorenzo-Zagallo/spring-boot-order-api.git
-
Navigate to the project folder:
cd spring-boot-order-api -
Run the application:
./mvnw spring-boot:run
-
Access the H2 Database Console:
- URL:
http://localhost:8080/h2-console - JDBC URL:
jdbc:h2:mem:testdb - User:
sa - Password: (leave blank)
- URL:
| Method | Endpoint | Description |
|---|---|---|
| GET | /workshop/products |
Lists all products |
| GET | /workshop/orders/{id} |
Fetches an order by ID (including its items) |
| POST | /workshop/orders |
Creates a new order |
| POST | /workshop/users |
Creates a new user |
Lorenzo Zagallo
- GitHub: @Lorenzo-Zagallo
- LinkedIn: Lorenzo Zagallo
