This project provides a simple banking service API.
It allows users to create accounts, log in, and potentially perform transactions (though only user management is fully shown in the snippets).
The core API is built using gRPC, and an HTTP Gateway translates requests for web clients.
It uses a PostgreSQL database (managed by sqlc) for storing data, Redis for background task queuing (like sending verification emails), and Paseto/JWT for user authentication.
Configuration is managed externally, and input data is validated before processing.
Source Repository: https://github.com/spaghetti-lover/simplebank
flowchart TD
A0["Application Orchestration & Entrypoint
"]
A1["Database Access Layer (sqlc)
"]
A2["gRPC API Service
"]
A3["HTTP Gateway
"]
A4["Authentication & Authorization (Token-Based)
"]
A5["Asynchronous Task Processing (Worker)
"]
A6["Configuration Management
"]
A7["Input Data Validation
"]
A0 -- "Loads Configuration" --> A6
A0 -- "Initializes DB Connection" --> A1
A0 -- "Initializes & Manages Task ..." --> A5
A0 -- "Initializes & Starts gRPC S..." --> A2
A0 -- "Initializes & Starts HTTP G..." --> A3
A2 -- "Executes DB Operations" --> A1
A2 -- "Uses Token Creation/Verific..." --> A4
A2 -- "Distributes Background Tasks" --> A5
A2 -- "Validates Request Data" --> A7
A3 -- "Forwards HTTP requests to gRPC" --> A2
A5 -- "Executes DB Operations for ..." --> A1
A5 -- "Uses Config (e.g., for Email)" --> A6
A4 -- "Uses Config (e.g., for Toke...)" --> A6
- gRPC API Service
- Database Access Layer (sqlc)
- Input Data Validation
- HTTP Gateway
- Authentication & Authorization (Token-Based)
- Asynchronous Task Processing (Worker)
- Configuration Management
- Application Orchestration & Entrypoint
- Database Design
-
brew install golang-migrate
-
npm install -g dbdocs dbdocs login
-
npm install -g @dbml/cli dbml2sql --version
-
brew install sqlc
-
go install github.com/golang/mock/[email protected]
-
Create the bank-network
make network
-
Start postgres container:
make postgres
-
Create simple_bank database:
make createdb
-
Run db migration up all versions:
make migrateup
-
Run db migration up 1 version:
make migrateup1
-
Run db migration down all versions:
make migratedown
-
Run db migration down 1 version:
make migratedown1
-
Generate DB documentation:
make db_docs
-
Access the DB documentation at this address. Password:
secret
-
Generate schema SQL file with DBML:
make db_schema
-
Generate SQL CRUD with sqlc:
make sqlc
-
Generate DB mock with gomock:
make mock
-
Create a new db migration:
make new_migration name=<migration_name>
-
Run server:
make server
-
Run test:
make test
-
Install nginx ingress controller:
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v0.48.1/deploy/static/provider/aws/deploy.yaml
-
kubectl apply -f https://github.com/jetstack/cert-manager/releases/download/v1.4.0/cert-manager.yaml