{"id":22993492,"url":"https://github.com/umarhadi/bank-server","last_synced_at":"2026-04-11T00:03:42.075Z","repository":{"id":63290116,"uuid":"534076762","full_name":"umarhadi/bank-server","owner":"umarhadi","description":"bank server","archived":false,"fork":false,"pushed_at":"2025-03-26T18:49:56.000Z","size":6605,"stargazers_count":1,"open_issues_count":12,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-27T07:04:12.045Z","etag":null,"topics":["backend","eks","go","grpc","k8s"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/umarhadi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2022-09-08T06:18:19.000Z","updated_at":"2025-02-22T08:27:08.000Z","dependencies_parsed_at":"2024-04-10T06:24:32.010Z","dependency_job_id":"d271c434-37bc-47ff-a3a0-2c8a6e67886e","html_url":"https://github.com/umarhadi/bank-server","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/umarhadi%2Fbank-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/umarhadi%2Fbank-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/umarhadi%2Fbank-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/umarhadi%2Fbank-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/umarhadi","download_url":"https://codeload.github.com/umarhadi/bank-server/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246814399,"owners_count":20838258,"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":["backend","eks","go","grpc","k8s"],"created_at":"2024-12-15T05:13:06.332Z","updated_at":"2025-12-30T22:32:11.560Z","avatar_url":"https://github.com/umarhadi.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bank Server\n\nThis service will provide 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---\n## Demo \nThis project already deployed, you can access Swagger at [https://bank.api.umarhadi.dev/swagger](https://bank.api.umarhadi.dev/swagger).\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 [link](https://dbdocs.io/umarhadi/bank_server).\n### 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    migrate create -ext sql -dir db/migration -seq \u003cmigration_name\u003e\n    ```\n\n### 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 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## Deploy to Fly.io\n\nCheck out the getting started guide [here](https://fly.io/docs/getting-started/) for installing the Fly CLI. Once you have the CLI installed, you can deploy the app with the following command:\n\n- Clone the repo:\n\n    ```bash\n    git clone https://github.com/umarhadi/bank-server.git \u0026\u0026 cd bank-server\n    ```\n\n- Create postgres database:\n\n    ```bash\n    flyctl postgres create\n    ```\n    After that, you will get the database url, save it for later.\n\n- Set environment variable\n\n    - `DB_SOURCE`\n        ```bash\n        flyctl secrets set DB_SOURCE=\"postgres://postgres:db_password@db_host:5432/postgres?sslmode=disable\"\n        ```\n        Replace `db_password` and `db_host` with the actual password and host from the database url. Don't delete `sslmode=disable` part, if you delete it, the app will not be able to connect to the database because connection between the app and the database is not encrypted via fly.io internal network.\n\n    - `TOKEN_SYMMETRIC_KEY`\n        ```bash\n        flyctl secrets set TOKEN_SYMMETRIC_KEY=\"your_token_symmetric_key\"\n        ```\n        Replace `your_token_symmetric_key` with your own 32 symmetric key. You can generate it with this [tool](https://www.browserling.com/tools/random-hex) or \n        ```bash\n        openssl rand -hex 64 | head -c 32\n        ```\n    \n    - Another environment variable\n    \n        You can change the default value of the environment variable in the `fly.toml` file.\n- Deploy the app:\n\n    ```bash\n    flyctl deploy\n    ```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fumarhadi%2Fbank-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fumarhadi%2Fbank-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fumarhadi%2Fbank-server/lists"}