Skip to content

🧩 Microservice developed in Spring Boot, RabbitMQ, MongoDB and Docker

License

Notifications You must be signed in to change notification settings

Guilhermebit/btg-pactual-back-end-challenge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BTG Pactual Back-end Challenge

Docker Pulls CI licence mit

Microservice developed to address the BTG Pactual challenge. The challenge involves creating a microservice that:

  • Consumes data from a queue
  • Stores this data in a database
  • Provides functionality to:
    • Retrieve the total amount of an order
    • Get the total number of orders for a customer
    • List orders made by a customer

This project has the following architecture:

Microservice Architecture

Tecnologies

  • ✅ Java 21
  • ✅ SpringBoot
  • ✅ Spring Data MongoDB
  • ✅ RabbitMQ
  • ✅ Docker
  • ✅ JUnit 5 + Mockito(unit tests)
  • ✅ IntelliJ IDEA Community Edition 2023.2.2

🚀 Installation

  1. Clone the repository:
$ git clone https://github.com/Guilhermebit/btg-pactual-back-end-challenge.git
  1. Install dependencies with Maven

  2. Install docker: https://docs.docker.com/engine/install/

  3. Run the following command:

./mvnw clean install

Usage

  1. Run the following command:
docker-compose up 
  1. Access RabbitMQ at http://localhost:15672
  • Login using the default credentials (usually guest/guest).
  • Navigate to the "Queues" menu and select the relevant queue.
  • Paste the provided payload from the challenge into the Payload field.
  • Click on "Publish Message" to send the message to the queue.
  1. The API will be accessible at http://localhost:8081.

Api EndPoints

To test the HTTP requests, you can use Postman.
Download Postman here: https://www.postman.com/downloads/

List customer orders

GET /customers/{customerId}/orders

  • Response 200 (application/json)

    • Body

      {
        "data": [
          {
            "orderId": 1001,
            "customerId": 1,
            "total": 120.00
          }
        ],
        "pagination": {
          "page": 0,
          "pageSize": 10,
          "totalElements": 1,
          "totalPages": 1
        }
      }

Troubleshooting

If you encounter issues, consider the following:

  • Ensure all services are running properly in Docker.
  • Check Docker logs for any errors related to RabbitMQ or MongoDB.
  • Verify that the configuration files are correctly set up.