A Payment API built with Spring Boot, using PostgreSQL, RabbitMQ, and Docker.
This project demonstrates an Event-Driven Architecture (EDA) where order creation generates events that are sent to a message broker and processed asynchronously.
- Java 21
- Spring Boot 3
- Spring Data JPA
- PostgreSQL
- RabbitMQ
- Docker
- Swagger / OpenAPI
- Lombok
- Maven
The system follows an Event-Driven Architecture using RabbitMQ for asynchronous communication.
It also follows a layered architecture, separating responsibilities into:
- Controllers
- Services
- Repositories
Project structure:
src/main/java/com/pay/payment_api
├── controller
├── service
├── repository
├── dto
├── mapper
├── entity
├── event
├── consume
└── exception-
Client sends a request to create an order
-
The order is stored in PostgreSQL
-
An OrderCreatedEvent is published to RabbitMQ
-
A consumer receives and processes the event
Simplified flow:
Client → API → Database
↓
RabbitMQ
↓
Consumer-
Create orders
-
List orders
-
Update order status
-
Publish events to RabbitMQ
-
Consume events asynchronously
-
Global exception handling
-
API documentation with Swagger
-
Running the Project
1 Clone the repository
git clone https://github.com/marconi-prog/fintech-payment-api.git
cd fintech-payment-api2 Start containers
docker compose up -dThis will start:
-
PostgreSQL
-
RabbitMQ
3 Run the application
mvn spring-boot:runAPI Documentation
Swagger UI available at:
http://localhost:8080/swagger-ui/index.htmlEndpoints Create Order
POST /orders
Request body:
{
"customerId": "UUID",
"amount": 100.50
}List Orders
Update Order Status
Available status values:
PENDING
PAYMENT_PROCESSING
PAYMENT_APPROVED
PAYMENT_FAILEDError Handling
The application includes a Global Exception Handler to standardize error responses.
Example response:
{
"message": "Order not found",
"status": 400,
"timestamp": "2026-03-05T03:40:00"
}Marconi Farias Backend Developer