Skip to content

Simple Bank is a learning project that includes several features such as Postgres, Sqlc, Gin, JWT/Paseto tokens, gRPC, gomock, Asyncq, and Redis

Notifications You must be signed in to change notification settings

NguyenHiu/Simple-Bank

Repository files navigation

Simple Bank

Description

Welcome to Simple Bank! Simple Bank is a backend service for managing bank accounts, users, and transactions. It includes features such as user registration, login, account management, and money transfers.

This repository is a learning project and includes several features:

  • Database: Postgresql with sqlc to generate Go type-safe code from SQL, and migrate to write migration scripts for migration up and down.
  • Web Framework: Gin for HTTP server and routing.
  • Authentication: Implements JWT and Paseto tokens.
  • gRPC: For efficient communication, includes an HTTP Gateway for gRPC endpoints.
  • Asynchronous Tasks: Implements workers using Asynq with Redis for background job processing.
  • Testing: Implements gomock to test gRPC, HTTP APIs, and functions.

Setup

  1. Clone the repository:

    git clone https://github.com/NguyenHiu/simple-bank
    cd simple_bank
  2. Setup environment variables:

    Create a .env file based on the provided app.env file and update the values as needed.

  3. Run database migrations:

    make migrateup
  4. Start the server:

    make server

    Note: The current code runs the gRPC and HTTP Gateway by default. Change the main.go file to use the HTTP server with Gin if you prefer.

Running Tests

To run the tests, use the following command:

make test

Endpoints

There are 2 Swagger files in the doc/swagger folder. One is gin_swagger.json for the HTTP Server with Gin, and the other is gateway_swagger.json for the HTTP Gateway from the gRPC Server. Give them a try if you want to interact with Simple Bank.

For gRPC methods, you can check the proto folder for more details about the request arguments and responses. However, common gRPC clients have a method to query all the methods and their request arguments at a specific gRPC server. Example,

About

Simple Bank is a learning project that includes several features such as Postgres, Sqlc, Gin, JWT/Paseto tokens, gRPC, gomock, Asyncq, and Redis

Resources

Stars

Watchers

Forks

Languages