Skip to content

Lorenzo-Zagallo/spring-boot-order-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Order Management System (RESTful API)

Java Spring Hibernate MicrosoftSQLServer

💡 About the Project

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).

🛠️ Technologies Used

  • Java 21 (LTS)
  • Spring Boot 3.4.2
  • Spring Data JPA / Hibernate
  • Database: SQL Server (Production) / H2 Database (Testing)
  • Maven (Dependency Management)

📐 Domain Model

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)
  • Order
  • Product
  • Category
  • Payment (1:1 Relationship)
Project Domain Model
Figure 1: System Architecture

🚀 How to Run

Prerequisites

  • 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).

Steps

  1. Clone the repository:

    git clone https://github.com/Lorenzo-Zagallo/spring-boot-order-api.git
  2. Navigate to the project folder:

    cd spring-boot-order-api
  3. Run the application:

    ./mvnw spring-boot:run
  4. Access the H2 Database Console:

    • URL: http://localhost:8080/h2-console
    • JDBC URL: jdbc:h2:mem:testdb
    • User: sa
    • Password: (leave blank)

📍 Main Endpoints

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

👨‍💻 Author

Lorenzo Zagallo

About

A RESTful API for an order management system built with Java 21, Spring Boot 3, and Hibernate, featuring complex ORM mappings.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages