Skip to content

Latest commit

 

History

History
44 lines (27 loc) · 1.85 KB

step-2-exploring-the-app.md

File metadata and controls

44 lines (27 loc) · 1.85 KB

Step 2: Exploring the app

The application we are going to work on is a microservice based on Spring Boot for managing a catalog of products. It provides APIs to save and retrieve the product information.

Sample App Architecture

SQL database with the products

When a product is created, we will store the product information in our database.

Our database of choice is PostgreSQL, accessed with Spring Data JPA.

Check com.testcontainers.catalog.domain.internal.ProductRepository.

LocalStack

We would like to store the product images in AWS S3 Object storage. We will use LocalStack to emulate the AWS cloud environment locally during local development and testing with Spring Cloud AWS.

Check com.testcontainers.catalog.domain.internal.S3FileStorageService.

Kafka

When a product image is uploaded to AWS S3, an event will be published to Kafka. The kafka event listener will then consume the event and update the product information with the image URL.

Check com.testcontainers.catalog.domain.internal.ProductEventPublisher and com.testcontainers.catalog.events.ProductEventListener.

External Service Integrations

Our application talks to inventory-service to fetch the product availability information. We will use Microcks to mock the inventory-service during local development and testing.

API Endpoints

The API is a Spring Web REST controller (com.testcontainers.catalog.api.ProductController) and exposes the following endpoints:

  • POST /api/products { "code": ?, "name": ?, "description": ?, "price": ? } to create a new product
  • GET /api/products/{code} to get the product information by code
  • POST /api/products/{code}/image?file=IMAGE to upload the product image

Next