Skip to content

skatesham/hexagonal-api-car-spring-rabbitmq-template

Repository files navigation

API Car with FIPE integration (Hexagonal Architecture)

coverag

API register vehicle indexed by brand and model with external client app price search. alt text

Explanation

How works creation:

  1. Receive request for create Vehicle by POST Rest entrypoint
  2. Validate database schema constraints, as: UK, Marca and Modelo
  3. Produce Event for schedule creation
  4. Consume Event and convert to Object
  5. Request External Client Demo FIPE getting the vehicle FIPE price
  6. When has External client Integration Error: send to DLQ
  7. Convert vehicle Price value to number
  8. Save vehicle on database

Stack

API:

  • Java 11: Language Programming version 11
  • Spring Boot: Java Injection Framework
  • Spring Web: Embedded Web Server (Apache Tomcat)
  • Spring JPA: ORM Hibernate
  • OpenFeign: Web Client
  • RabbitMQ: Async Queue Messaging
  • Actuator: Health check
  • Flyway: Manage Database Migration Versioning
  • Netflix Ribbon: Client Side Load Balancer (Manage OpenFeign Client)
  • Jackson ObjectMapper: Library for mapper objects java.
  • PostgreSQL: Database SQL
  • PostgreSQL Driver: Configure connection with PostgreSQL Database
  • Lombok: Java Code Style Improvements

Tests:

  • Wiremock: Mock Web client Server
  • H2: Light weight Embedded SQL Database
  • RestAssured: Testing BDD REST API
  • H2 Driver: Configure connection with H2 Database

Running App

Requirements

  • JDK Java 11
  • Docker / Docker Compose
./gradlew build --parallel --x test
docker build --tag=car-api:latest .
docker-compose up

Open App

Example Vehicle Request:
Endpoint: POST /api/v1/veiculos

Payload:

{
  "placa": "NEW-4321",
  "marcaId": 21,
  "modeloId": 473,
  "precoAnuncio": 1000000,
  "ano": 2011
}

Database Credentials:

System: PosgreSQL
Server: db
Username: 123456789
Password: 123456789
Database: postgres

RabbitMQ Credentials:

Username: guest
Password: guest

Schema

alt text

Vehicle Creation Flow

alt text

Credits:

Sham Vinicius Fiorin
By Dryve

About

Java template for MS hexagonal Architecture

Resources

Stars

Watchers

Forks

Packages

No packages published