Production-ready in 90 seconds. No headaches, just clean code.
GRAB is a Go boilerplate that doesn't waste your time β highly tested, Docker-ready, fully documented, AI-assistant optimized, with everything you need. Built for developers who want to code with AI, not fight it.
π Full Documentation β’ π Quick Start β’ β¨ Live Demo
GRAB is designed to work seamlessly with your favorite AI coding assistants:
Out-of-the-box AI integration with comprehensive guidelines for:
- GitHub Copilot (VS Code, GoLand, Visual Studio)
- Cursor IDE (with dedicated
.cursor/rules/) - Windsurf IDE (with dedicated
.windsurf/rules/) - JetBrains AI (via AGENTS.md standard)
- Any AI assistant supporting AGENTS.md standard
Note: GoLand users get dual AI support through both GitHub Copilot (via
.github/copilot-instructions.md) and JetBrains AI (viaAGENTS.md). No IDE-specific configuration needed.
AI assistants understand GRAB's Clean Architecture, Docker-first workflow, migration patterns, and testing conventions. Get intelligent code completions, accurate refactoring suggestions, and context-aware help.
π Learn More: AI-Friendly Development Guide
You know the pain: Starting a new Go project means days of configuring Docker, wiring up authentication, setting up migrations, writing boilerplate code, and praying your hot-reload actually works.
GRAB changes that.
make quick-start # β One command. 90 seconds. You're building features.This is the real deal. The production-grade boilerplate you wish you had from day one:
β
Clean Architecture β Handler β Service β Repository (GO industry standard)
β
AI-Optimized Guidelines β Built-in rules for GitHub Copilot, Cursor, Windsurf & AGENTS.md
β
Security & JWT Auth β OAuth 2.0 BCP compliant with refresh token rotation, rate limiting, CORS
β
Role-Based Access Control β Many-to-many RBAC with JWT integration and secure admin CLI
β
Database Migrations β PostgreSQL with version control & rollback
β
Comprehensive Tests β Unit + integration with CI/CD pipeline
β
Interactive Docs β Auto-generated Swagger + Postman collection
β
Structured Logging β JSON logs with request IDs and tracing
β
Standardized API Responses β Consistent envelope format for all endpoints
β
Structured Error Handling β Machine-readable error codes with details
β
Production Docker β Multi-stage builds, health checks, optimized images
β
Environment-Aware β Dev/staging/prod configs + Make automation & more
β
Graceful Shutdown β Zero-downtime deployments with configurable timeouts
β
Hot-Reload (2 seconds!) β Powered by Air, not magic
And that's just scratching the surface. Check the full documentation to see everything GRAB offers.
Not some random structure β follows official Go project layout + battle-tested community patterns from golang-standards/project-layout. The same architecture used by Gin, GORM, and production Go services.
- π Shipping Fast β Launch MVPs and production APIs in days, not weeks
- π₯ Team Projects β Consistent standards everyone understands
- ποΈ Scaling Up β Architecture that grows with your business
- π Learning Go β See how pros structure real-world applications
Get your API running in under 2 minutes:
- Docker and Docker Compose
- Git
π‘ Want to run without Docker? See the Manual Setup Guide in the documentation.
git clone https://github.com/vahiiiid/go-rest-api-boilerplate.git
cd go-rest-api-boilerplate
make quick-startπ Done! Your API is now running at:
- API Base URL: http://localhost:8080/api/v1
- Swagger UI: http://localhost:8080/swagger/index.html
- Health Checks: http://localhost:8080/health β’ /health/live β’ /health/ready
Create Admin User:
make create-admin # Interactive: prompts for email, name, password
make promote-admin ID=1 # Promote existing user to admin by IDOpen http://localhost:8080/swagger/index.html to explore and test all endpoints interactively.
Import the pre-configured collection from api/postman_collection.json with example requests and tests.
π Ready to Build?
- π Development Guide β Learn how to add models, routes, and handlers
- π‘ TODO List Tutorial β Complete step-by-step feature implementation from scratch
Most boilerplates give you code. GRAB gives you a professional development workflow.
- OAuth 2.0 BCP compliant β JWT-based auth (HS256) with refresh token rotation and automatic reuse detection
- Enhanced security β Refresh tokens with family tracking, secure token invalidation, and breach detection
- Context helpers β Type-safe user extraction (no more casting nightmares)
- Password security β Bcrypt hashing with best-practice cost factor
- Rate limiting β Token-bucket protection against abuse built-in
π Authentication Guide | Context Helpers
- Many-to-many architecture β Flexible roles system with extensible permissions
- Secure admin CLI β Interactive admin creation with strong password enforcement (no defaults in code)
- JWT-integrated authorization β Roles embedded in tokens for server-side validation
- Protected endpoints β Middleware-based access control (RequireRole, RequireAdmin)
- Three-endpoint pattern β
/auth/me(current user),/users/:id(specific),/users(admin list) - Paginated user management β Admin-only user listing with filtering and search
π RBAC Guide
-
PostgreSQL + GORM β Production-grade ORM with relationship support
-
golang-migrate β Industry-standard migrations with timestamp versioning
-
Complete migration CLI β Create, apply, rollback with ease
make migrate-create NAME=add_posts_table # Create with timestamp make migrate-up # Apply all pending make migrate-down # Rollback last (safe) make migrate-down STEPS=3 # Rollback multiple make migrate-status # Check current version make migrate-goto VERSION=<timestamp> # Jump to specific version
-
Safety features β Confirmation prompts, dirty state detection
-
Transaction support β BEGIN/COMMIT wrappers for data integrity
-
Connection pooling β Configured for performance out of the box
π Migrations Guide
- 2-second hot-reload β Powered by Air, actually works in Docker
- One command to rule them all β
make quick-starthandles everything - Development & production β Separate optimized configs
- Multi-stage builds β Tiny production images (~20MB)
π Docker Guide
- Kubernetes-ready probes β Liveness (
/health/live) and readiness (/health/ready) endpoints - Database health monitoring β Response time tracking with pass/warn/fail thresholds
- RFC-compliant responses β Following IETF draft standards for health check format
- Zero-downtime deployments β Smart readiness checks for load balancer integration
- Extensible architecture β Easy to add custom health checkers (Redis, external APIs, etc.)
π Health Checks Guide
- Auto-generated Swagger β Interactive API explorer at
/swagger/index.html - Full documentation site β Not just README, real guides at vahiiiid.github.io/go-rest-api-docs
- Step-by-step tutorials β Build a TODO app from scratch
- Postman collection β Import and test immediately
π Full Documentation
- Comprehensive coverage β Handlers, services, and repositories all tested
- In-memory SQLite β No external dependencies for tests
- Table-driven tests β Go idiomatic testing patterns
- CI/CD ready β GitHub Actions configured and working
π Testing Guide
- Consistent envelope format β All responses wrapped in
{success, data, error, meta}structure - JSend-inspired design β Industry best practice for API response formatting
- Type-safe responses β Predictable structure for frontend integration
- Metadata support β Pagination, timestamps, request IDs built-in
π API Response Format Guide
- Structured API errors β Machine-readable codes (NOT_FOUND, VALIDATION_ERROR, etc.)
- Detailed error info β Code, message, details, timestamp, path, request ID
- Validation details β Clear field-level error messages for bad requests
- Centralized middleware β Single error handler for consistent responses
- Rate limit errors β Includes
retry_afterfor proper backoff logic
π Error Handling Guide
- Clean layers β Handler β Service β Repository (no shortcuts)
- Dependency injection β Proper DI, easy to mock and test
- Domain-driven β Organize by feature, not by layer
- Official Go layout β Follows golang-standards/project-layout
π Development Guide
The easiest way to develop with hot-reload and zero setup:
make up # Start containers with hot-reload
make logs # View logs
make test # Run all tests
make lint # Check code quality
make lint-fix # Auto-fix linting issues
make down # Stop containersWhat you get:
- π₯ Hot-reload β Code changes reflect in ~2 seconds (powered by Air)
- π¦ Volume mounts β Edit code in your IDE, runs in container
- ποΈ PostgreSQL β Database on internal Docker network
- π All tools pre-installed β No Go installation needed on host
Production-grade migrations using golang-migrate:
make migrate-create NAME=add_todos_table # Create new migration
make migrate-up # Apply all pending
make migrate-down # Rollback last migration
make migrate-status # Check current versionFor long-running migrations:
go run cmd/migrate/main.go up --timeout=30m --lock-timeout=1mAll environments use SQL migrations for consistency and safety.
Want to run natively? You'll need Go 1.24+ installed.
make build-binary # Build binary to bin/server
make run-binary # Build and run (requires PostgreSQL on localhost)π Full Setup Guide for native development
GRAB includes optimized production builds:
make docker-up-prod # Start production containersWhat's included:
- β Multi-stage Docker builds (minimal image size)
- β Production-grade health checks (liveness & readiness probes)
- β Environment-based configuration
- β No development dependencies
- β Production logging
Ready for:
- AWS ECS/Fargate β Container orchestration
- Google Cloud Run β Serverless containers
- DigitalOcean App Platform β Platform-as-a-service
- Kubernetes β Self-managed orchestration
- Any VPS β Using Docker Compose
π Deployment Guide for step-by-step instructions
Complete guides covering everything:
- π Getting Started β Installation and configuration
- π» Development Guide β Building features
- π‘ TODO Tutorial β Step-by-step implementation
- π³ Docker Guide β Container workflows
- ποΈ Migrations β Database schema management
- π₯ Health Checks β Kubernetes probes and monitoring
- π§ͺ Testing β Writing and running tests
- π¦ API Response Format β Standardized response envelope
β οΈ Error Handling β Structured API errors- π Swagger β API documentation
- βοΈ Configuration β Environment setup
Documentation lives in a separate repository. To contribute:
- Visit github.com/vahiiiid/go-rest-api-docs
- Follow the contributing guidelines
- Submit pull requests for improvements
For code contributions, see CONTRIBUTING.md
We β€οΈ contributions! See CONTRIBUTING.md for:
- Code style guidelines
- Pull request process
- Testing requirements
- Commit conventions
- Fork the repository
- Create a feature branch (
git checkout -b feat/amazing-feature) - Make your changes
- Run tests and linter (
make lint-fix && make lint && make test) - Commit your changes (
git commit -m 'feat: add amazing feature') - Push to the branch (
git push origin feat/amazing-feature) - Open a Pull Request
- Gin β Fast HTTP web framework
- GORM β Developer-friendly ORM
- golang-migrate β Database migration toolkit
- Viper β Configuration management
- golang-jwt β JWT implementation
- swaggo β Swagger documentation generator
- Air β Hot-reload for development
This project is licensed under the MIT License - see the LICENSE file for details.
- π Read the Documentation
- π Report Bugs
- π¬ Ask Questions
- β Star this repo if you find it helpful!
Made with β€οΈ for the Go community
β Star β’ π Docs β’ π Issues β’ π¬ Discussions



