A robust, production-ready backend banking service built with Go, featuring account management, user authentication, secure token handling, and comprehensive database operations.
- User Management: Create and manage bank accounts with secure authentication
- JWT & PASETO Authentication: Dual token generation for enhanced security
- Account Operations: Core banking functionalities for account management
- Transfer & Transactions: Secure fund transfer and transaction tracking
- PostgreSQL Database: Reliable data persistence with connection pooling
- REST API: Clean, RESTful endpoints powered by Gin framework
- Input Validation: Comprehensive request validation using
go-playground/validator - Unit Testing: Full test coverage with mocking support
- Docker Support: Easy deployment with Docker and Docker Compose
- Database Migrations: Version-controlled schema management with SQL migrations
| Component | Technology | Purpose |
|---|---|---|
| Language | Go 1.25.5 | Fast, efficient backend development |
| Web Framework | Gin | High-performance HTTP framework |
| Database | PostgreSQL 16 | Reliable relational database |
| DB Driver | pgx/v5 | Modern PostgreSQL driver |
| DB Generation | sqlc | Type-safe SQL queries |
| Authentication | JWT + PASETO | Secure token-based auth |
| Validation | go-playground/validator | Request validation |
| Config Management | Viper | Environment configuration |
| Containerization | Docker & Docker Compose | Deployment orchestration |
| Testing | testify + uber/mock | Testing & mocking utilities |
Bank-Pro/
βββ main.go # Application entry point
βββ go.mod & go.sum # Go dependencies
βββ Dockerfile # Container image definition
βββ docker-compose.yaml # Multi-container setup
βββ Makefile # Common development commands
βββ sqlc.yaml # SQL code generation config
βββ app.env # Environment variables
β
βββ api/ # REST API handlers & server
βββ db/ # Database layer
β βββ migration/ # SQL migration files
β βββ sqlc/ # Generated SQL queries
β βββ mock/ # Mock database for testing
βββ token/ # JWT & PASETO token management
βββ util/ # Utility functions & helpers
- Go 1.25.5 or higher
- Docker & Docker Compose
- PostgreSQL client (optional, for local development)
# Clone the repository
git clone https://github.com/niloy104/Bank-Pro.git
cd Bank-Pro
# Start services
docker-compose up --build
# API will be available at http://localhost:8080# Clone repository
git clone https://github.com/niloy104/Bank-Pro.git
cd Bank-Pro
# Start PostgreSQL
make postgres
# Create database
make createdb
# Run migrations
make migrateup
# Start server
make server
# API will be running at configured SERVER_ADDRESS# Database operations
make postgres # Start PostgreSQL container
make createdb # Create 'simple_bank' database
make dropdb # Drop 'simple_bank' database
# Database migrations
make migrateup # Run all pending migrations
make migratedown # Rollback all migrations
make migrateup1 # Run next 1 migration
make migratedown1 # Rollback 1 migration
# Code generation & testing
make sqlc # Generate type-safe SQL code
make test # Run all tests with coverage
make mock # Generate mock database for tests
# Development
make server # Start the API serverConfiguration is managed via environment variables. Create an app.env file:
# Server Configuration
SERVER_ADDRESS=0.0.0.0:8080
# Database Configuration
DB_SOURCE=postgresql://root:secret@localhost:5432/simple_bank?sslmode=disable
# JWT/PASETO Configuration
TOKEN_SYMMETRIC_KEY=<your-32-character-key>
ACCESS_TOKEN_DURATION=15m
REFRESH_TOKEN_DURATION=24hPOST /auth/login- User login (returns JWT/PASETO token)POST /auth/refresh- Refresh authentication token
POST /accounts- Create new accountGET /accounts/:id- Get account detailsGET /accounts- List user accounts
POST /transfers- Create fund transferGET /transfers/:id- Get transfer details
GET /transactions- List account transactions
Detailed API documentation available in /api endpoint
# Run all tests
make test
# Run specific test
go test -v ./api
# Run with coverage report
go test -cover ./...Tests use mock databases and dependency injection for isolated, reliable testing.
# Build image
docker build -t bank-pro:latest .
# Run container
docker run -p 8080:8080 \
-e DB_SOURCE=postgresql://root:secret@postgres:5432/simple_bank \
bank-pro:latestdocker-compose up -d- Token-Based Authentication: JWT and PASETO tokens
- Password Encryption: Secure hashing with
golang.org/x/crypto - SQL Injection Prevention: Type-safe queries via sqlc
- Input Validation: Comprehensive request validation
- Environment-Based Config: Sensitive data in environment variables
- Connection Pooling: Secure database connection management via pgxpool
Key external dependencies:
github.com/gin-gonic/gin- Web frameworkgithub.com/golang-jwt/jwt/v5- JWT token generationgithub.com/o1egl/paseto- PASETO token generationgithub.com/jackc/pgx/v5- PostgreSQL drivergolang.org/x/crypto- Cryptographic functionsgithub.com/google/uuid- UUID generationgithub.com/spf13/viper- Configuration management
See go.mod for complete dependency list.
- Create Feature Branch:
git checkout -b feature/your-feature - Make Changes: Implement your feature
- Run Tests:
make test- ensure all tests pass - Generate Code:
make sqlc- if database changes - Commit: Commit with meaningful messages
- Push & PR: Create pull request for review
- Type Safety: Full static typing with Go
- Testing: Comprehensive unit tests with mocking
- Linting: Go standard conventions followed
- Documentation: Inline comments for complex logic
# Change SERVER_ADDRESS in app.env
SERVER_ADDRESS=0.0.0.0:8081# Verify PostgreSQL is running
docker ps | grep postgres
# Check DB_SOURCE connection string# Reset migrations
make migratedown
make migrateupThis project is licensed under the terms specified in the LICENSE file.
niloy104 - GitHub Profile
- Go: 92% (Core application)
- Shell: 5.8% (Deployment scripts)
- Makefile: 1.5% (Build automation)
- Dockerfile: 0.7% (Container setup)
Built with β€οΈ for secure, scalable banking backend systems