A production-ready Go backend shardflow using Echo framework, PostgreSQL, and comprehensive observability features.
- Framework: Echo v4 for high-performance HTTP routing
- Database: PostgreSQL with connection pooling and migrations
- Observability: Structured logging with Zerolog, health checks, and metrics
- Configuration: Environment-based config with validation
- Middleware: CORS, rate limiting, request logging, error handling
- API Documentation: OpenAPI/Swagger UI
- Development Tools: Hot reload, linting, testing setup
- Go 1.21+
- PostgreSQL 12+
- Docker (optional, for local development)
-
Clone the repository
git clone <repository-url> cd shardflow
-
Set up environment variables
cp .env.sample .env # Edit .env with your configuration -
Install dependencies
go mod download
-
Set up database
# Ensure PostgreSQL is running # Run migrations (only in non-local environments) go-task migrate
-
Run the application
go-task run
The server will start on http://localhost:8080.
Configuration is managed through environment variables with the SHARDFLOW_ prefix. Key settings:
- Server: Port, timeouts, CORS origins
- Database: Connection details, pooling settings
- Observability: Logging level, service name, health checks
See .env.sample for all available options.
GET /status- Health check endpointGET /docs- OpenAPI documentation UIGET /static/*- Static file serving
go-task run- Start the development servergo-task build- Build the applicationgo-task test- Run testsgo-task lint- Run lintersgo-task migrate- Run database migrations
├── cmd/shardflow/ # Application entry point
├── internal/
│ ├── config/ # Configuration management
│ ├── database/ # Database setup and migrations
│ ├── handler/ # HTTP handlers
│ ├── logger/ # Logging setup
│ ├── middleware/ # Echo middlewares
│ ├── repository/ # Data access layer
│ ├── router/ # Route definitions
│ ├── server/ # Server setup
│ ├── service/ # Business logic
│ └── validation/ # Input validation
├── static/ # Static assets (OpenAPI docs)
├── .env.sample # Environment template
└── Taskfile.yml # Development tasks
- Structured JSON logs in production
- Console-formatted logs in development
- Request/response logging with latency and status
- Error stack traces
- Database connectivity checks
- Configurable check intervals and timeouts
- Follow Go best practices and project conventions
- Add tests for new features
- Update documentation as needed
- Run
go-task lintbefore committing