This solution comprises two microservices (AntiFraudService and TransactionService) designed to handle transaction processing and fraud detection. Both services are built using .NET 8.0 and follow the Clean Architecture pattern. Communication between the services is facilitated through Apache Kafka event messaging. The solution is containerized using Docker and Docker Compose, allowing for easy deployment and management of the services.
Both microservices implement Clean Architecture, which:
- Isolates the domain/business logic from external concerns
- Enables better testability and maintainability
- Structures the code in three main layers:
- Domain: Core business logic
- Application: Use cases and orchestration
- Infrastructure: External dependencies (databases, messaging, etc.)
- Presentation: API layer for handling HTTP requests
- Unit Tests: Each microservice includes unit tests for the domain and application layers, ensuring that business logic is thoroughly tested.
The AntiFraudService is responsible for:
- Analyzing transactions for potential fraud
- Processing fraud detection rules
- Communicating results back to the TransactionService
The TransactionService handles:
- Processing incoming transaction requests
- Storing transaction data
- Requesting fraud verification
- Updating transaction status based on fraud analysis results
- Backend: .NET 8.0
- Databases: PostgreSQL
- Messaging: Apache Kafka
- Containerization: Docker and Docker Compose
- Orchestration: Docker Compose for local development
- Testing: xUnit for unit and integration tests
- TransactionService receives a transaction request
- Transaction is saved to PostgreSQL
- TransactionService publishes a "transaction-created-topic" event to Kafka
- AntiFraudService consumes the event and processes fraud detection
- AntiFraudService publishes a "transaction-status-updated-topic" event back to Kafka
- TransactionService consumes the result and updates the transaction status
- Docker and Docker Compose installed
- Git
-
Clone the repository:
git clone <repository-url> cd <repository-directory>
-
Start the solution using Docker Compose:
docker-compose up --build -d
-
The following services will be available:
- TransactionService API: http://localhost:8000
- AntiFraudService API: http://localhost:7000
The solution uses Docker Compose to set up:
- PostgreSQL databases for each service
- Zookeeper for Kafka cluster management
- Kafka brokers for event messaging
- .NET 8.0 containers for both APIs
Each microservice has its own PostgreSQL database:
- YapeTransactionService DB: Stores transaction data, status, and history
- YapeAntiFraudService DB: Stores analysis results, and detection patterns
The main Kafka topics used for communication:
transaction-created-topic: Published by TransactionService when a new transaction is createdtransaction-status-updated-topic: Published by AntiFraudService with the fraud analysis result
To add new features or modify the existing code:
- Each microservice follows the Clean Architecture pattern
- Domain models and business logic are isolated from external concerns
- Infrastructure classes handle database and messaging interactions
This solution was developed by Erick Orlando as part of a project to demonstrate the capabilities of .NET 8.0 and Clean Architecture in building microservices for fraud detection and transaction processing.