Microservice for digital wallet management built with Java 21, Spring Boot and MongoDB.
- Create wallets
- Deposit and withdraw funds
- Transfer between wallets
- List transactions
- Query current and historical balance
Base API path: http://localhost:8080/api/v1
- Java 21
- Spring Boot 3.4.5
- Spring Data MongoDB
- Spring Boot Actuator
- Maven
- Docker
- JUnit 5, Mockito and JaCoCo
- Java 21
- Maven
- Docker Desktop or Docker Engine with Compose
- Start MongoDB:
cd docker
docker compose up -d
cd ..MongoDB URI used by the application:
mongodb://walletadmin:walletpass@localhost:27017/wallet_management?authSource=admin
If needed, override it:
export MONGODB_URI='mongodb://walletadmin:walletpass@localhost:27017/wallet_management?authSource=admin'- Run the application:
mvn spring-boot:run- Check health:
curl http://localhost:8080/actuator/health- Stop MongoDB when finished:
cd docker
docker compose down- Start MongoDB:
cd docker
docker compose up -d
cd ..- Build the image:
docker build -t wallet-management-ms:latest .- Run the container:
docker run --rm -p 8080:8080 \
-e MONGODB_URI='mongodb://walletadmin:walletpass@host.docker.internal:27017/wallet_management?authSource=admin' \
--name wallet-management-ms \
wallet-management-ms:latestOn Linux, replace
host.docker.internalwith your Docker host gateway/IP if needed.
| Method | Endpoint | Description |
|---|---|---|
| POST | /wallets |
Create wallet |
| GET | /wallets/{walletId} |
Get wallet |
| GET | /wallets/{walletId}/balance |
Get current balance |
| GET | /wallets/{walletId}/balance?at=datetime |
Get historical balance |
| POST | /wallets/{walletId}/deposit |
Deposit funds |
| POST | /wallets/{walletId}/withdraw |
Withdraw funds |
| GET | /wallets/{walletId}/transactions |
List transactions |
| POST | /transfers |
Transfer between wallets |
Create wallet:
curl -X POST http://localhost:8080/api/v1/wallets \
-H "Content-Type: application/json" \
-d '{"owner_name":"John Doe","owner_email":"john@example.com"}'Transfer:
curl -X POST http://localhost:8080/api/v1/transfers \
-H "Content-Type: application/json" \
-d '{
"source_wallet_id":"uuid-1",
"destination_wallet_id":"uuid-2",
"amount":50.00,
"description":"Payment"
}'{
"error_code": "WALLET_NOT_FOUND",
"message": "Wallet not found with id: ...",
"timestamp": "2026-03-29T10:30:00",
"path": "/api/v1/wallets/..."
}Common status codes: 200, 201, 400, 404, 422, 500.
Files available in collection/:
wallet-management-ms.postman_collection.jsonwallet-management-ms.local.postman_environment.jsonwallet-management-ms.docker.postman_environment.json
Run all tests:
mvn testGenerate coverage report:
mvn test jacoco:reportCoverage output: target/site/jacoco/index.html
src/main/java/io/github/juli0mendes/walletmanagement/
├── application/ # Use cases
├── controller/ # REST controllers
├── domain/ # Domain model and repository ports
├── dto/ # Request/response DTOs
├── exception/ # API error handling
├── infrastructure/ # MongoDB adapters, mappers and configuration
└── config/ # Application configuration