A Spring Boot application that handles instant money transfers between users. The system provides REST APIs for payment processing with retry mechanisms and circuit breaker patterns.
- Instant money transfers between accounts
- Idempotency support for safe retries
- Circuit breaker pattern for fault tolerance
- Kafka integration for transaction notifications
- Database transaction management
- REST API endpoints
- Java 21 or higher
- Gradle 8+
- PostgreSQL 15+ (server not running, only the client tools are needed)
- Apache Kafka 3.x
- Docker and Docker Compose
For quick setup with Docker, use the provided docker-compose.yml:
- Start
postgrescontainer
$ docker-compose up postgres
- Use
psqlto login to Postgres in container
$ psql instantpayments -U postgres -h localhost
Password: postgres
- Create a PostgreSQL tables
Run
CREATE TABLE..scripts fromdatabase/database.sql
Also insert seed data as well for testing.
- Ctrl-C (e.g. stop PostgreSQL container)
$ ./gradlew clean build
$ docker-compose up -d --build
POST /api/payments Content-Type: application/json
{ "senderId": "sender123", "recipientId": "recipient456", "amount": 100.00, "idempotencyKey": "unique-transaction-id" }
http://localhost:8080/swagger-ui/index.html
Run unit tests:
$ ./gradlew test
The application exposes actuator endpoints for monitoring:
- Health check: http://localhost:8080/health
- Info: http://localhost:8080/nfo
The system handles various error scenarios:
- Insufficient balance
- Account not found
- Duplicate transactions (idempotency)
- System failures with circuit breaker fallback
Ensure to configure appropriate security measures:
- Enable HTTPS in production
- Implement authentication
- Set up proper authorization
- Secure sensitive configuration