MicroBank is a modern, scalable, and secure banking backend system built using microservice architecture. It enables account management, financial transactions, document generation, and notification services while ensuring robust authentication and authorization mechanisms through Keycloak.
Microservices provide modularization, independent scalability, and better maintainability. Each service in MicroBank is responsible for a specific business capability, allowing independent development and deployment.
- Microservice Architecture: Independent services for authentication, account management, transactions, documents, and notifications.
- Event-Driven Communication: RabbitMQ for asynchronous messaging between services.
- Secure Authentication & Authorization: Keycloak OAuth2 integration.
- Scalable Storage Solutions: PostgreSQL, Redis, and MinIO.
- Containerized Deployment: Docker and Docker Compose for environment consistency.
Before running MicroBank, ensure you have the following installed:
- Java 17 or higher
- Maven (latest version)
- Docker & Docker Compose
- Postman (optional, for API testing)
MicroBank services must be started in a specific order:
- Start infrastructure services (databases, Keycloak, Redis, RabbitMQ, MinIO):
docker-compose up -d
- Start Discovery Service first (to enable service registration):
mvn spring-boot:run -f discovery/pom.xml
- Start remaining microservices (auth, account, transaction, document, notification, and API gateway)
mvn spring-boot:run -f auth/pom.xml mvn spring-boot:run -f account/pom.xml mvn spring-boot:run -f transaction/pom.xml mvn spring-boot:run -f document/pom.xml mvn spring-boot:run -f notification/pom.xml mvn spring-boot:run -f apigateway/pom.xml
A Postman Collection is provided in the ./postman
directory to facilitate API testing.
- Import
MicroBank API Collection.postman_collection.json
into Postman. - Set environment variables like
baseURL = http://localhost:8123/api/v1
. - Run API requests seamlessly.
Keycloak authentication is pre-configured in the project with a realm export file (./keycloak-config/realm-export.json
).
- Access Keycloak Admin UI: http://localhost:9098
- Default admin credentials:
admin / admin
- Important: After Keycloak starts, manually reset
client-secret
values in Clients → microbank-client & admin-cli and update them in./auth/src/main/resources/application.yml
.
The backend consists of multiple independent microservices:
- API Gateway: Routes all requests, handles authentication.
- Auth Service: Manages user authentication and token handling.
- Account Service: Manages bank accounts and balances.
- Transaction Service: Handles money transfers between accounts.
- Document Service: Generates and stores transaction receipts.
- Notification Service: Sends email notifications for important events.
- Discovery Service: Service registry using Eureka for dynamic service discovery.
- Synchronous Communication: OpenFeign is used for inter-service REST API calls.
- Asynchronous Communication: RabbitMQ queues for event-driven messaging.
- PostgreSQL: Persistent storage for Auth, Account, Transaction, and Document services.
- Redis: Temporary storage for authentication-related data (password reset, activation codes).
- MinIO: Object storage for transaction receipts.
To access the PostgreSQL databases and perform administrative tasks, you can use the following commands:
Auth Database (auth_db)
psql -U auth_db -d auth_db -h localhost -p 5431
(Default auth_db
password: auth_db)
Account Database (account_db)
psql -U account_db -d account_db -h localhost -p 5430
(Default account_db
password: account_db)
Transaction Database (transaction_db)
psql -U transaction_db -d transaction_db -h localhost -p 5433
(Default transaction_db
password: transaction_db)
Document Database (document_db)
psql -U document_db -d document_db -h localhost -p 5434
(Default document_db
password: document_db)
- OAuth2 & OpenID Connect: Secure authentication and token-based authorization.
- Role-Based Access Control (RBAC): User roles (
USER
,ADMIN
) managed by Keycloak.
- User Registration & Activation
- Users register via
/api/v1/auth/register
. - Activation code is sent via email.
- User activates the account via
/api/v1/auth/activate
.
- Users register via
- Login & Token Handling
- Users log in via
/api/v1/auth/login
, obtaining an access token and refresh token. - Token validation occurs at the API Gateway.
- Users log in via
- API Gateway (AuthN) & Microservices (AuthZ)
- API Gateway validates tokens and forwards requests.
- Microservices enforce authorization using Spring Security.
All API endpoints are structured under http://localhost:8123/api/v1/
.
Service | Endpoint Example | Description |
---|---|---|
Auth | /auth/login |
User authentication |
Auth | /auth/register |
User registration |
Account | /accounts |
Get user accounts |
Transaction | /transactions |
Create and list transactions |
Document | /documents/{transactionId} |
Retrieve transaction documents |
Notification | Internal | Listens to RabbitMQ events |
All API responses follow a uniform structure:
{
"status": 200,
"message": "Success message",
"data": {},
"timestamp": "2025-02-01T12:00:00.000Z",
"errors": null
}
- Start infrastructure (databases, Keycloak, Redis, RabbitMQ, MinIO) first
- Start Discovery Service
- Start Microservices
- Start API Gateway last
Contributions are welcome! To contribute:
- Fork the repository.
- Create a feature branch.
- Submit a pull request.
For any questions, open an issue or reach out to the project maintainers.