Skip to content

Conversation

@Martin161195
Copy link

@Martin161195 Martin161195 commented Jan 6, 2026

🚀 Feature: Transaction Service with Anti-Fraud Integration via Kafka

📋 Summary

Implements a complete transaction management microservice with real-time anti-fraud validation using event-driven architecture and hexagonal design pattern.

🎯 What's New

  • Transaction Service microservice with RESTful API
  • Anti-Fraud integration via Apache Kafka for asynchronous validation
  • Hexagonal Architecture ensuring clean domain logic and infrastructure decoupling
  • Event-driven communication between services using Kafka topics
  • PostgreSQL persistence with JPA/Hibernate and connection pooling
  • Transaction status management: PENDING → APPROVED/REJECTED

🏗️ Architecture Highlights

  • Domain Layer: Pure business logic with value objects and entities
  • Application Layer: Use cases implementation (Create, Get, Update transactions)
  • Infrastructure Layer: REST controllers, Kafka producers/consumers, PostgreSQL adapters
  • Kafka Topics:
    • transaction.created - Published by Transaction Service
    • transaction.approved/rejected - Consumed from Anti-Fraud Service

🔧 Technical Stack

  • Java 17 + Spring Boot
  • Apache Kafka
  • PostgreSQL
  • Maven (dependency management)
  • Docker & Docker Compose (containerization)

📦 Key Components

Transaction Service

  • CreateTransactionUseCase - Creates transactions with PENDING status
  • UpdateTransactionStatusUseCase - Updates status based on anti-fraud response
  • KafkaEventPublisher - Publishes transaction events
  • KafkaTransactionConsumer - Consumes fraud evaluation results

Configuration

  • Kafka Producer: idempotent, acks=all, compression enabled
  • Kafka Consumer: manual commit, 3 concurrent threads
  • Database: HikariCP connection pool

📝 API Endpoints

  • POST /api/v1/transactions - Create new transaction
  • GET /api/v1/transactions/{id} - Retrieve transaction by ID

🔄 Transaction Flow

  1. Client creates transaction via REST API
  2. Transaction saved with status PENDING
  3. Event published to Kafka (transaction.created)
  4. Anti-Fraud Service evaluates (async)
  5. Result received via Kafka (approved or rejected)
  6. Transaction status updated accordingly

📚 Documentation

  • Complete README with architecture diagrams
  • Scaffolding structure documented
  • API examples with curl commands

✅ Checklist

  • Hexagonal architecture implemented
  • REST API endpoints working
  • Kafka producer configured
  • Kafka consumer configured
  • PostgreSQL integration
  • Logging configured
  • README documentation
  • Unit tests completed
  • Integration tests completed

🚦 How to Test

# Start infrastructure
docker-compose up -d postgres kafka zookeeper

# Run application
mvn spring-boot:run -Dspring.profiles.active=dev

# Create transaction
curl -X POST http://localhost:8080/api/v1/transactions \
  -H "Content-Type: application/json" \
  -d '{
    "accountExternalIdDebit": "550e8400-e29b-41d4-a716-446655440000",
    "accountExternalIdCredit": "6ba7b810-9dad-11d1-80b4-00c04fd430c8",
    "transferTypeId": 1,
    "value": 500.00
  }'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant