Echo Starter - Production Grade Go Boilerplate

A production-grade Go + Echo boilerplate for building scalable, testable, and maintainable backend applications.
This starter template is perfect for solo projects, team projects, or learning best practices in Go.
Features
- Clean Architecture: Well-organized folder structure following Go best practices
- Thin Entrypoint: Minimal
main.go with clear separation of concerns
- HTTP Server Lifecycle: Isolated server logic from business logic
- Layered Structure: Handlers, services, repositories for clean code
- Global Middleware: Built-in logger and recovery middleware
- Graceful Shutdown: Ready for production deployments
- Observability: Logger, tracing, and metrics support
- Background Jobs: Folder for Asynq workers
- Config Management: Environment variables and
.env support
- Modular & Testable: Easy to test and maintain
π Folder Structure
echo-starter/
βββ cmd/
β βββ server/ # Entry point (main.go)
βββ internal/
β βββ app/ # Application wiring / Dependency Injection
β βββ config/ # Configuration module
β βββ errors/ # Custom typed errors
β βββ handler/ # HTTP handlers
β βββ jobs/ # Background workers
β βββ middleware/ # Custom middleware
β βββ model/ # Domain models
β βββ observability/ # Logger / metrics / tracing
β βββ repository/ # Database access layer
β βββ server/ # Server lifecycle & route registration
β βββ service/ # Business logic
β βββ shutdown/ # Graceful shutdown logic
βββ migrations/ # Database migrations
βββ configs/ # Configuration templates
βββ scripts/ # Development / operations scripts
βββ test/ # Integration / end-to-end tests
βββ .env.example # Environment variables template
βββ Taskfile.yml # Task automation
βββ go.mod # Go module file
βββ go.sum # Go dependencies checksum
βββ README.md # This file
Quick Start
Folder Creation & Initial Setup
If starting from scratch, create the project structure:
# Create the directory structure
mkdir -p cmd/server internal/{app,config,errors,handler,jobs,middleware,model,observability,repository,server,service,shutdown} migrations configs scripts test
# Initialize Go module
go mod init github.com/yourusername/echo-starter
# Install dependencies
go mod tidy
Installation
-
Clone the repository:
git clone https://github.com/jabeedhexanovamedia/echo-starter.git
cd echo-starter
-
Install dependencies:
go mod download
-
Set up environment (optional):
cp .env.example .env
# Edit .env with your configuration
βΆ Running the Application
Start the server:
go run cmd/server/main.go
The server will start on http://localhost:8080 by default.
For development with hot reload (if using Taskfile):
task dev
Testing
Run tests:
go test ./...
For integration tests:
go test ./test/...
Configuration
The application uses environment variables for configuration. Create a .env file in the root directory:
# Server Configuration
PORT=8080
HOST=localhost
# Database
DB_HOST=localhost
DB_PORT=5432
DB_NAME=echo_starter
DB_USER=user
DB_PASSWORD=password
# Logging
LOG_LEVEL=info
# Other settings...
Development
Adding New Features
- Models: Define your domain models in
internal/model/
- Repositories: Implement data access in
internal/repository/
- Services: Add business logic in
internal/service/
- Handlers: Create HTTP endpoints in
internal/handler/
- Routes: Register routes in
internal/server/server.go
Database Migrations
Add migration files to the migrations/ directory and run them using your preferred migration tool.
Background Jobs
Implement workers in internal/jobs/ using Asynq or similar.
π€ Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature)
- Commit your changes (
git commit -m 'Add some amazing feature')
- Push to the branch (
git push origin feature/amazing-feature)
- Open a Pull Request
π Acknowledgments
- Echo Framework - High performance, extensible, minimalist Go web framework
- Go - The Go programming language
π License
This project is licensed under the MIT License - see the LICENSE file for details.
Made with β€οΈ for the Go community