skamranahmed / banking-system

🏦 A backend API to imitate how a bank transfer transaction takes place.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

🏦 Banking System

  • A backend API to imitate how a bank transfer transaction takes place

  • Handled data inconsistency and potential deadlocks for concurrent transactions

Features

  • Create and manage account

    • Owner, balance and currency
  • Record all balance changes

    • Create an account entry for each change
  • Money transfer transaction

    • Perform money transaction between 2 accounts consistently within a transaction

DB Schema

Banking-System

πŸƒβ€β™‚οΈ Setup & How to Run

Using docker-compose

  • Start the services
make dc-up
  • Stop the servcies
make dc-down

Using Docker (a bit more manual work)

  • Clone the repository
git clone https://github.com/skamranahmed/banking-system.git
  • Create a banking-system-network in Docker
make create-bank-network
  • Setup Postgres via Docker
make setup-postgres
  • Create bank db and bank_test db in Postgres
make create-db
  • Download the project dependencies via the below command
make download
  • Migrate the DB Schema using the SQL Script For this I have used the golang-migrate library. You will first have to install this package.

For MacOS

brew install golang-migrate

For other OS or kernels, refer this: https://github.com/golang-migrate/migrate/tree/master/cmd/migrate

Once the installation is done, run the below commands:

  1. To migrate the database schema for the bank db:
make migrate-up
  1. To migrate the database schema for the bank_test db:
make migrate-up-test
  • Configuring the environment variables

Make sure you are in the banking-system root directory.

cp config/localConfigSample.yaml config/localConfig.yaml
  • Run the server
  1. Non-dockerized:
make run
  1. Dockerized:
  • Build the docker image for the backend service:
make build
  • Run the docker image for the backend service:
make dockerized-server-run

About

🏦 A backend API to imitate how a bank transfer transaction takes place.


Languages

Language:Go 95.4%Language:Makefile 2.2%Language:Dockerfile 1.9%Language:Shell 0.4%Language:PLpgSQL 0.2%