Layrgo is an open-source CLI that scaffolds production-ready Go web APIs — clean architecture, Docker, and your choice of framework, database, and ORM, all generated in one command.
Quick start
Requires Go 1.23+.
go install github.com/samznd/layrgo/cmd/layrgo@latest
layrgo init
cd mywebapp
go run ./cmd
Verify the API is running:
curl http://localhost:3000/api/v1/message
# {"message":"data from repository"}
Interactive wizard
Running layrgo init prompts you for:
- Project name
- Web framework — Fiber, Gin, Echo, Chi, or Iris
- Database — Postgres, MySQL, or SQLite
- ORM — GORM, XORM, Ent, or none (
database/sql)
$ layrgo init
? What is your project name? mywebapp
? Choose your web framework: Gin
? Choose your database system: Postgres
? Would you like to use an ORM? Yes
? Choose your ORM framework: GORM
✅ Project "mywebapp" is ready (Gin + Postgres + GORM)
Non-interactive (CI & scripts)
layrgo init myapi --framework gin --database Postgres --orm GORM
What you get
- Clean architecture — handler → service → repository, pre-wired and ready to extend
- Your stack, your choice — framework, database, and ORM selected at init time
- Docker ready —
Dockerfileanddocker-compose.ymltailored to your database - Runnable immediately —
go run ./cmdworks right after scaffolding - Idiomatic layout — follows standard Go project conventions
Layrgo vs manual setup
| Without Layrgo | With Layrgo |
|---|---|
| Manually wire handlers, services, repos | Pre-wired handler → service → repository |
| Pick framework + DB + ORM from scratch | Choose your stack interactively or via flags |
| Write Dockerfile and compose yourself | Docker + compose generated per database |
| Hope the layout is idiomatic | Standard Go project layout out of the box |
Project structure
your-project/
├── cmd/main.go # Entry point with DI wiring
├── config/database.go # DB connection for your stack
├── internal/
│ ├── handlers/ # HTTP layer
│ ├── services/ # Business logic
│ ├── repositories/ # Data access
│ ├── routes/ # Route registration
│ ├── middleware/
│ └── models/
├── pkg/utils/ # Env loader
├── Dockerfile
├── docker-compose.yml
└── .env
New endpoints follow a predictable path: repository method → service → handler → route.
Supported stacks
| Layer | Options |
|---|---|
| Frameworks | Fiber, Gin, Echo, Chi, Iris |
| Databases | Postgres, MySQL, SQLite |
| ORMs | GORM, XORM, Ent, or database/sql via --no-orm |
CLI reference
| Command | Description |
|---|---|
layrgo init | Interactive wizard |
layrgo init myapp --flags | Non-interactive scaffold |
layrgo version | Print version |
layrgo --help | Show help |
| Flag | Values |
|---|---|
--framework | Fiber, Gin, Echo, Chi, Iris |
--database | Postgres, MySQL, SQLite |
--orm | GORM, XORM, Ent |
--no-orm | Use database/sql instead |
Contributing
git clone https://github.com/samznd/layrgo.git
cd layrgo
make install # build & install locally
make test # unit tests
make vet # static analysis
Roadmap
Shipped: multi-framework support · Docker per database · DI wiring · non-interactive flags
Planned: GraphQL scaffold · gRPC scaffold · SQLBoiler support
Open source under the MIT License.