Spring boot application project with a REST API and a Postgres DB. This repo was made for testcontainers workshop.
The project uses hexagonal architecture with Maven multi-module to separate different layers. The different layers are:
- application: Contains the domain and the business logic of the application.
- driven: Contains driven/out ports for the application. Here we have:
- database: Database adapter with JPA and Postgres.
- driving: Contains driving/in ports for the application. Here we have:
- rest-api: REST API adapter with Spring Boot web.
The application is about managing stores, products and their stock. We have 3 separated APIs:
- stores: API to read stores data. Including store data and product stock.
- products: API to read products data. Including product data, prices and suppliers that serves the product.
- pallet: API to scan cargo pallets and process them as stock for the stores.
The more interesting part here is the pallet API. The barcode of a pallet has to be decoded in order to process it. The barcode is composed of IAs, which are a 2-3 digit indicator that tells us what kind of information comes next and how long it is. The IAs are:
- 00: The next 18 digits are the pallet ID.
[Required]
- 01: The next 14 digits are the product ID.
[Required]
- 412: The next 13 digits are the supplier ID.
[Required]
- 410: The next 13 digits are the delivery site ID (store ID for us).
[Required]
- 37: The next 1 to 8 digits are the quantity of products (the symbol
*
is used to mark the end)[Required]
- 10: The text 1 to 20 digits are the batch id (the symbol
*
is used to mark the end) - 11: The next 6 digits are the expiration date in the format
yyMMdd
.
- main: Contains the initial project with the hexagonal architecture.
- testcontainers/demo: Contains examples about testing domain logic with a Posges DB using Testcontainers.
- testcontainers/workshop-db: Contains the starting point for the workshop about testing the database adapter with Testcontainers.
- testcontainers/workshop-db-solution: Contains our version of the solution for the workshop about testing the database adapter with Testcontainers.
- testcontainers/workshop-kafka: Contains the starting point for the workshop about testing the Kafka adapter with Testcontainers.
- testcontainers/workshop-kafka-solution: Contains our version of the solution for the workshop about testing the Kafka adapter with Testcontainers.
- testcontainers/workshop-api: Contains the starting point for the workshop about testing external API adapter with Testcontainers.
- testcontainers/workshop-api-solution: Contains our version of the solution for the workshop about testing external API adapter with Testcontainers.
- Docker/Podman
- Java 21
- Maven 3
The project has a docker compose file with a postgres database container.
docker-compose up -d
Then you can run the project with an IDE or with maven.
mvn clean install
cd boot
mvn spring-boot:run
Or just run the jar file.
mvn clean package
java -jar driven/database/target/workshop-web-products-database-0.1.0.jar
When the project is running, you can access the API documentation at: