A modern Go web application boilerplate using Fiber framework with Uber FX dependency injection, MongoDB integration, and Swagger documentation.
- Fiber Framework: High-performance web framework
- Uber FX: Dependency injection for clean architecture
- MongoDB: NoSQL database integration
- Swagger: Automated API documentation
- Zap Logger: Structured logging
- Docker Support: Containerization ready
- GitHub Actions: Automated swagger generation
- Graceful Shutdown: Proper application shutdown handling
- Environment Config: Easy configuration management
- Health Check: Built-in health monitoring
├── .github/
│ └── workflows/ # GitHub Actions workflows
├── src/
│ ├── bootstrap/
│ │ ├── config/ # Application configuration
│ │ ├── logger/ # Zap logger setup
│ │ ├── mongodb/ # MongoDB connection
│ │ └── server/ # Fiber server setup
│ ├── internal/
│ │ ├── handler/ # HTTP request handlers
│ │ ├── middleware/ # Custom middlewares
│ │ ├── model/ # Data models
│ │ ├── repository/ # Data access layer
│ │ ├── routes/ # Route definitions
│ │ └── service/ # Business logic
├── docs/ # Swagger documentation
├── Dockerfile # Docker configuration
├── docker-compose.yml
├── .env.example # Environment variables template
└── main.go # Application entry point
- Go 1.21+
- MongoDB
- Docker (optional)
- Clone the repository
git clone https://github.com/yourusername/fiber-fx-boilerplate.git- Set up environment variables
cp .env.example .env
# Edit .env with your configurations- Run with Docker
docker-compose up --buildOR
- Run locally
go mod download
go run main.goGET /api/health- Health check endpoint
GET /api/foo- Get all itemsGET /api/foo/:id- Get item by IDPOST /api/foo- Create new itemPUT /api/foo/:id- Update existing item
Swagger UI is available at:
http://localhost:8090/swagger/
Documentation is automatically generated and updated via GitHub Actions.
Build and run with Docker:
# Build image
docker build -t fiber-fx-app .
# Run container
docker run -p 8090:8090 fiber-fx-appOr use docker-compose:
docker-compose upConfiguration is managed through environment variables:
| Variable | Description | Default |
|---|---|---|
| APP_ENV | Application environment | development |
| PORT | Server port | 8090 |
| MONGO_DB_URL | MongoDB connection URL | - |
| LOG_LEVEL | Logging level | info |
| QUERY_TIMEOUT | Database query timeout | 1m |
The project follows clean architecture principles:
- Handlers: HTTP request handling
- Services: Business logic implementation
- Repositories: Data access abstraction
- Models: Data structures
- Middleware: Request/Response processing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'feat: add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.