gobackend

command module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 4, 2026 License: MIT Imports: 5 Imported by: 0

README

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.

See the generated project's own README.md for how to add a new resource following the user example.

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

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
internal
generator
Package generator renders the embedded project template into a target directory, substituting the Go module path throughout.
Package generator renders the embedded project template into a target directory, substituting the Go module path throughout.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL