A robust Go application boilerplate implementing Clean Architecture principles with FastHTTP framework.
├── api # HTTP API layer
│ ├── controller # Request handlers
│ ├── middleware # HTTP middleware
│ └── route # Route definitions
├── bootstrap # Application bootstrapping
├── cmd # Main applications
├── domain # Enterprise business rules and entities
├── infrastructure # External tools and libraries
├── pkg # Common utilities and helpers
├── repository # Data access layer
└── usecase # Application business rulesThis project follows Clean Architecture principles with the following layers:
-
Entities/Domain Layer (
domain)- Contains enterprise-wide business rules
- Defines core business entities and interfaces
- Has no dependencies on external layers
-
Use Cases Layer (
usecase)- Contains application-specific business rules
- Orchestrates data flow between entities
- Implements business logic
-
Interface Adapters Layer (
api,repository)- Contains adapters that convert data between use cases and external agencies
- Implements repository interfaces
- Handles HTTP routing and controllers
-
Infrastructure Layer (
infrastructure,pkg)- Contains frameworks, tools, and helpers
- Database implementations
- External services integration
-
Repository Pattern
- Abstracts data persistence operations
- Defined in
repository - Interfaces in
domain
-
Dependency Injection
- Used throughout the application
- Dependencies are initialized in
bootstrap - Promotes loose coupling and testability
-
Factory Pattern
- Used in bootstrapping components
- Creates instances of repositories and use cases
-
Middleware Pattern
- HTTP middleware implementations
- Request/Response processing
- Go 1.23.4 or higher
- PostgreSQL
- Docker (optional)
cp .env.example .env
# Edit .env with your configurations- Using Go directly:
make run- Using Docker:
docker-compose upmake build- Clean Architecture implementation
- FastHTTP for high-performance HTTP handling
- PostgreSQL integration with transaction support
- Structured logging with Zap
- Environment configuration management
- Encryption support for PII data
- Request/Response middleware
- Graceful shutdown
fasthttp- High-performance HTTP serverzap- Structured loggingpq- PostgreSQL driverencryption-pii- PII data encryptiongo-envconfig- Environment configuration
-
Adding New Features
- Add domain entities in
domain - Implement use cases in
usecase - Add repository implementations in
repository - Create API routes in
api/route
- Add domain entities in
-
Testing
make testMIT License