From 7e7e6a86eda63402f15091b39dd0c606cb3f86f1 Mon Sep 17 00:00:00 2001 From: Viral Parmar Date: Fri, 29 Sep 2023 10:19:07 +0530 Subject: [PATCH] Update README --- README.md | 108 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 106 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1f24d12..113b516 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,109 @@ # Simple Bank -## DB Schema +This repository contains code for a simple bank service written completely in Go, supporting the following operations: -https://dbdiagram.io/d/Simple-Bank-650d067f02bd1c4a5e0e347d +1. Create and manage bank accounts, which are composed of owner’s name, balance, and currency. +2. Record all balance changes to each of the account. So every time some money is added to or subtracted from the account, an account entry record will be created. +3. Perform a money transfer between 2 accounts. This should happen within a transaction, so that either both accounts’ balance are updated successfully or none of them are. + +## Setup local development + +### Install tools + +- [Docker desktop](https://www.docker.com/products/docker-desktop) +- [TablePlus](https://tableplus.com/) +- [Golang](https://golang.org/) +- [Homebrew](https://brew.sh/) +- [Migrate](https://github.com/golang-migrate/migrate/tree/master/cmd/migrate) + + ```bash + brew install golang-migrate + ``` + +- [Sqlc](https://github.com/kyleconroy/sqlc#installation) + + ```bash + brew install sqlc + ``` + +- [Gomock](https://github.com/golang/mock) + + ```bash + go install github.com/golang/mock/mockgen@v1.6.0 + ``` + +### Setup infrastructure + +- Start postgres container: + + ```bash + make postgres + ``` + +- Create simple_bank database: + + ```bash + make createdb + ``` + +- Run db migration up all versions: + + ```bash + make migrateup + ``` + +- Run db migration up 1 version: + + ```bash + make migrateup1 + ``` + +- Run db migration down all versions: + + ```bash + make migratedown + ``` + +- Run db migration down 1 version: + + ```bash + make migratedown1 + ``` + +### Documentation + +- DB Schema: + + https://dbdiagram.io/d/Simple-Bank-650d067f02bd1c4a5e0e347d + +- API Schema: + + https://github.com/viralparmarme/simple-bank/blob/main/postman.json + +### How to generate code + +- Generate SQL CRUD with sqlc: + + ```bash + make sqlc + ``` + +- Generate DB mock with gomock: + + ```bash + make mock + ``` + +### How to run + +- Run server: + + ```bash + make server + ``` + +- Run test: + + ```bash + make test + ```