bank-API-golang

command module
v0.0.0-...-e81f0dd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 30, 2023 License: MIT Imports: 23 Imported by: 0

README

Bank Service

Bank is a backend service that provides gRPC APIs to the frontend, facilitating the following functionalities:

  1. Create and Manage Bank Accounts: Users can create bank accounts with details including owner’s name, balance, and currency.
  2. Record Balance Changes: The service records every transaction that results in a balance change, creating an account entry record for each such instance.
  3. Money Transfer: Enables users to perform money transfers between two accounts within a transaction, ensuring that either both accounts’ balances are updated successfully, or none of them are.
  4. User Authentication: Authenticates users and ensures that they can only access and manage their own accounts.
  5. Role-based Functionality: The service includes role-based access control, with specific roles such as "banker" and "depositor". There are several ways to create a banker user. You can create the first banker user either via a DB migration, or a script that runs on the production server. Once the first banker user is created, they can access an API that allows them to create other banker users.
Used Technologies

The project utilizes the following technologies:

  • Golang
  • gRPC
  • PostgreSQL
  • Redis
  • SQLC
  • Asynq

Setup Local Development

Install Tools
  • Docker Desktop: Installation Guide
  • TablePlus: Installation Guide
  • Golang: Installation Guide
  • Migrate:
    sudo install golang-migrate
    
  • DB Docs:
    npm install -g dbdocs
    dbdocs login
    
  • DBML CLI:
    npm install -g @dbml/cli
    dbml2sql --version
    
  • Sqlc:
    brew install sqlc
    
  • Gomock:
    go install github.com/golang/mock/mockgen@v1.6.0
    
Setup Infrastructure
  • Create Bank Network:
    make network
    
  • Start Postgres Container:
    make postgres
    
  • Create Bank Database:
    make createdb
    
  • Run Database Migrations:
    make migrateup
    make migratedown
    
Documentation
  • Generate DB documentation:
    make db_docs
    
  • Access the DB documentation at Swagger Hub or at localhost:8080/swagger when you run the app locally.
Code Generation
  • 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:
    make new_migration name=<migration_name>
    
How to Run
  • Run Server:
    make server
    

Alternatively, if you have Docker installed on your local machine, you can simply run:

docker compose up
  • Run Tests:
    make test
    

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
db
mock
Package mockdb is a generated GoMock package.
Package mockdb is a generated GoMock package.
doc
Package pb is a reverse proxy.
Package pb is a reverse proxy.
mock
Package mockwk is a generated GoMock package.
Package mockwk is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL