rdev-go-api-template
π The Concept
A unified Go development utility that functions simultaneously as a production-ready architectural blueprint and an automation tool. Tailored specifically for high-performance Go-Gin HTTP routing and Bun ORM data layers, it builds a secure backend foundation and automates continuous vertical-slice feature generation.
π οΈ Why, What, and How
Why
Manual backend bootstrapping and database layer setup introduce repetitive friction, architecture drift, and security vulnerabilities. This project was built to solve those challenges by providing a highly optimized stack out of the box, offering a major evolutionary leap over our previous rdev-go-ddgen utility:
-
From
rdev-go-ddgentordev-go-api-template: The old iteration was a loose, single-purpose domain code generator. This new variation elevates the entire workflow by introducing a unified sub-command engine that handles both initial repository creation and domain generation, backed by explicit path traversal safety guards. - Modern Stack Integration: Replaces generic database setups with an efficient, SQL-first workflow using Bun ORM alongside the ultra-fast Go-Gin web framework.
What
A compiled, self-contained CLI tool that handles two distinct lifecycle phases:
-
init: Scaffolds a complete API directory tree pre-configured with Gin routers, Bun connection abstractions, Docker environments, and hidden workspace management. -
generate: Dynamically injects architectural domain components (handlers, services, repositories) cleanly into your existing codebase.
How
Install the compiled utility globally:
go install github.com/XaiPhyr/rdev-go-api-template@v1.0.0
1. Scaffold a New Project Tree
rdev-go-api-template init github.com/username/project
2. Generate a Complete Domain Feature Slice
rdev-go-api-template generate -d orders
3. Generate an Isolated Architectural Component
rdev-go-api-template generate -d orders -f handler
βοΈ Trade-offs
- SQL-First Performance vs. Heavy Abstraction: Utilizing Bun ORM yields raw SQL performance and type-safe query compilation without the bloated runtime overhead of heavier ORMs. The trade-off is that developers must write idiomatic SQL/Go code rather than relying entirely on magic graphical abstractions, keeping the application highly performant under high concurrency.
-
Immutable Compilation: All blueprint templates are baked directly into the compiled machine binary using Go's
//go:embedfilesystem. This ensures complete tool independence, but requires rebuilding the binary (go install) if you modify the underlying scaffolding templates.
π‘ Layman's Terms
Think of our previous tool, rdev-go-ddgen, like a specialized mechanical drill that only made holes for wall plugs. It was helpful, but you still had to build the entire house by hand first.
This new version is like a complete, heavy-duty factory machine. Not only does it instantly clear the land and assemble the entire structural frame of the house (init), but it installs the high-performance water plumbing (Go-Gin) and the electric grid wires (Bun ORM) automatically. When you need a new room added later, you just tap a button (generate), and it snaps a pre-labeled, fully wired room right into place perfectly!
Top comments (0)