Code Monkey home page Code Monkey logo

bank-accounts-management's Introduction

Bank accounts management

Objective

Your assignment is to build an internal API for a fake financial institution

Brief

While modern banks have evolved to serve a plethora of functions, at their core, banks must provide certain basic features. Today, your task is to build the basic HTTP API for one of those banks! Imagine you are designing a backend API for bank employees. It could ultimately be consumed by multiple frontends (web, iOS, Android etc).

Tasks

  • Design DB.
  • Implement class diagram.
  • There should be API routes that allow them to:
    • Create a new bank account for a customer, with an initial deposit amount. A single customer may have multiple bank accounts.
    • Transfer amounts between any two accounts, including those owned by different customers.
    • Retrieve balances for a given account.
    • Retrieve transfer history for a given account.

How to set up & run this project?

In this project, we will use docker for the development process. In particular, Laravel has a package that helps us to easily manage and set it up. And it's name is Sail.

  • Install docker
  • Copy .env.example to .env and start filling in the values.
      cp .env.example .env
  • Run below commands:
      docker-compose up -d
      docker-compose run laravel.test composer install
      ./vendor/bin/sail up --build
      ./vendor/bin/sail php artisan key:generate
      ./vendor/bin/sail php artisan migrate
      ./vendor/bin/sail php artisan db:seed

DB Diagram

DB Diagram

Endpoints

  GET|HEAD   api/bank_accounts/{accountId}/balance .................................... BankAccountController@balances
  GET|HEAD   api/bank_accounts/{accountId}/transaction_history ......................... BankAccountController@history
  POST       api/banks/transfer .............................................................. BankController@transfer
  POST       api/customers/{customerId}/bank_accounts ................................... BankAccountController@create

Class Diagram

classDiagram
  direction BT
	class BankAccountController {
	   __construct(bankAccountService) 
	    bankAccountService
	   balance(request, accountId) 
	   history(request, accountId) 
	   create(request, customerId) 
	}
	
	class BankController {
	   __construct(bankService) 
	    bankService
	   transfer(request) 
	}
	
	class Controller
	
	BankAccountController  -->  Controller 
	BankController  -->  Controller 
	
	  direction B	
	class BankAccountService {
	   __construct(bankAccountRepository, transactionRepository) 
	   getAllTransactionsByAccount(accountId) 
	   getBalance(accountId) 
	   createBankAccountForCustomer(customerId, body) 
	   getBankAccount(accountId) 
	}
	class BankAccountServiceInterface {
	   getAllTransactionsByAccount(accountId) 
	   createBankAccountForCustomer(customerId, body) 
	   getBalance(accountId) 
	   getBankAccount(accountId) 
	}
	
	BankAccountService  ..>  BankAccountServiceInterface 
	
	class BankService {
	   __construct(bankAccountRepository, transactionRepository) 
	   transfer(from, to, amount) 
	}
	class BankServiceInterface {
	   transfer(from, to, amount) 
	}
	
	BankService  ..>  BankServiceInterface 
	
	class BankAccountRepository {
	   __construct(model) 
	   getBankAccountsIn(accountNumberList) 
	   get(accountId) 
	   create(customerId, payload) 
	}
	class BankAccountRepositoryInterface {
	   getBankAccountsIn(accountNumberList) 
	   get(accountId) 
	   create(customerId, payload) 
	}
	
	BankAccountRepository  ..>  BankAccountRepositoryInterface 
	
class TransactionRepository {
   __construct(transactionModel, transactionDetailModel) 
   getAllTransactionDetailByAccount(accountNumber) 
   createTransaction(from, to, amount) 
}
class TransactionRepositoryInterface {
   getAllTransactionDetailByAccount(accountNumber) 
   createTransaction(from, to, amount) 
}

TransactionRepository  ..>  TransactionRepositoryInterface 

Postman Collection

Reference sources

Contact

bank-accounts-management's People

Contributors

dangnghia1997 avatar

Watchers

 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.