Giter VIP home page Giter VIP logo

balance-controller's Introduction

Grover monetary transaction

Table of Contents

Overview

Grover monetary transaction provides a bunch of REST APIs to simulate a monetary transaction for the given user. It provides following list of APIs


Provided 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]


Code architecture

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.


source code

tar -xvf monetary-transaction.tar

cd monetary-transaction

Service build information

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.

Regular user

npm install
npm run build
npm run test:ci
npm start:{dev || debug || prod}

Advanced user

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.

Deployment

Helm

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

Kubernetes manifests

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

Monitoring and alerting

Health check

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

OpenApi

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

Documentation

By running following comman you can generate the full code documentation (Compodoc) and get access to it through port 7000

npm run doc

http://localhost:7000

ToDo list

  • 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

balance-controller's People

Contributors

moeidheidari avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.