Things learnt during developing this system:
- Design a database scheme and generate postgres SQL code using dbdiagram
- Install docker engine and docker desktop on my machine (Debian 12)
- Use docker to run a PostgreSQL container and run it on port 5432 on host machine
- Using TablePlus to run some SQL and check database information
- Learn to do migration using golang-migrate
- Generate CRUD code using SQLC
- Write unit tests for CRUD operations with the help of Testify
- Implement database transaction following the ACID Property
- Atomicity: Either all operations complete successfully or transaction fails and database is unchanged.
- Consistency: Database state must be valid after transaction.
- Isolation: concurrent transaction must not affect each other.
- Durability: successfully transaction data must be recorded in persistant storage.
- Overcome deadlock by always updating the account with smaller ID first.
- Learnt how to use Github Action to build and test code with CI.
- Implemented REST API Endpoint using Gin Framework, used built-in validator to validate JSON content in request body, query params and uri params.
- Use Golang Viper Library to load config using file/environmental variable
- Use GoMock Library to create a mockdb for API Testing
- Create a custom validator and register it into Gin Framework, currency validator
- Create custom matcher for creating unit test for Create User API Endpoint using GoMock.
- Learn the differences between JWT and PASETO and identify why PASETO is much more secured than using JWT.
- Implement JWT/Paseto Token Maker using JWT and PASETO Library.
- Login API will now create a JWT/Paseto token depending on which TokenMaker is initialised.
- Implement an authentication middleware to authenticate API endpoints.
- Implement unit tests for testing authentication middleware and authenticated API endpoints.
- Create a Dockerfile Image to build and run the app - optimised with only copying the go binary file into the image
- Learn to connect two seperated container using network with command
docker network create networkname
and connect them with commanddocker network connect networkname containername
. You can also connect it when running a container by specifying in the docker run commanddocker run --name containername --network networkname -p 8080:8080 -e GIN_MODE=release -e DB_SOURCE="postgresql://root:password@postgrescontainername:5432/simple_bank?sslmode=disable" simplebank:latest
. By doing so, you don't have to specify the IP of the postgres container, you can just provide the container name. - Learn to use docker composes to spin up multiple containers at the same time (stack) and also modify the startup sequence of each container using wait-for script.
- Learn to setup a user/group in AWS and configure github actions to build and push docker images to AWS ECR (Elastic Container Registry)