{"id":23228475,"url":"https://github.com/samirprakash/go-bank","last_synced_at":"2025-06-22T16:40:39.430Z","repository":{"id":52065306,"uuid":"331424191","full_name":"samirprakash/go-bank","owner":"samirprakash","description":"Backend system for a simple banking application developed to be used as a boilerplate for best practices around developing and working with golang based API's, GORM with SQLC and PostgresSQL as a database.","archived":false,"fork":false,"pushed_at":"2023-05-03T04:56:20.000Z","size":108,"stargazers_count":40,"open_issues_count":0,"forks_count":11,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-21T09:05:11.982Z","etag":null,"topics":["api","ci","github-actions","golang","golang-migrate","gorm","postgresql","rest-api"],"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/samirprakash.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":"2021-01-20T20:30:51.000Z","updated_at":"2025-04-12T02:22:07.000Z","dependencies_parsed_at":"2024-06-19T03:21:55.468Z","dependency_job_id":null,"html_url":"https://github.com/samirprakash/go-bank","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/samirprakash/go-bank","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samirprakash%2Fgo-bank","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samirprakash%2Fgo-bank/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samirprakash%2Fgo-bank/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samirprakash%2Fgo-bank/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/samirprakash","download_url":"https://codeload.github.com/samirprakash/go-bank/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samirprakash%2Fgo-bank/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261328094,"owners_count":23142444,"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":["api","ci","github-actions","golang","golang-migrate","gorm","postgresql","rest-api"],"created_at":"2024-12-19T01:13:50.962Z","updated_at":"2025-06-22T16:40:34.417Z","avatar_url":"https://github.com/samirprakash.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# A Simple Bank\n\n![ci-test](https://github.com/samirprakash/go-bank/workflows/ci-test/badge.svg?branch=main)\n\n### Features\n\n- Create and manage account\n  - Owner\n  - Balance\n  - Currency\n- Record all balance changes for each account\n  - Create an account entry for each change for each account\n- Money transfer transaction\n  - Perform money transfer between 2 accounts consistently within a transaction\n\n### Pre-requisites\n\n- Install `docker for desktop`\n- Execute `brew install golang-migrate sqlc`\n- Execute `go install github.com/golang/mock/mockgen@v1.6.0`\n\n### Database Design\n\n- Design DB schema using dbdiagram.io\n  - Export the queries onto `/dbdiagrams.io`\n- Save and share DB diagram within the team\n- Generate SQL code to create database in a target database engine i.e. postgres/MySQL/SQLServer\n\n### Docker and Postgres\n\n- Execute `docker pull postgres:12-alpine` to get the postgres image\n- Execute `docker run --name postgres12 -p 5432:5432 -e POSTGRES_USER=root -e POSTGRES_PASSWORD=secret -d postgres:12-alpine` to run the postgres container\n- Execute `docker logs postgres12` to see the logs\n- Execute `docker exec -it postgres12 psql -U root` to connect to the postgres container and login as `root` user\n- Connect to postgres container and execute the queries from `/dbdiagrams.io` to create the tables\n\n### DB migration\n\n- Execute `migrate -version` to verify that the `golang-migrate` has been installed\n- Execute `migrate create -ext sql -dir db/migration -seq init_schema` to generate migration files\n  - `*.up.sql` is used to migrate up to a new version using `migrate up`\n  - `*.down.sql` is used to migrate down to an older version using `migrate down`\n  - Copy the sql quesries generated from `dbdiagram.io` to `*.up.sql`\n  - Add `DROP TABLE` queries to `*.down.sql`\n- Execute `make migrateup` to migrate data upwards to a new version\n- Execute `make migratedown` to revert migration to a previous version\n- Manage migrations in future with `migrtion up/down` commands\n\n### DB and Docker Setup for development\n\n- Execute `make postgres` to run postgres container on local docker setup\n- Execute `make createdb` to create the `simple_bank` database\n- Execute `make migrateup` to setup tables and initial database state\n- If required,\n  - Execute `make dropdb` to drop database\n  - Execute `make migratedown` to migrate or revert database state to a previous version\n\n### Generate CRUD Golang code from SQL\n\n- Execute `make sqlc` to auto generate CRUD functionalities\n- Execute `make mock` to generate mock DB\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamirprakash%2Fgo-bank","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsamirprakash%2Fgo-bank","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamirprakash%2Fgo-bank/lists"}