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
withsqlc
to generate Go type-safe code from SQL, andmigrate
to write migration scripts for migration up and down. - Web Framework:
Gin
for HTTP server and routing. - Authentication: Implements
JWT
andPaseto
tokens. - gRPC: For efficient communication, includes an
HTTP Gateway for gRPC endpoints
. - Asynchronous Tasks: Implements workers using
Asynq
withRedis
for background job processing. - Testing: Implements
gomock
to test gRPC, HTTP APIs, and functions.
-
Clone the repository:
git clone https://github.com/NguyenHiu/simple-bank cd simple_bank
-
Setup environment variables:
Create a
.env
file based on the providedapp.env
file and update the values as needed. -
Run database migrations:
make migrateup
-
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.
To run the tests, use the following command:
make test
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,