This system implements a microservices architecture for managing bank accounts and transactions, as depicted in the provided diagram. It leverages the capabilities of the Spring Boot
framework, incorporating key technologies such as Spring Cloud
and Netflix Eureka
to deliver a scalable and resilient solution.
The system employs a layered architecture, with the API Gateway providing an abstraction layer between clients and microservices. Service discovery and load balancing are crucial for ensuring scalability and high availability. The use of separate databases (MySQL
and MongoDB
) reflects the polyglot persistence approach, where each microservice can choose the most appropriate database technology.
The architecture comprises the following key components:
- account-service:
- Manages customer account data stored in a MySQL database;
- Provides RESTful APIs for account creation, retrieval, and validation;
- Operates with redundancy across ports 8000 and 8001.
- transaction-service:
- Handles bank transactions, storing transaction data in MongoDB;
- Offers APIs for deposits, withdrawals, and inter-account transfers;
- Utilises OpenFeign to communicate with the Account Service for account validation;
- Operates with redundancy across ports 8080 and 8081.
- discovery-service:
- Uses Netflix Eureka to enable service registration and discovery;
- Facilitates dynamic service location and load balancing;
- Operates on port 8761.
- api-gateway:
- Acts as a single entry point for client requests;
- Routes requests to the appropriate microservices;
- Operates on port 8765.
- load-balancing:
- Distributes incoming traffic across multiple instances of the Account and Transaction services to enhance performance and availability.
- Client Apps:
- Represents client devices (e.g., desktops, mobile phones) that interact with the system via the API Gateway.
Technology | Version | Description |
---|---|---|
π IntelliJ IDEA | 2024.3 |
Integrated Development Environment (IDE) |
β Java | 21 |
Backend programming language |
π± Spring Boot | 3.4.3 |
Framework for creating Spring applications |
π¦ Maven | 3.9.9 |
Build automation and dependency management tool |
π¬ MySQL | 9.2.0 |
Open-source relational database management system |
π MongoDB | 8.0 |
NoSQL document-oriented database |
βοΈ Spring Cloud | 2024.0.0 |
Framework for building cloud-native applications |
π§ Netflix Eureka | 3.0.0 |
Service registry and discovery server |
π OpenFeign | 4.2.0 |
Declarative REST client |
π Resilience4j | 2.3.0 |
Fault tolerance library for microservices |
π©βπ Postman | 11.19 |
API testing and development tool |
Dependency | Category | Description |
---|---|---|
π Spring Web | Web | Build web, including RESTful, applications using Spring MVC |
πΎ Spring Data JPA | SQL | Simplifies database interactions using JPA with Spring Data and Hibernate |
π MySQL Driver | SQL | Provides connectivity between Java applications and MySQL databases |
π Spring Data MongoDB | NoSQL | Provides integration with MongoDB, allowing data access in a reactive or blocking way |
πΆοΈ Lombok | Developer Tools | A Java annotation library that minimises boilerplate code |
π OpenFeign | Cloud | Simplifies HTTP API client creation with declarative REST clients |
π§ Netflix Eureka Server | Cloud | Provides a service registry for microservices architecture using Eureka Server |
βοΈ Load Balancer | Cloud | Provides client-side load balancing |
πͺ Gateway | Cloud | Provides a library for building API Gateways on top of Spring WebFlux |
πΊοΈ ModelMapper | Utility | A library that simplifies object mapping by automatically mapping properties between objects |
π Resilience4j | Fault Tolerance | Provides circuit breakers, rate limiters, retries, and bulkheads for microservices |
βΆ Actuator | Monitoring | Provides production-ready features for monitoring and managing applications |
π AOP | Aspect-Oriented | Enables aspect-oriented programming with Spring AOP and AspectJ |
ποΈ dotenv-java | Configuration | Loads environment variables from a .env file, aiding secure configuration management |
- 1.0 Introduction;
- 1.1 Tools;
- 1.2 Monolithic Architecture;
- 1.3 Microservices Architecture.
- 2.1 Monolithic Architecture;
- 2.2 Microservice Architecture.
(Microservice 1 - Bank Account)
- 3.1 IDE Configuration;
- 3.2 Project Creation;
- 3.3 Structuring and Entity;
- 3.4 Customer Repository;
- 3.5 Customer Service;
- 3.6 Customer Controller;
- 3.7 Standardising Responses;
- 3.8 Automatic Account Number Generator;
- 3.9 Retrieving All User Accounts;
- 3.10 Account Validation;
- 3.11 Custom Exception;
- 3.12 Configuring Redundancy for the Microservice.
(Microservice 2 - Bank Transactions)
- 4.1 Microservice Creation and Structuring;
- 4.2 MongoDB Configuration and Entities;
- 4.3 Repositories;
- 4.4 Transaction Controller;
- 4.5 Transaction Service;
- 4.6 Using OpenFeign to Validate Customer Account;
- 4.7 Custom Exception for Account Validation;
- 4.8 Calculating Account Balance;
- 4.9 Implementing Account Statement;
- 4.10 Transfer Controller;
- 4.11 Inter-Account Transfer;
- 4.12 Transfer Statement Business Logic;
- 4.13 Statement for Destination Account;
- 4.14 Retrieving All Account Transfers.
- 5.1 Introduction to Discovery Service;
- 5.2 Implementing Discovery Service and Registering Microservices;
- 5.3 Load Balancing.
- 6.1 Introduction to API Gateway;
- 6.2 API Gateway Project Creation and Configuration;
- 6.3 Testing the API Gateway Service;
- 6.4 Configuring Routes.
- 7.1 Retry with Resilience4j;
- 7.2 Retry Attempts;
- 7.3 Fallback Method - Custom Exception;
- 7.4 Wait Duration.