A Spring Boot application demonstrating the Hexagonal Architecture (also known as Ports and Adapters) pattern in a bookstore management system.
This project implements the Hexagonal Architecture pattern with the following components:
- Domain Layer: Contains the core business logic and entities
- Application Layer: Contains ports (interfaces) and services
- Infrastructure Layer: Contains adapters and configuration
src/
├── main/
├── java/
│ └── com/example/hexagonalbookstore/
│ ├── application/ # Application layer
│ │ ├── ports/ # Interfaces
│ │ └── services/ # Use cases
│ ├── domain/ # Domain layer
│ │ ├── model/ # Domain entities
│ │ └── exception/ # Domain exceptions
│ └── infrastructure/ # Infrastructure layer
│ ├── adapters/ # Input/Output adapters
│ └── config/ # Configuration
└── resources/
├── application.properties # Application configuration
└── openapi.yaml # API documentation
- CRUD operations for books
- RESTful API with proper error handling
- OpenAPI documentation
- Hexagonal Architecture implementation
- JPA persistence
- Validation
- Exception handling
- Java 17
- Spring Boot 3.2.1
- Spring Data JPA
- H2 Database
- SpringDoc OpenAPI
- Maven
- Lombok
The API documentation is available through Swagger UI when running the application:
- Swagger UI:
http://localhost:8080/swagger-ui.html - OpenAPI Spec:
http://localhost:8080/v3/api-docs
- Ensure you have Java 17 and Maven installed
- Clone the repository
- Navigate to the project directory
- Run the application:
mvn spring-boot:runPOST /api/books- Create a new bookGET /api/books- Get all booksGET /api/books/{id}- Get a book by IDPUT /api/books/{id}- Update a bookDELETE /api/books/{id}- Delete a book
Run the tests using:
mvn testBuild the application using:
mvn clean packageThe JAR file will be generated in the target directory.
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a new Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.