Skip to content

Go Chi Postgres Starter v1.0.0

Latest

Choose a tag to compare

@justyn-clark justyn-clark released this 12 Nov 21:17
· 2 commits to main since this release

πŸš€ 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 - /metrics endpoint 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 - /metrics endpoint
  • βœ… 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


Full Changelog: https://github.com/justyn-clark/go-chi-postgres-starter/compare/v1.0.0