Description
In this course, you will learn:
- DBML is used to create database schema and then automatically produce SQL code from it.
- Understand the isolation levels of the database, transactions, and how to avoid deadlock.
- Generate Golang code to communicate with the database automatically.
- Using the Gin framework, create a RESTful backend web service.
- User authentication, JWT, and PASETO are used to secure the APIs.
- Create a more robust test suite with great coverage by utilizing interfaces and mocking.
- For deployment, create a simple Docker image and utilize Docker-compose for development.
- Configure Github Action to develop and deploy the app to an AWS Kubernetes cluster automatically.
- To route traffic to the web service, register a domain and configure Kubernetes ingress.
- Allow Let's Encrypt to automatically issue and renew TLS certificates for the domain.
Syllabus:
1. Working with database [Postgres + SQLC]
- Design DB schema and generate SQL code with dbdiagram.io
- Setup development environment on Windows: WSL2, Go, VSCode, Docker, Make, Sqlc
- Setup development environment on MacOS: Install Go and Visual Studio Code
- Use Docker + Postgres + TablePlus to create DB schema
- How to write & run database migration in Golang
- Generate CRUD Golang code from SQL | Compare db/sql, gorm, sqlx & sqlc
- Write unit tests for database CRUD with random data in Golang
- A clean way to implement database transaction in Golang
- DB transaction lock & How to handle deadlock in Golang
- How to avoid deadlock in DB transaction? Queries order matters!
- Deeply understand transaction isolation levels & read phenomena
- Setup Github Actions for Golang + Postgres to run automated tests
2. Building RESTful HTTP JSON API [Gin + JWT + PASETO]
- Implement RESTful HTTP API in Go using Gin
- Load config from file & environment variables in Go with Viper
- Mock DB for testing HTTP API in Go and achieve 100% coverage
- Implement transfer money API with a custom params validator
- Add users table with unique & foreign key constraints in PostgreSQL
- How to handle DB errors in Golang correctly
- How to securely store passwords? Hash password in Go with Bcrypt!
- How to write stronger unit tests with a custom gomock matcher
- Why PASETO is better than JWT for token-based authentication?
- How to create and verify JWT & PASETO token in Golang
- Implement login user API that returns PASETO or JWT access token in Go
- Implement authentication middleware and authorization rules in Golang using Gin
3. Deploying the application to production [Docker + Kubernetes + AWS]
- How to build a small Golang Docker image with a multistage Dockerfile
- How to use docker network to connect 2 stand-alone containers
- How to write docker-compose file and control service start-up orders
- How to create a free-tier AWS account
- Auto build & push docker image to AWS ECR with Github Actions
- How to create a production database on AWS RDS
- Store & retrieve production secrets with AWS secrets manager
- Kubernetes architecture & How to create an EKS cluster on AWS
- How to use kubectl & k9s to connect to a kubernetes cluster on AWS EKS
- How to deploy a web app to Kubernetes cluster on AWS EKS
- Register a domain & set up A-record using Route53
- How to use Ingress to route traffics to different services in Kubernetes
- Auto issue & renew TLS certificates with cert-manager and Let's Encrypt
- Automatic deploy to Kubernetes with Github Action
4. Advanced Backend Topics [Sessions + gRPC]
- How to manage user session with refresh token
- Generate DB documentation page and schema SQL dump from DBML
- Introduction to gRPC
- Define gRPC API and generate Go code with protobuf
- How to run a golang gRPC server and call its API
- Implement gRPC API to create and login users in Go
- gRPC Gateway: write code once, serve both gRPC & HTTP requests
- How to extract information from gRPC metadata
- Automatic generate & serve swagger documentation from Go server
- Embed static front-end files inside Golang backend server's binary
- Validate gRPC parameters and send human/machine friendly response
- Run DB migrations directly inside Golang code
- Partial update DB record with SQLC nullable arguments
- Build gRPC update API with optional parameters
- Add authorization to protect gRPC API
- Write structured logs for gRPC APIs
- How to write HTTP logger middleware in Go
5. Asynchronous processing with background workers [Asynq + Redis]
- Implement background worker with Redis task queue
- Integrate async worker to Go web server
- Send async tasks to Redis within a DB transaction
- How to handle errors and print logs for Async workers
- Some delay might be good for your async tasks
- How to send email in Go via Gmail
- How to skip test in Go and config test flag in vscode
- Email verification feature: design DB and send email
- Implement email verification API in Go
- Unit test gRPC API with mock DB & Redis
- How to test a gRPC API that requires authentication
6. Improve the stability and security of the server
- Upgrade and config sqlc with version 2 syntax
- Switch DB driver from lib/pq to pgx
- How to properly handle DB errors with pgx driver
- Docker compose: port + volume mapping
- How to install & use binary packages in Go
- Implement role-based access control (RBAC) in Go
- Grant AWS EKS cluster access to Postgres and Redis using security group