Skip to content
/ Architecture

Documentation

Architecture

The four layers and the dependency rule.

goclean follows Clean Architecture. The one rule that matters: source code dependencies point inward, toward the domain.

dependency direction
Delivery → Usecase → Domain ← Infrastructure

Domain

Entities and the repository interfaces they need. It imports nothing from the other layers, no frameworks and no database drivers.

Usecase

Application-specific business rules. A usecase receives repository interfaces and orchestrates domain entities.

Delivery

The HTTP layer, built for Gin or Chi. Handlers translate requests into usecase calls and usecase results into responses.

Infrastructure

Concrete implementations: database connections, GORM repositories, logging. It implements the interfaces declared by the domain.

Dependency injection

Dependencies are constructed in cmd/api and passed inward through constructors, so each layer stays easy to test in isolation.