A Simple Bank
π¬ About
This project was developed following Udemy's "Backend Master Class [Golang + Postgres + Kubernetes + gRPC]" class.
The project is a simple bank system that allows you to create accounts, deposit and withdraw money, and transfer money between accounts.
Notes taken during the course are in the notes file.
π» Technologies
(back to top)
π Requirements
(back to top)
πΏ Installation
git clone git@github.com:filipe1309/ud-bmc-simplebank.git
cd ud-bmc-simplebank
If you don't want to use docker, you can install the project dependencies and create the database with:
make install
This will run the commands: make createdb
and make migrateup
.
This will install the project dependencies and create the database.
The database will be available at localhost:5432
with:
- user:
root
- password:
secret
- database:
simple_bank
(back to top)
π Running
With docker:
make run
Without docker:
make server
This will run:
HTTP server at localhost:8080
gRPC server at localhost:9090
database at localhost:5432
redis at localhost:6379
(back to top)
π Usage
defined in main.go
API - Gin
API |
Name |
Rule |
POST /users/login |
Login |
A user can log in with email and password |
POST /tokens/renew-access-token |
Renew access token |
A user can renew his/her access token with a valid refresh token |
POST /users |
Create a new user |
A user can create a new user |
POST /accounts |
Create a new account |
A logged user can only create an account for himself/herself |
GET /accounts/:id |
Get an account by id |
A logged user can only get accounts that belong to himself/herself |
GET /accounts |
List accounts |
A logged user can only list accounts that belong to himself/herself |
POST /transfers |
Create a new transfer |
A logged user can only send money from his/her account |
Examples of the API requests are in the api file.
Docs http://localhost:8080/swagger/
API - gRPC Gateway
API |
Name |
Rule |
POST /v1/login_user |
Login |
A user can log in with email and password |
POST /v1/create_user |
Create a new user |
A user can create a new user |
POST /v1/update_user |
Update a user |
A logged user can only update his/her own user, username is required and other fields are optional |
Examples of the API requests are in the api_grpc_gateway file.
Docs http://localhost:8080/swagger/
gRPC
gRPC |
Name |
Rule |
LoginUser |
Login |
A user can log in with email and password |
CreateUser |
Create a new user |
A user can create a new user |
UpdateUser |
Update a user |
A logged user can only update his/her own user, username is required and other fields are optional |
Example with Evans REPL:
make evans
> call LoginUser
# {
# "username": "johndoe5",
# "password": "secret"
# }
> call CreateUser
# {
# "username": "johndoe5",
# "full_name": "John Doe Five",
# "email": "john.doe5@email.com",
# "password": "secret"
# }
> call UpdateUser
# {
# "username": "johndoe5", # required
# "full_name": "New John Doe Five",
# "email": "john.doe5@email.com",
# "password": "secret"
# }
# OR
# {
# "username": "johndoe5",
# "full_name": "New John Doe Five"
# }
(back to top)
β
Tests
make test
(back to top)
π License
MIT
(back to top)
π§ββοΈ About Me
(back to top)
Done withΒ Β β₯οΈΒ Β by Filipe Leuch Bonfim π
π Acknowledgments
(back to top)