How lalotor/fraud-detection works
Project Type and Purpose
• It’s a Java/Spring Boot, multi-module microservices project.
• Purpose: Process financial transactions, detect fraud, and notify clients.
• Uses standard spring-cloud patterns: API Gateway, Eureka Discovery, Config Server, several business microservices, common shared library.
Main Components
a. API Gateway
– Entrypoint for clients (REST).
– Routes requests to “transaction”, “fraud-analysis”, “notification” services.
b. Discovery Server (Eureka)
– Service registry.
– All services (API Gateway, business services) register here.
c. Config Server
– Centralized configuration (application-*.properties).
– Other services fetch config at startup.
d. Business Microservices
1. Transaction Service
• Exposes endpoints to initiate transactions.
• Persists to a datastore (implied by repository).
• May synchronously call Fraud-Analysis.
2. Fraud-Analysis Service
• Analyzes transaction risk.
• Caches results (ehcache).
• Publishes or returns analysis.
3. Notification Service
• Sends out fraud notifications (e-mail/SMS/etc.).
• May listen for events or be invoked by others.
e. Common Library
– Shared code: models (Transaction, FraudNotification), integration abstractions, caching, concurrency utilities.
– Included as a Maven dependency in each service.
f. Infrastructure
– Docker Compose: Boots Eureka, Config, and any external dependencies.
– Build & Run scripts: mvnw, run-all.sh
Relationships & Data Flow
1. Client → API Gateway
2. API Gateway → Discovery Server
3. API Gateway → Transaction Service
• Load-balanced REST call.
4. Transaction Service → Fraud-Analysis Service
• Either REST or messaging (use integration interface).
5. Fraud-Analysis Service → Notification Service
• Upon high-risk detection → Invoke Notification REST API.
6. Notification Service → Client/External Messaging System
• E-mail or SMS adapter (external service boundary).
Architectural Patterns & Principles
• Microservices: each domain area in its own Spring Boot app.
• Service Discovery (Eureka) + API Gateway (Spring Cloud Gateway).
• Central Config (Spring Cloud Config).
• Shared common library to reduce duplication.
• Circuit breaker, caching, and metrics (MetricConfig) are configured per service.
• BDD tests (Cucumber) for service integration.
Must-Have Elements
– Clear labels: service names, ports (optional), protocols.