Skip to content

Reactive Spring Boot web service for managing client data and resolving bank names by credit card numbers. The service uses MongoDB for data persistence and supports high-throughput asynchronous operations.

Notifications You must be signed in to change notification settings

sashasch/clients-payment-mgmt

Repository files navigation

Clients Payment Management Service

This is a Reactive Spring Boot web service for managing client data and resolving bank names by credit card numbers. The service uses MongoDB for data persistence and supports high-throughput asynchronous operations.


📦 Features

  • CRUD operations for clients
  • Lookup of banks for specific credit card IDs
  • Reactive stack (WebFlux + Reactive MongoDB)
  • Docker & Docker Compose ready
  • Collection filtering happens on MongoDb Side by generic repository customization.
  • Primary data validation presents using Jakarta Validation.
  • Errors handling:
    • 404 (Not Found) Error thrown if a client not found
    • 400 (Bad Request) Error thrown if a client already exists (by name) or the request is not valid.
  • Used MapStruct for DTO <-> Models mapping.
  • Used Smart tests approach - if no Mongo present, the tests depends on it will be skipped to allow normal build anytime

🔗 REST API Endpoints

Base URL: http://localhost:8080/clients

▶️ Create Client

curl -X POST http://localhost:8080/clients \
  -H "Content-Type: application/json" \
  -d '{
        "name": "John Doe",
        "creditCardIds": ["1111222233334444", "5555666677778888"]
      }'

🛠 Update Client

curl -X PUT http://localhost:8080/clients/<id> \
  -H "Content-Type: application/json" \
  -d '{
        "name": "Updated Name",
        "creditCardIds": ["cc1", "cc3"]
      }'

📥 Get All Clients

curl http://localhost:8080/clients

🔍 Get Client by ID

curl http://localhost:8080/clients/<id>

❌ Delete Client by ID

curl -X DELETE http://localhost:8080/clients/<id>

🏦 Resolve Bank Names

curl -X POST http://localhost:8080/clients/bank-names \
  -H "Content-Type: application/json" \
  -d '{
        "personIds": ["<clientId1>", "<clientId2>"],
        "creditCardIds": ["1111222233334444", "cc1"]
      }'

🚀 Running the Project

🧱 Prerequisites

  • Java 17
  • Gradle
  • Docker & Docker Compose

▶️ Build the JAR

./gradlew clean build

🐳 Start,Stop with Docker Compose

docker-compose up --build
docker-compose up -d
docker-compose down

The app will be available at:
📍 http://localhost:8080/clients


🧪 Sample MongoDB Document (Person)

{
  "_id": "abc123",
  "name": "Alice",
  "creditCardIds": ["cc1", "cc2", "cc3"]
}

📁 Environment Variables (.env)

The app uses the following environment variables (loaded via .env):

MONGO_IMAGE=docker.io/library/mongo:latest
MONGO_PORT=27017
APP_PORT=8080
MONGO_DB_NAME=clients_db
MONGO_URI=mongodb://mongo:${MONGO_PORT}/${MONGO_DB_NAME}

📁 TODO

  • Add tests and monitor test coverage.
  • Replace Smart tests with TestContainers usage.


About

Reactive Spring Boot web service for managing client data and resolving bank names by credit card numbers. The service uses MongoDB for data persistence and supports high-throughput asynchronous operations.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published