DEV Community

Cover image for rdev-go-ddgen: Automating Domain Directory Boilerplate for Go Applications
RL Loz
RL Loz

Posted on

rdev-go-ddgen: Automating Domain Directory Boilerplate for Go Applications

When building robust backend APIs in Go, maintaining a consistent, clean architectural pattern across domain directories is essential for scalability. However, manually creating repetitive domain structures for every new resource introduces subtle human error.

The Why: Why Manual Boilerplate Fails
Copy-pasting existing files to scaffold a new domain (e.g., adding an orders domain next to a users domain) is a common but fragile practice. It is incredibly easy to overlook an import statement, miss a file, or forget to update a variable definition. As an API grows to dozens of domains, this manual approach becomes a major bottleneck that risks introducing compilation errors or silent bugs into your application.

The What: What is rdev-go-ddgen?
rdev-go-ddgen (Domain Directory Generator) is a lightweight, open-source Command Line Interface (CLI) tool designed to eliminate manual boilerplate creation for Go applications. It targets developers looking to instantly spin up predictable, structured domain directories without the risk of copy-paste mistakes.

While built out of a personal need while developing high-conformance Go APIs using Gin and Bun ORM, rdev-go-ddgen is completely engine-agnostic and serves as a universal foundational bootstrapper.

The How: Rapid Deployment
You can install rdev-go-ddgen globally and immediately integrate it into your development workflow with a single command:

go install github.com/XaiPhyr/rdev-go-ddgen@latest

To Initialize folder structure

rdev-go-ddgen init

To scaffold a completely new, structured domain directory, simply initialize the tool and use the domain flag (-d):

rdev-go-ddgen -d orders

This single command instantly generates a pristine directory containing five core architectural layers, fully stubbed with basic functions and type declarations:

handler.go – API routing and transport logic.
service.go – Core business logic boundaries.
repository.go – Database abstraction and data access.
types.go – Domain-specific data models and structs.
_test.go – Unit and integration test placeholders.

Screenshot of commands

P.S. I hope this tool saves you some development time! rdev-go-ddgen is my first official contribution to the Go community, it’s a small step, but I'm incredibly excited to finally share something back with the ecosystem.

Top comments (0)