Hexagonal Boundaries
In production services, domain entities must remain strictly isolated from database drivers, HTTP routers, and third-party SDKs.
- Domain Layer: Pure business entities, state invariants, validation rules.
- Application Layer (Use Cases): Coordinates domain flows, defines outbound ports (interfaces).
- Infrastructure Layer (Adapters): PostgreSQL adapters, Kafka consumers, Stripe client implementations.
domain/article_repository.go
type ArticleRepository interface {
GetByID(ctx context.Context, id int64) (*Article, error)
Save(ctx context.Context, article *Article) error
}Personal engineering field notes compiled from production systems. Patterns and benchmarks are updated as runtimes evolve.