gobackend
A CLI that scaffolds a working Fiber + GORM + PostgreSQL backend skeleton — the same
layered architecture (config / constants / internal / migrations / seeds /
server(middleware, model, v1) / storage(repo, psql)) every time, so new projects
start from a consistent, already-wired structure instead of a blank folder.
The generated project is not a toy: JWT auth (access + refresh tokens), bcrypt
password hashing, Postgres via GORM, Redis, MinIO, a GORM query logger,
golang-migrate migrations that run on boot, a seed runner, and a Fiber server
with an example user resource wired end-to-end (repo → psql → storage →
handler → route) all compile and run out of the box.
Install
go install github.com/sattorovshoxrux3009/gobackend@latest
Requires Go 1.23+ (only for building the CLI itself — you can raise the
generated project's go.mod version independently).
Usage
Create a new project in a new directory:
gobackend new myapp
# or with an explicit module path:
gobackend new myapp --module github.com/you/myapp
Scaffold into the current (empty) directory instead:
mkdir myapp && cd myapp
gobackend init --module github.com/you/myapp
Both commands run go mod tidy automatically afterwards (skip with
--no-tidy).
cd myapp
cp .env.example .env # fill in your local Postgres/Redis/MinIO credentials
make run # applies migrations, seeds an admin user, starts the API
What you get
cmd/ entrypoint (wires config, db, redis, minio, server)
config/ env-based configuration (viper + godotenv)
constants/ shared constants (roles, pagination, messages)
internal/ auth (jwt/bcrypt), database (migrate runner), email (SMTP),
logger (async GORM query logger), minio, redis, websocket
migrations/ golang-migrate SQL migrations, applied automatically on boot
seeds/ one-off data seeders, run automatically on boot
server/ server.go (routes) + middleware/ + model/ (DTOs) + v1/ (handlers)
storage/ storage.go (aggregate interface) + repo/ (interfaces + models)
+ psql/ (GORM implementations)
Routes included out of the box: POST /api/v1/auth/{register,login,refresh,logout},
GET/PUT /api/v1/me, and an admin-only /api/v1/admin/users group demonstrating
AuthMiddleware + RequireRole.
Adding a resource
From the root of a generated project, generate resource (alias g r) adds a
new CRUD resource — storage/repo/<name>.go, storage/psql/<name>.go,
server/model/<name>.go, server/v1/<name>.go and a migration pair — and
wires the repo into storage/storage.go automatically:
gobackend generate resource product --fields "title:string,price:float64,description:text?,in_stock:bool"
--fields "name:type,..." — a trailing ? marks a field nullable. Supported
types: string, text, int, int64, float64, bool, time. Defaults
to a single title:string field if omitted.
--table — override the generated SQL table name (default: <name>s).
The command prints the exact server/server.go route group to paste in —
route registration is left manual since grouping/middleware varies per
project.
Other commands
gobackend list # print every file `new`/`init` would create, without touching disk
gobackend version # print version, commit and build date
Why
Built after repeatedly hand-copying the same folder structure across backend
projects. This packages that structure as a reusable, one-command generator
instead.
License
MIT