A backend banking service built with Go, PostgreSQL, and gRPC that provides user management, account operations, and money transfers with email verification.
- User registration and authentication with JWT/PASETO tokens
- Email verification system with async task processing
- Account management (create, read, update)
- Money transfers between accounts with transaction support
- Role-based access control (depositor/banker)
- RESTful HTTP API and gRPC API
- Swagger documentation
- Redis-backed async task queue
- Backend: Go 1.x
- Database: PostgreSQL 18
- Cache/Queue: Redis 7
- API: gRPC with gRPC-Gateway for REST
- Authentication: JWT and PASETO tokens
- Task Queue: Asynq (Redis-based)
- Database Migrations: golang-migrate
- Code Generation: sqlc (SQL to Go), protoc (Protocol Buffers)
- Testing: Go testing with gomock
- Frontend: Vue 3 + TypeScript + Vite
- Go 1.19+
- Docker and Docker Compose
- Make
- migrate CLI tool
- sqlc
- protoc (Protocol Buffer compiler)
git clone <repository-url>
cd SimpleBankdocker-compose up -dThis starts:
- PostgreSQL on port 5432
- Redis on port 6379
- API server on ports 8080 (HTTP) and 9090 (gRPC)
If you prefer running services individually:
# Create Docker network
make network
# Start PostgreSQL
make postgres
# Create database
make createdb
# Run migrations
make migrateup
# Start Redis
make redis
# Run the server
make serverEdit app.env to configure:
DB_SOURCE=postgresql://root:secret@localhost:5432/simple_bank?sslmode=disable
REDIS_ADDRESS=localhost:6379
HTTP_SERVER_ADDRESS=0.0.0.0:8080
GRPC_SERVER_ADDRESS=0.0.0.0:9090
TOKEN_SYMMETRIC_KEY=<32-character-key>
ACCESS_TOKEN_DURATION=15m
REFRESH_TOKEN_DURATION=24h
ENVIRONMENT=development
EMAIL_SENDER_NAME=SimpleBank
EMAIL_SENDER_ADDRESS=<your-email>
EMAIL_SENDER_PASSWORD=<your-password>Once the server is running, access Swagger UI at:
http://localhost:8080/swagger/
The database includes:
- users: User accounts with authentication
- accounts: Bank accounts with balances
- entries: Account balance change records
- transfers: Money transfer records between accounts
- sessions: User session management
- verify_emails: Email verification tokens
make test# Generate Go code from SQL queries
make sqlc
# Generate gRPC/Protocol Buffer code
make proto
# Generate database mocks for testing
make mock# Create new migration
make new_migration name=<migration_name>
# Run all migrations
make migrateup
# Run one migration
make migrateup1
# Rollback all migrations
make migratedown
# Rollback one migration
make migratedown1# Generate database docs
make db_docs
# Generate SQL schema from DBML
make db_schema.
├── api/ # HTTP REST API handlers
├── db/
│ ├── migration/ # Database migration files
│ ├── query/ # SQL queries for sqlc
│ ├── sqlc/ # Generated Go code from SQL
│ └── mock/ # Mock database for testing
├── doc/ # Documentation and Swagger files
├── gapi/ # gRPC API handlers
├── mail/ # Email sending functionality
├── pb/ # Generated Protocol Buffer code
├── proto/ # Protocol Buffer definitions
├── token/ # JWT and PASETO token makers
├── util/ # Utility functions and config
├── val/ # Custom validators
├── worker/ # Async task processors
├── frontend/ # Vue.js frontend
└── main.go # Application entry point
POST /users- Create userPOST /users/login- Login userPOST /accounts- Create accountGET /accounts/:id- Get accountPOST /transfers- Create transfer
CreateUser- Register new userLoginUser- Authenticate userUpdateUser- Update user detailsVerifyEmail- Verify email address
The project includes unit tests and integration tests using:
- Go's built-in testing package
- gomock for mocking dependencies
- testify for assertions
Run tests with coverage:
go test -v -cover ./...The project includes:
Dockerfilefor containerizationdocker-compose.yamlfor local deployment- Kubernetes manifests in
eks/directory - GitHub Actions workflows in
.github/workflows/