- Overview
- Technology Stack
- Application Structure
- Architecture Diagram
- How to build and run
- URLs and Endpoints
- Testing
This Spring Boot application exposes a rest service to consult the final price of a product.
It was designed to comply with a Hexagonal Architecture and also to comply with SOLID principles.
- Common
- Data & Persistence
- Spring Data JPA: JPA based repositories implementation.
- Flyway: To load database migrations at application startup.
- H2 Database: Very fast, open source, JDBC API. Support embedded and server modes; disk-based or in-memory databases
- RestAPI
- springdoc-openapi-ui: Helps to automate the generation of API documentation using spring boot projects.
- rest-assured: REST Assured is a Java DSL for simplifying testing of REST based services.
Module | Description |
---|---|
ecommerce-parent | Module for inheriting common configurations, dependencies, and plugins. |
- ecommerce-application | Part of the business logic is centralized in this layer. |
- ecommerce-bootloader | Module to launch Spring Boot application, run tests and coverage reports. |
- ecommerce-domain | Here the POJO classes and domain interfaces are centralized. |
- ecommerce-infrastructure | Adapters such as Rest and access to Persistence (JPA) are centralized in this module. |
- Java 17
- Maven 3.8.x
Go to the project root directory and execute the following command to compile, test, package and install the different artifacts in your local maven repository.
mvn clean install
Or use the embedded Maven Wrapper if you don't have a maven installation.
./mvnw clean install
IMPORTANT: Make sure you do not have any applications running on port
8080
before running this program.
After creating all artifacts you can run the project with the following command:
mvn spring-boot:run -pl ecommerce-bootloader
Or use the embedded Maven Wrapper if you don't have a maven installation.
./mvnw spring-boot:run -pl ecommerce-bootloader
You should see in the console the following log line:
......
2024-04-25T01:29:26.228-03:00 INFO 45458 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port 8080 (http) with context path ''
2024-04-25T01:29:26.234-03:00 INFO 45458 --- [ main] c.e.b.EcommerceSpringBootApplication : Started EcommerceSpringBootApplication in 1.841 seconds (process running for 1.959)
URL | Description |
---|---|
http://localhost:8080/swagger-ui.html | Swagger interface based on the OpenAPI auto-generated schema that helps you to test the prices resource endpoint. |
http://localhost:8080/v3/api-docs | OpenAPI schema auto-generated from the swagger annotation provided by the springdoc dependency. |
http://localhost:8080/api/v1/prices | GET http method that will receive three parameters. |
http://localhost:8080/h2 | H2 Database Console (URL: jdbc:h2:mem:test , User: sa , Password: password ) |
mvn clean test
Or use the embedded Maven Wrapper if you don't have a maven installation.
./mvnw clean test
Note: This report will be generated through the JaCoCo library
mvn clean verify
Or use the embedded Maven Wrapper if you don't have a maven installation.
./mvnw clean verify
The code coverage report will be generated in the following path: ecommerce-bootloader/target/index.html