Local Bank service asynchronously synchronizes the Third-Party Provider to retrieve the user transactions. To get the data in an asynchronous manner, both services use notification service as their communication channel. API Gateway is a mechanism for providing an entry point on both Local Bank and TPP Transaction services. Bank Transactions API built following the Test-Driven Approach.
We have included the following concepts/guidelines on the multiple service based Bank Transactions API:
- Asynchronous communcation: services communicate in an asynchronous manner using AMQP protocol to exchange messages via a message broker (RabbitMQ).
- API gateway: a mechanism for providing an entry point for clients.
- DevOps: a mechanism for handling continuous integration (CI)
- Loose coupling: services are independent of each other, one can update and deploy each service without affecting the others.
- Single responsibility: each service does only one thing.
- Standard/Synchronous communication: services communicate with each other through rest APIs
Following instructions will get you a copy of the project up and running on your local machine for the development and testing purposes.
There are two ways of running the project in your local machine.
- Using yarn as a package manager:
- Install local Node.js environment
- Install Package manager to manage packages yarn
- Install local db MongoDB
- Using docker-compose for running a multi-container Docker apps:
- Install docker engine considering your distro
- Install docker-compose
.env
file in the root of the project need to be created and variables should be inserted as a key/value pairs in the following format of KEY=VALUE
:
# move into the root project folder
cd bank-transactions-api
# rename the .env.sample
mv .env.example .env
Project can be executed in the following two ways:
1. Using yarn
Scripts for Installation, development and testing purposes
# move into the root project folder and go for the specific service
cd bank-transactions-api/services/local-bank
# Install the necessary packages for the specific service
yarn install
# Run the service in development mode
yarn run dev
# Run the service in production mode
yarn run start
# Run test cases
yarn run test
# Collect test coverage
yarn run coverage
2. Using docker and docker-compose
Commands for running and getting the details of the services.
# Build and run the services
docker-compose up -d --build
# List containers
docker ps
# Get logs
docker-compose logs
There are two ways of running the tests on your local machine.
- To run each microservice tests one by one, go to the respective service directory where the package.json is located and run tests.
For example: to run the tests for the banking-service
cd banking-service yarn test
- To run all tests for the entire microservices, execute a file 'run_all_tests' which is included test running scripts that has been created in the root directory.
# run the test cases
./run_all_tests
NOTE: If there is
sudo: ./run_all_tests: command not found
notification then make sure that you have set necessary executable permission of a file on your local machine. To do that:
# set file execute permission
chmod +x run_all_tests
# run the test cases
./run_all_tests
Available endpoints for services and their functions included in the Documentation folder. They can be tested using their belonging Postman Collections. Postman Collection - Local bank OR Postman Collection - TPP Transaction
- Express.js - The Node.js web application framework
- Mongoose - MongoDB ODM
- Amqplib - An AMQP 0-9-1 (RabbitMQ) library.
- Axios - Promise based HTTP client for the server
- Nodemailer - Send e-mails from Node.js
- Swagger-ui-express - Library to serve auto-generated swagger-ui generated API
- Winston - Logging Library
- Jest - Testing framework
- Supertest - HTTP assertions
Distributed under the MIT License. See LICENSE
for more information.