Skip to content

a go/docker/postgres project to implement a simple bank functions

Notifications You must be signed in to change notification settings

cyberpunk-admin/simple_bank

Repository files navigation

Simple Bank

a project to implement a simple bank server

Swagger API Doc

It will provide APIs for the frontend to do following things:

  • Create and manage bank accounts, which are composed of owner’s name, balance, and currency.
  • 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.
  • 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 tool

  • Docker
    sudo apt-get update sudo apt-get install docker-ce docker-ce-cli containerd.io
  • TablePuls
  • Migrate
    curl -L https://github.com/golang-migrate/migrate/releases/download/$version/migrate.$platform-amd64.tar.gz | tar xvz
  • Sqlc
    go install github.com/kyleconroy/sqlc/cmd/sqlc@latest
  • Gomock
    go install github.com/golang/mock/[email protected]  
  • Viper
    go get github.com/spf13/viper

Setup infrastructure

  • Build docker compose
    reference docker-compose
    
  • Unit test with GitHub Action
    reference .github/workflow test.yml
    
    • Push image to Alibaba Cloud Container Registry
    reference .GitHub/workflow deploy.yml
    

How to generate code

  • Generate schema SQL file with DBML:
    make db_schema`
  • Generate SQL CRUD with sqlc:
    make sqlc
  • Generate DB mock with gomock:
    make mock
  • Create a new db migration:
    migrate create -ext sql -dir db/migration -seq <migration_name>  

How to run

  • Run server:
    make server
  • Run test
    make test

About

a go/docker/postgres project to implement a simple bank functions

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published