Microservices design:
This project uses Backend-for-frontend design pattern - 2 internal backend microservices (account service and transaction debit credit record service) facilitate basic generic functions such as credit, debit and create event records of transaction, credit and debit; 2 fronten BFF does the actual business logic coordination (create transaction by calling debit and credit functions) and data aggregation (balance enquiry through account service's find account by account number).
NOTE: For simplicity, this project uses redis service included by PCF Dev to simulate persistance.
Target development/execution environment:
OS: Windows 10 Professional
IDE: Spring Tool Suite(STS)
Paas: PCF Dev
Storage: Redis from PCF Dev
Config Server: Cloud Foundry Config Server (Spring Cloud Config Server)
Config git: https://github.com/k6leung/CodingChallenge2Config.git
PCF Domain: local.pcfdev.io
Primary libraries:
Spring boot, Spring MVC, Spring Cloud Connector, Spring Data Redis, Cloud Foundry Connector
3rd party libraries:
Apache commons pool2(for redis connection pooling)
Apache httpclient (for PUT requests)
Rest Assured (restful test cases)
How to build:
- In STS, for each "common" projects (BFF common, NoSecurityCommon, RedisStorageCommon and RestfulCommon), right click the project->run as->maven install
- Maven install the microservice projects (AccountService, BalanceEnquiryBFF, TransactionBFF and TransactionDebitCreditRecordService)
How to deploy:
- In cf CLI, run the following commands to create required pcf services:
cf create-service p-redis shared-vm accountRedis
cf create-service p-redis shared-vm transactionRedis
cf create-service p-config-server standard configServer -c "{"git":{"uri":"https://github.com/k6leung/CodingChallenge2Config.git\",\"cloneOnStart\": true,"searchPaths":["CodingChallenge2Config/BalanceEnquiryBFF","CodingChallenge2Config/TransactionBFF"]}}" - After services being created successfully, for each of the microservice projects (AccountService, BalanceEnquiryBFF, TransactionBFF and TransactionDebitCreditRecordService),
go to its root, run the following command:
cf push -f manifest.yml -t 180
How to run test case:
- After complete deploying all 4 microservices, in STS, right click the test case project (RestTestCases), run as-> Junit Test
Swagger API Specifications:
- https://github.com/k6leung/CodingChallenge2/blob/master/AccountService/openapi.yml
- https://github.com/k6leung/CodingChallenge2/blob/master/BalanceEnquiryBFF/openapi.yml
- https://github.com/k6leung/CodingChallenge2/blob/master/TransactionBFF/openapi.yml
- https://github.com/k6leung/CodingChallenge2/blob/master/TransactionDebitCreditRecordService/openapi.yml