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:

  1. Project name
  2. Web framework — Fiber, Gin, Echo, Chi, or Iris
  3. Database — Postgres, MySQL, or SQLite
  4. 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 readyDockerfile and docker-compose.yml tailored to your database
  • Runnable immediatelygo run ./cmd works right after scaffolding
  • Idiomatic layout — follows standard Go project conventions

Layrgo vs manual setup

Without LayrgoWith Layrgo
Manually wire handlers, services, reposPre-wired handler → service → repository
Pick framework + DB + ORM from scratchChoose your stack interactively or via flags
Write Dockerfile and compose yourselfDocker + compose generated per database
Hope the layout is idiomaticStandard 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

LayerOptions
FrameworksFiber, Gin, Echo, Chi, Iris
DatabasesPostgres, MySQL, SQLite
ORMsGORM, XORM, Ent, or database/sql via --no-orm

CLI reference

CommandDescription
layrgo initInteractive wizard
layrgo init myapp --flagsNon-interactive scaffold
layrgo versionPrint version
layrgo --helpShow help
FlagValues
--frameworkFiber, Gin, Echo, Chi, Iris
--databasePostgres, MySQL, SQLite
--ormGORM, XORM, Ent
--no-ormUse database/sql instead

Contributing

Built with Cobra and Survey.

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.

Star on GitHub · Open an issue · Submit a PR