{"id":15096119,"url":"https://github.com/bruce-mig/simple-bank","last_synced_at":"2026-01-07T11:16:32.215Z","repository":{"id":211049083,"uuid":"728054042","full_name":"bruce-mig/simple-bank","owner":"bruce-mig","description":"a  bank service in Go using gRPC, protobuf, asynq redis message broker, gin, docker and k8s","archived":false,"fork":false,"pushed_at":"2024-03-04T05:37:45.000Z","size":6991,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-01T17:44:20.326Z","etag":null,"topics":["asynq","backend","ci-cd","docker","gin","go","golang","grpc","grpc-go","http-server","kubernetes","message-queue","redis"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bruce-mig.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-12-06T06:04:23.000Z","updated_at":"2024-12-29T17:57:03.000Z","dependencies_parsed_at":"2024-06-20T20:27:40.214Z","dependency_job_id":null,"html_url":"https://github.com/bruce-mig/simple-bank","commit_stats":null,"previous_names":["bruce-mig/simple-bank"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bruce-mig%2Fsimple-bank","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bruce-mig%2Fsimple-bank/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bruce-mig%2Fsimple-bank/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bruce-mig%2Fsimple-bank/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bruce-mig","download_url":"https://codeload.github.com/bruce-mig/simple-bank/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245852887,"owners_count":20683113,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asynq","backend","ci-cd","docker","gin","go","golang","grpc","grpc-go","http-server","kubernetes","message-queue","redis"],"created_at":"2024-09-25T15:45:41.730Z","updated_at":"2026-01-07T11:16:32.169Z","avatar_url":"https://github.com/bruce-mig.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simple bank service\n\nThe service provides APIs for the frontend to do following things:\n\n1. Create and manage bank accounts, which are composed of owner’s name, balance, and currency.\n2. 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.\n3. 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.\n\n## Setup local development\n\n### Install tools\n\n- [Docker desktop](https://www.docker.com/products/docker-desktop)\n- [TablePlus](https://tableplus.com/)\n- [Golang](https://golang.org/)\n- [Homebrew](https://brew.sh/)\n- [Migrate](https://github.com/golang-migrate/migrate/tree/master/cmd/migrate)\n\n    ```bash\n    brew install golang-migrate\n    ```\n\n- [DB Docs](https://dbdocs.io/docs)\n\n    ```bash\n    npm install -g dbdocs\n    dbdocs login\n    ```\n\n- [DBML CLI](https://www.dbml.org/cli/#installation)\n\n    ```bash\n    npm install -g @dbml/cli\n    dbml2sql --version\n    ```\n\n- [Sqlc](https://github.com/kyleconroy/sqlc#installation)\n\n    ```bash\n    brew install sqlc\n    ```\n\n- [Gomock](https://github.com/golang/mock)\n\n    ``` bash\n    go install github.com/golang/mock/mockgen@v1.6.0\n    ```\n\n### Setup infrastructure\n\n- Create the bank-network\n\n    ``` bash\n    make network\n    ```\n\n- Start postgres container:\n\n    ```bash\n    make postgres\n    ```\n\n- Create simple_bank database:\n\n    ```bash\n    make createdb\n    ```\n\n- Run db migration up all versions:\n\n    ```bash\n    make migrateup\n    ```\n\n- Run db migration up 1 version:\n\n    ```bash\n    make migrateup1\n    ```\n\n- Run db migration down all versions:\n\n    ```bash\n    make migratedown\n    ```\n\n- Run db migration down 1 version:\n\n    ```bash\n    make migratedown1\n    ```\n\n### Documentation\n\n- Generate DB documentation:\n\n    ```bash\n    make db_docs\n    ```\n\n- Access the DB documentation at [this address](https://dbdocs.io/bmigeri/simple_bank). Password: `secret`\n\n### How to generate code\n\n- Generate schema SQL file with DBML:\n\n    ```bash\n    make db_schema\n    ```\n\n- Generate SQL CRUD with sqlc:\n\n    ```bash\n    make sqlc\n    ```\n\n- Generate DB mock with gomock:\n\n    ```bash\n    make mock\n    ```\n\n- Create a new db migration:\n\n    ```bash\n    make new_migration name=\u003cmigration_name\u003e\n    ```\n\n### How to run\n\n- Run server:\n\n    ```bash\n    make server\n    ```\n\n- Run test:\n\n    ```bash\n    make test\n    ```\n\n## Deploy to minikube kubernetes cluster\n\n- Start minikube:\n\n    Minikube and kubectl must be installed as prerequisites.\n    Then start minikube\n\n    ```bash\n    minikube start\n    ```\n    To view minikube dashboard, use the command `minikube dashboard` or use k9s with the command `k9s`.\n\n- Pod deployments:\n\n     Use the command `kubectl apply -f \u003cfile-name\u003e.yml`\n\n- Running Postgres and Redis on the host machine:\n\n    To spin up database on local machine, run the following command\n\n    ```bash\n    docker-compose -f database.yml up -d\n    ```\n\n    To connect to database from  minikube, change the host from localhost to `host.minikube.internal` in the deployment.yaml file.\n\n- [Install nginx ingress controller](https://kubernetes.github.io/ingress-nginx/deploy/#minikube):\n\n    Enable ingress add-ons\n    ```bash\n    minikube addons enable ingress\n    minikube addons enable ingress-dns\n    ```\n    Apply ingress\n    ```bash\n    kubectl apply -f k8s/ingress-nginx.yaml\n    kubectl apply -f k8s/ingress-http.yaml\n    kubectl apply -f k8s/ingress-grpc.yaml\n    kubectl get ingress\n    ```\n\n- Configure ingress:\n    \n    Add ingress host to /etc/hosts as follows\n\n    ```bash\n    sudo vi /etc/hosts\n    ```\n    Append to the file \n    ```bash\n    127.0.0.1       api.simplebank.test\n    127.0.0.1       gapi.simplebank.test\n    ```\n\n    Create a minikube tunnel\n\n    ```bash\n    minikube tunnel\n    ```\n\n    The app is now available at `http://api.simplebank.test` in the browser.\n\n    Test ingress by running \n    \n    ```bash\n    nslookup simplebank.test\n    ```\n\n- [Install cert-manager](https://cert-manager.io/docs/installation/kubernetes/):\n\n    ```bash\n    kubectl apply -f https://github.com/jetstack/cert-manager/releases/download/v1.4.0/cert-manager.yaml\n    ```\n\n## Deploy to kubernetes cluster\n\n- [Install nginx ingress controller](https://kubernetes.github.io/ingress-nginx/deploy/#aws):\n\n    ```bash\n    kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v0.48.1/deploy/static/provider/aws/deploy.yaml\n    ```\n\n- [Install cert-manager](https://cert-manager.io/docs/installation/kubernetes/):\n\n    ```bash\n    kubectl apply -f https://github.com/jetstack/cert-manager/releases/download/v1.4.0/cert-manager.yaml\n    ```\n\n### Setup gRPC\n\n- Generate files\n\n    NOTE: You should add the `protoc-gen-go-grpc` to your PATH\n\n    ```bash\n    PATH=\"${PATH}:${HOME}/go/bin\"\n    ```\n\n    ```bash\n    make proto\n    ```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbruce-mig%2Fsimple-bank","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbruce-mig%2Fsimple-bank","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbruce-mig%2Fsimple-bank/lists"}