Skip to content

Architecture Exercises

Apply clean architecture principles and common design patterns through these exercises.

ExerciseDifficultyTimeDescription
Clean LayersEasy20 minStructure code with domain, application, and infrastructure layers
Repository PatternMedium25 minImplement the repository pattern with interfaces
DI ContainerHard30 minBuild a simple dependency injection container
  • Clean Architecture: Separating concerns into layers
  • Dependency Rule: Inner layers don’t depend on outer layers
  • Repository Pattern: Abstracting data access
  • Dependency Injection: Providing dependencies from outside
  • Interface Segregation: Small, focused interfaces

Before starting these exercises, you should be comfortable with:

  • Go interfaces
  • Structs and methods
  • Chapter 8: Clean Architecture in Go
  • Chapter 9: Dependency Injection
  1. Start from the domain layer and work outward
  2. Define interfaces at the point of use, not implementation
  3. Keep your domain entities free of infrastructure concerns