fibergen

command module
v1.4.4 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2025 License: MIT Imports: 13 Imported by: 0

README ΒΆ

FiberGen πŸš€

Codecov Go Report Card Go Reference Version

Generate Clean Architecture for REST API with support for Fiber Web Framework and gRPC in Golang. Speed up your development with automatic code generation.

✨ Features

  • πŸ—οΈ Clean Architecture - Automatically generates layered architecture structure
  • πŸ”Œ Fiber Framework Support - Optimized for the Fiber web framework
  • 🌐 gRPC Support - Built-in support for gRPC services (in-progress)
  • πŸ”„ CRUD Generation - Generate CRUD operations from JSON specifications
  • πŸ› οΈ Swagger CRUD Generation - Generate Swagger CRUD operations
  • 🧩 Modular Design - Feature-based modules for better organization
  • πŸ”§ Wire Integration - Dependency injection with Google Wire
  • ⚑ Fast Development - Speed up your development workflow

πŸ“¦ Installation

Latest version:

go install github.com/prongbang/fibergen@v1.4.3

For older projects:

go install github.com/prongbang/fibergen@v1.2.5

πŸš€ Quick Start

1. Create a New Project

Generate a new project with module structure:

fibergen -new test_project -mod github.com/prongbang

Parameters:

  • -new: Project name
  • -mod: Module name

This creates the following structure:

.
β”œβ”€β”€ Makefile
β”œβ”€β”€ cmd
β”‚     └── api
β”‚         └── main.go
β”œβ”€β”€ configuration
β”‚     β”œβ”€β”€ configuration.go
β”‚     β”œβ”€β”€ development.yml
β”‚     β”œβ”€β”€ environment.go
β”‚     └── production.yml
β”œβ”€β”€ deployments
β”‚     β”œβ”€β”€ Dockerfile
β”‚     └── api-prod.yml
β”œβ”€β”€ docs
β”‚     └── apispec
β”‚         β”œβ”€β”€ docs.go
β”‚         β”œβ”€β”€ swagger.json
β”‚         └── swagger.yaml
β”œβ”€β”€ go.mod
β”œβ”€β”€ go.sum
β”œβ”€β”€ internal
β”‚     β”œβ”€β”€ app
β”‚     β”‚     β”œβ”€β”€ api
β”‚     β”‚     β”‚     β”œβ”€β”€ api.go
β”‚     β”‚     β”‚     β”œβ”€β”€ example
β”‚     β”‚     β”‚     β”‚     β”œβ”€β”€ datasource.go
β”‚     β”‚     β”‚     β”‚     β”œβ”€β”€ example.go
β”‚     β”‚     β”‚     β”‚     β”œβ”€β”€ handler.go
β”‚     β”‚     β”‚     β”‚     β”œβ”€β”€ permission.go
β”‚     β”‚     β”‚     β”‚     β”œβ”€β”€ provider.go
β”‚     β”‚     β”‚     β”‚     β”œβ”€β”€ repository.go
β”‚     β”‚     β”‚     β”‚     β”œβ”€β”€ router.go
β”‚     β”‚     β”‚     β”‚     └── usecase.go
β”‚     β”‚     β”‚     └── routers.go
β”‚     β”‚     └── app.go
β”‚     β”œβ”€β”€ database
β”‚     β”‚     β”œβ”€β”€ db.go
β”‚     β”‚     β”œβ”€β”€ drivers.go
β”‚     β”‚     β”œβ”€β”€ mariadb.go
β”‚     β”‚     β”œβ”€β”€ mongodb.go
β”‚     β”‚     β”œβ”€β”€ wire.go
β”‚     β”‚     └── wire_gen.go
β”‚     β”œβ”€β”€ middleware
β”‚     β”‚     β”œβ”€β”€ api_key.go
β”‚     β”‚     β”œβ”€β”€ jwt.go
β”‚     β”‚     └── on_request.go
β”‚     β”œβ”€β”€ pkg
β”‚     β”‚     β”œβ”€β”€ casbinx
β”‚     β”‚     β”‚     └── casbinx.go
β”‚     β”‚     β”œβ”€β”€ response
β”‚     β”‚     β”‚     └── response.go
β”‚     β”‚     └── validator
β”‚     β”‚         └── validator.go
β”‚     └── shared
β”‚           └── example
β”‚               β”œβ”€β”€ datasource.go
β”‚               β”œβ”€β”€ example.go
β”‚               β”œβ”€β”€ provider.go
β”‚               └── repository.go
β”‚
β”œβ”€β”€ pkg
β”‚     β”œβ”€β”€ core
β”‚     β”‚     β”œβ”€β”€ common.go
β”‚     β”‚     β”œβ”€β”€ flag.go
β”‚     β”‚     β”œβ”€β”€ handler.go
β”‚     β”‚     β”œβ”€β”€ header.go
β”‚     β”‚     β”œβ”€β”€ jwt.go
β”‚     β”‚     β”œβ”€β”€ paging.go
β”‚     β”‚     β”œβ”€β”€ params.go
β”‚     β”‚     β”œβ”€β”€ request.go
β”‚     β”‚     β”œβ”€β”€ response.go
β”‚     β”‚     β”œβ”€β”€ router.go
β”‚     β”‚     └── sorting.go
β”‚     β”œβ”€β”€ multipartx
β”‚     β”‚     └── multipartx.go
β”‚     β”œβ”€β”€ requestx
β”‚     β”‚     └── request.go
β”‚     β”œβ”€β”€ schema
β”‚     β”‚     └── sql.go
β”‚     β”œβ”€β”€ streamx
β”‚     β”‚     └── streamx.go
β”‚     β”œβ”€β”€ structx
β”‚     β”‚     └── structx.go
β”‚     └── typex
β”‚         └── typex.go
β”œβ”€β”€ policy
β”‚     β”œβ”€β”€ model.conf
β”‚     └── policy.csv
β”œβ”€β”€ spec
β”‚     └── promotion.json
β”œβ”€β”€ wire.go
└── wire_gen.go
2. Generate Features Prototype

Generate a new feature module:

fibergen -f user

This creates:

test-project/internal/app/api/promotion
β”œβ”€β”€ datasource.go
β”œβ”€β”€ handler.go
β”œβ”€β”€ permission.go
β”œβ”€β”€ promotion.go
β”œβ”€β”€ provider.go
β”œβ”€β”€ repository.go
β”œβ”€β”€ router.go
└── usecase.go
3. Generate Features CRUD and Swagger

Generate CRUD operations from JSON specifications:

1. Define Spec File

Create spec/auth.json:

{
    "accessToken": "JWT",
    "expired": 1234567,
    "date": "2024-10-15T14:30:00Z"
}
2. Generate CRUD
  • SQL Builder
fibergen -f auth -s spec/auth.json -d mariadb -orm sqlbuilder
  • Bun
fibergen -f auth -s spec/auth.json -d mariadb -orm bun

This generates complete CRUD operations based on your JSON structure.

test-project/internal/app/api/promotion
β”œβ”€β”€ datasource.go
β”œβ”€β”€ handler.go
β”œβ”€β”€ permission.go
β”œβ”€β”€ promotion.go
β”œβ”€β”€ provider.go
β”œβ”€β”€ repository.go
β”œβ”€β”€ router.go
└── usecase.go
4. Generate Shared Prototype
fibergen -sh promotion

This generates shared prototype

test-project/internal/shared/promotion
β”œβ”€β”€ datasource.go
β”œβ”€β”€ promotion.go
β”œβ”€β”€ provider.go
└── repository.go
5. Generate Shared CRUD
  • SQL Builder
fibergen -sh promotion -s spec/promotion.json -d maridb -orm sqlbuilder
  • Bun
fibergen -sh promotion -s spec/promotion.json -d maridb -orm bun

This generates shared CRUD operations based on your JSON structure.

test-project/internal/shared/promotion
β”œβ”€β”€ datasource.go
β”œβ”€β”€ promotion.go
β”œβ”€β”€ provider.go
└── repository.go

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ’– Support

If you find this tool helpful, please consider buying me a coffee:

  • Fiber - Express-inspired web framework
  • Wire - Compile-time dependency injection
  • gRPC - High performance RPC framework

Documentation ΒΆ

The Go Gopher

There is no documentation for this package.

Directories ΒΆ

Path Synopsis
pkg
mod

Jump to

Keyboard shortcuts

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