Skip to content

Fiber backend template

go version go cover go report license

Fiber is an Express.js inspired web framework build on top of Fasthttp, the fastest HTTP engine for Go. Designed to ease things up for fast development with zero memory allocation and performance in mind.

  • Create a new project with Fiber:
cgapp create

# Choose a backend framework:
#   net/http
# > Fiber
  • Run Docker container with database (by default, for PostgreSQL):
make docker.postgres
  • Apply migrations:
make migration.up user=<db_user> pass=<db_pass> host=<db_host> table=<db_table>
  • Rename .env.example to .env and fill it with your environment values.

  • Run project by this command:

make run


Folder with business logic only. This directory doesn't care about what database driver you're using or which caching solution your choose or any third-party things.

  • ./app/controllers folder for functional controllers (used in routes)
  • ./app/models folder for describe business models and methods of your project
  • ./app/queries folder for describe queries for models of your project
  • ./app/validators folder for describe validators for models fields


Folder with API Documentation. This directory contains config files for auto-generated API Docs by Swagger.


Folder with project-specific functionality. This directory contains all the project-specific code tailored only for your business use case, like configs, middleware, routes or utils.

  • ./pkg/configs folder for configuration functions
  • ./pkg/middleware folder for add middleware (Fiber built-in and yours)
  • ./pkg/routes folder for describe routes of your project
  • ./pkg/utils folder with utility functions (server starter, error checker, etc)


Folder with platform-level logic. This directory contains all the platform-level logic that will build up the actual project, like setting up the database or cache server instance and storing migrations.

  • ./platform/database folder with database setup functions (by default, PostgreSQL)
  • ./platform/migrations folder with migration files (used with golang-migrate/migrate tool)
# .env

# Server settings:

# JWT settings:

# Database settings:
DB_SERVER_URL="host=localhost port=5432 user=postgres password=password dbname=postgres sslmode=disable"

# SMTP severs settings:
Name Version Type
gofiber/fiber v2.5.0 core
gofiber/jwt v2.1.0 middleware
arsmn/fiber-swagger v2.3.0 middleware
stretchr/testify v1.7.0 tests
dgrijalva/jwt-go v3.2.0 auth
joho/godotenv v1.3.0 config
jmoiron/sqlx v1.3.1 database
jackc/pgx v4.10.1 database
swaggo/swag v1.7.0 utils
google/uuid v1.2.0 utils
go-playground/validator v10.4.1 utils