The service that we’re going to build is a simple bank. 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.
-
brew install golang-migrate
-
npm install -g dbdocs dbdocs login
-
npm install -g @dbml/cli dbml2sql --version
-
brew install sqlc
-
go install github.com/golang/mock/[email protected]
-
Create the bank-network
make network
-
Start postgres container:
make postgres
- Start redis container:
make redis
-
Create simple_bank database:
make createdb
-
Run db migration up all versions:
make migrate_up
-
Run db migration up last change version:
make migrate_up_last
-
Run db migration down all versions:
make migrate_down
-
Run db migration down last change version:
make migrate_down_last
- Reset DB to initial state:
make migrate_down make migrate_up
-
Generate DB documentation:
make db_docs
-
Access the DB documentation at this address. Password:
secret
-
Generate schema SQL file with DBML:
make db_schema
-
Generate SQL CRUD with sqlc:
make sqlc
-
Generate DB mock with gomock:
make mock
-
Generate a new db migration up and down files:
make new_migration name=add_role_to_users
-
Generate proto config file and swagger interface:
make proto
-
Run server:
make server
-
Run test:
make test
Start evans cli interface
make evans
List packages
show package
Select a package
package pb
Show services in the package
show service
Connect to service
service SimpleBank
Use the RPC
call CreateUser
-
Install nginx ingress controller:
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v0.48.1/deploy/static/provider/aws/deploy.yaml
-
kubectl apply -f https://github.com/jetstack/cert-manager/releases/download/v1.4.0/cert-manager.yaml