Grover monetary transaction provides a bunch of REST APIs to simulate a monetary transaction for the given user. It provides following list of APIs
-
Create new account (
/api/v1/account
)[POST][GET][PUT][DELETE] -
Deposit money (
/api/v1/balance/deposit
)[POST] -
Widraw money (
/api/v1/balance/widraw
)[POST] -
Show balance(
/api/v1/balance
)[GET]
Onion Architecture
src
├── application
│ ├── controllers
│ └── dtos
├── domain
│ ├── decorators
│ ├── entities
│ ├── enums
│ │ └── httpResponse
│ ├── exceptions
│ ├── guards
│ ├── helpers
│ ├── interceptors
│ ├── interfaces
│ ├── modules
│ │ └── common
│ ├── pipes
│ ├── repositories
│ ├── seeders
│ └── servicecs
│ └── common
└── infrastructure
├── config
└── modules
└── common
Here we have three very main layers
- Application
in this layer we define the actual behavior of our application, thus being responsible for performing interactions among units of the domain layer.
- Domain
this layer represents the business and behavior objects. we define units which play the role of entities and business rules and have a direct relationship to our domain
- Infrastructure
this layer the boundary to whatever is external to our application: the database, email services, queue engines, etc.
tar -xvf monetary-transaction.tar
cd monetary-transaction
There are different stages of building the application for this service. Based on the environment you want to deploy we have different ways to build the application. following information may help with building the service.
npm install
npm run build
npm run test:ci
npm start:{dev || debug || prod}
cd scripts
bash run.sh -h
2022.05.30.14.43
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-buildDocker] [-runDocker] [-runApp] [-runDoc] [-packageHelm]
This script helps you to run the application in different forms. below you can get the full list of available options.
Available options:
-h, --help Print this help and exit
-buildDocker Build the docker image called "grover:latest"
-runDocker Build the docker image and run on local machine
-runApp Run application with npm in usual way for development
-runDoc Generate the code documentation
-packageHelm makes a helm package from the helm chart.
with the following instruction you can install the helm chart on an up and running kubernetes cluster.
cd k8s
helm install {grover-app} {app-0.1.0.tgz} --set service.type=NodePort
Alternativelly you can deploy the application on an up an running kubernetes cluster using provided config files.
cd k8s/configFiles
kubectl apply -f grover-namespace.yaml, grover-configmap.yaml, grover-deployment.yaml, grover-service.yaml
it should give you following output
namespace/grover created
configmap/grover-config created
deployment.apps/grover created
service/grover created
by calling the following endpoint you can make sure that the application is running and listening to your desired port
http://localhost:{port_number}/health
most probably you will get a result back as follow
Example
{"status":"ok","info":{"alive":{"status":"up"}},"error":{},"details":{"alive":{"status":"up"}}}
mertics
to get the default metrics of the application you can use the following endpoint
http://localhost:{port_number}/metrics
by calling the following endpoint you can see the Swagger OpenApi documentation and explore all the available apis and schemas.
http://localhost:{port_number}/api
By running following comman you can generate the full code documentation (Compodoc) and get access to it through port 7000
npm run doc
-
add moneytion from one account to another account
-
apply commision to money transaction
-
apply commision to widraw money
-
apply deposit fee per minute to the balance
-
add counter metric to the apis