A production-ready Gin + Fx based project template for rapidly building scalable, modular, RESTful web services in Go.
This template is designed with:
- π§± Modular architecture (Fx DI)
- π§ Clean architecture layering
- π JWT authentication
- π¦ Ent ORM
- π³ Docker & Docker Compose
- π Swagger API docs
- π§ͺ Testing & mocking
- π Database migration
- Gin HTTP framework
- Uber Fx dependency injection
- PostgreSQL (Ent ORM)
- Redis
- JWT authentication
- Modular domain structure
- Swagger documentation
- Integration testing stack
- Database migration
- Linting & formatting
- Mock generation
- Dependency vulnerability scanning
cmd/
app/ # Application entrypoint
internal/
config/ # Configuration
modules/ # Business modules (user, post, auth, ...)
router/ # Router layer
middleware/ # HTTP middlewares (auth, logging, cors, ...)
dto/ # Data Transfer Objects (request/response models)
pkg/
logger/ # Logger
postgres/ # PostgreSQL client
redis/ # Redis client
jwt/ # JWT utilities
oauth2/ # OAuth2 (Github & Google)
ent/
schema/ # Ent schemas
migrate/ # Migration files- Module-based architecture (inspired by NestJS)
- Fx global container with interface-based exports
- Strong decoupling via interfaces
- Dependency inversion principle (DIP)
- Clean boundaries between modules
Controller -> Service -> Domain Interface -> Infrastructurebrew install dockergo version >= 1.22docker run -d --name pg-server \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=password \
-e POSTGRES_DB=db_name \
-p 5432:5432 \
-v pgdata:/var/lib/postgresql \
postgresdocker run -d --name redis \
-p 6379:6379 \
-v redis-data:/data \
redis redis-server --requirepass yourpassword --appendonly yescp .env.example .envmake runmake compose-upmake compose-up-allmake compose-up-integration-testmake compose-downmake swag-v1Access:
http://localhost:8080/swagger/index.html
make testmake schema-create Usermake ent-genmake migrate-create add_user_tablemake migrate-upmake migrate-downmake formatmake linter-golangcimake deps-auditmake mockmake deps
make upgrade-deps
make ls-depsmake pre-commitEach module follows:
module/
module.go # fx.Module definition
service.go # internal implementation
repo.go # repository
controller.go # HTTP layerExternal modules only depend on interfaces.
- JWT authentication
- Middleware-based authorization
- Environment-based secrets
- Isolated service layers
- OpenTelemetry tracing
- Prometheus metrics
- gRPC gateway
- CQRS pattern
- Event-driven architecture
- Message queue integration
MIT License
PRs are welcome. Please follow:
- Go formatting standards
- Modular structure
- Interface-first design
- Clean commit history
Simple by default, scalable by design.
Architecture should enable growth, not block it.
- Enterprise-ready
- Clean architecture
- Strong boundaries
- Modular design
- High scalability
- Production-grade tooling
Happy coding! π