go-backend-clean-architecture
Go backend with Gin, MongoDB, JWT auth, and Clean Architecture.
When & Why to Use This Skill
This Claude skill provides a production-ready boilerplate for building scalable Go backends using the Gin framework and MongoDB. It strictly follows Clean Architecture principles to ensure a high degree of maintainability, testability, and separation of concerns. Featuring built-in JWT authentication and Docker support, it serves as a comprehensive starter kit for developers looking to implement secure and robust RESTful APIs with a professional directory structure.
Use Cases
- Rapidly bootstrapping a new Go-based web service or microservice with a pre-configured, industry-standard project layout.
- Implementing a decoupled backend architecture where business logic is isolated from external frameworks like Gin or MongoDB.
- Setting up secure user authentication and authorization workflows using JWT (JSON Web Tokens) in a Go environment.
- Developing cloud-native applications that require easy containerization via Docker and structured environment configuration.
- Learning or teaching best practices for Go backend development, specifically focusing on the Repository and Use Case patterns.
| name | go-backend-clean-architecture |
|---|---|
| description | Go backend with Gin, MongoDB, JWT auth, and Clean Architecture. |
Go Clean Architecture
A Go backend with Gin, MongoDB, JWT authentication, and Docker support following Clean Architecture principles.
Tech Stack
- Framework: Gin
- Language: Go
- Database: MongoDB
- Auth: JWT
- Architecture: Clean Architecture
Prerequisites
- Go 1.21+
- MongoDB
- Docker (optional)
Setup
1. Clone the Template
git clone --depth 1 https://github.com/amitshekhariitbhu/go-backend-clean-architecture.git .
If the directory is not empty:
git clone --depth 1 https://github.com/amitshekhariitbhu/go-backend-clean-architecture.git _temp_template
mv _temp_template/* _temp_template/.* . 2>/dev/null || true
rm -rf _temp_template
2. Remove Git History (Optional)
rm -rf .git
git init
3. Install Dependencies
go mod download
4. Setup Environment
Configure MongoDB connection and JWT secret.
Build
go build -o app ./cmd/main.go
Development
go run ./cmd/main.go