π Go Chi Postgres Starter v1.0.0
A production-ready Go REST API starter template with Chi Router and PostgreSQL 18.
β¨ Key Features
π Security & Protection
- JWT Authentication - Secure token-based authentication with role support
- Rate Limiting - IP-based token bucket algorithm (10 req/sec default)
- Request Body Limits - 1MB limit to prevent DoS attacks
- Security Headers - X-Frame-Options, CSP, XSS protection, HSTS ready
- Password Hashing - bcrypt with proper cost
- Input Validation - Struct validation with go-playground/validator
π‘οΈ Reliability & Resilience
- Graceful Shutdown - Signal handling (SIGINT/SIGTERM) with 30s timeout
- Panic Recovery - Stack trace logging on panics
- Health Checks - Database-aware health endpoint (
/api/health) - Database Migrations - golang-migrate integration
- Connection Pooling - Production-ready pool config (MaxConns: 25, MinConns: 5)
π Observability
- Structured Logging - Zerolog with configurable levels
- Request Logging - Method, path, status, duration, bytes
- Prometheus Metrics -
/metricsendpoint with HTTP metrics - Request ID - Per-request tracking for debugging
β‘ Performance
- Response Compression - gzip compression (level 5)
- Database Pooling - Optimized connection pool settings
- Goroutine Utilities - Production-ready concurrency patterns
π οΈ Developer Experience
- OpenAPI/Swagger - Auto-generated interactive docs (
/swagger/index.html) - Live Reload - Air integration for development
- CI/CD - GitHub Actions (test, lint, build)
- Docker Support - docker-compose for database and Redis
- Queue System - Pluggable background job processing (Redis/in-memory)
- Comprehensive Documentation - README, guides, and inline docs
π― What's Included
- β Chi Router - Lightweight, standard library compatible router
- β pgx/v5 - High-performance PostgreSQL driver
- β golang-migrate - Database migrations
- β JWT Authentication - Secure token-based auth system
- β Zerolog - Structured logging
- β Rate Limiting - IP-based with token bucket algorithm
- β
Prometheus Metrics -
/metricsendpoint - β Queue System - Redis/in-memory background jobs
- β Deployment Ready - Dockerfile + Fly.io & Railway configs
π¦ Quick Start
# Clone the repository
git clone https://github.com/justyn-clark/go-chi-postgres-starter.git
cd go-chi-postgres-starter
# Create database
createdb go_api_starter
# Run migrations
export DATABASE_URL="postgresql://postgres:postgres@localhost:5432/go_api_starter?sslmode=disable"
make migrate-up
# Start the API
make runπ Documentation
π Links
- Repository: https://github.com/justyn-clark/go-chi-postgres-starter
- API Documentation: Available at
/swagger/index.htmlafter starting the server
Full Changelog: https://github.com/justyn-clark/go-chi-postgres-starter/compare/v1.0.0