A modern, modular Go web application boilerplate built with Fiber v3. It features a repository pattern, structured logging, background task processing, and a robust validation system.
- Framework: Fiber v3 for high-performance web routing.
- Architecture: Modular design with a clean separation of concerns (Controller, Service, Repository).
- Database:
- PostgreSQL with pgxpool for connection pooling.
- goqu for type-safe query building.
- goose for database migrations.
- Background Tasks: Asynq (Redis-based) for asynchronous job processing (e.g., sending emails).
- Security:
- JWT-based authentication.
- Password hashing with Argon2/Bcrypt (via custom hasher).
- Validation: validator/v10 with custom validators (e.g., database uniqueness checks).
- Logging: Structured logging with
slog, featuring a pretty-printed handler for development. - Configuration: Environment-based configuration using
koanf. - Mailing: SMTP-based mailer with support for both synchronous and asynchronous sending.
- Views: HTML templates support via Fiber's template engine.
- Go: 1.25.0+
- Database: PostgreSQL
- Cache/Queue: Redis
- Web Framework: Fiber v3
- ORM/Query Builder: Goqu
- Migrations: Goose
Before you begin, ensure you have the following installed:
- Go (1.25.0 or later)
- PostgreSQL
- Redis
gooseCLI (optional, but recommended for migrations)
-
Clone the repository:
git clone <repository-url> cd fiber_go
-
Configure Environment Variables: Copy the example environment file and update it with your settings:
cp .env.example .env
-
Install Dependencies:
go mod download
-
Run Database Migrations: Ensure your PostgreSQL instance is running and the database specified in
.envexists.make migrate_up
To run the API with hot reload (if configured) or simply via go run:
make run_apiTo compile the application into a binary:
make build_apiThe binary will be located in the bin directory.
├── assets/ # Static files (CSS, Images, etc.)
├── cmd/ # Application entry points
│ └── api/ # API server entry point
├── internal/ # Private application code
│ ├── app/ # App initialization, routes, and middleware
│ ├── config/ # Configuration schema and loading logic
│ ├── lib/ # Internal libraries (email, view, etc.)
│ └── modules/ # Business logic organized by domain (auth, user)
├── migration/ # Database migration files
├── pkg/ # Public/Shared packages
│ ├── db/ # Database connection management
│ ├── hasher/ # Security and hashing utilities
│ ├── http/ # HTTP DTOs, controllers, and common middleware
│ ├── log/ # Logger implementation
│ ├── mailer/ # SMTP mailer logic
│ ├── queue/ # Redis-based background queue
│ ├── storage/ # Generic repository and filtering logic
│ └── validation/ # Request validation and custom validators
├── resources/ # Templates and other non-code resources
└── Makefile # Build and development commands
Available make commands:
make run_api: Run the API server.make build_api: Build the API binary.make check_vulnerabilities: Scan dependencies for known security issues.make migrate_up: Apply all pending database migrations.make migrate_down: Roll back the last database migration.make migrate_status: Show current migration status.MIGRATION_NAME=name make migration_sql: Create a new SQL migration.
This project is licensed under the MIT License.
