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:
Postgresqlwithsqlcto generate Go type-safe code from SQL, andmigrateto write migration scripts for migration up and down. - Web Framework:
Ginfor HTTP server and routing. - Authentication: Implements
JWTandPasetotokens. - gRPC: For efficient communication, includes an
HTTP Gateway for gRPC endpoints. - Asynchronous Tasks: Implements workers using
AsynqwithRedisfor background job processing. - Testing: Implements
gomockto 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
.envfile based on the providedapp.envfile 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.gofile to use the HTTP server with Gin if you prefer.
To run the tests, use the following command:
make testThere 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,