Clean architecture

Hybrid

Domain, application, and infrastructure stay horizontal. The notes endpoint and its wire mapper are the feature slice.

clean-architectureserverpodhybrid

Hybrid keeps the inner rings horizontal and slices the outer edge by feature. domain/notes, application/notes, and infra/notes match the layer-first tree. presentation/notes/ holds the endpoint and the wire mapper together. There is no shared presentation/mappers/wire_mappers.dart.

app/ is still the only wiring site. A use case does not move into presentation/notes/ just because the endpoint lives there. If it does, the workflow has started to depend on the edge.

The tree

text
lib/src/domain/notes/entities/note.dart
lib/src/application/notes/save_note_use_case.dart
lib/src/infra/notes/note_repository_impl.dart
lib/src/presentation/notes/notes_endpoint.dart
lib/src/presentation/notes/wire_mappers.dart
lib/src/app/use_cases.dart
lib/src/bootstrap/talaria_monitoring.dart

The package is examples/serverpod/hybrid. From that directory, dart test runs the domain test, the use-case test with a fake repository, and one integration test through the endpoint.

Read this track

  1. Pros and cons
  2. When to use it
  3. Domain
  4. Application
  5. Infrastructure
  6. Presentation
  7. Composition root
  8. Tests
  9. Talaria

Compare this tree with layer-first and feature-first. The chooser is the table of where a file sits.