Layer-first
Top folders are the layers. The notes feature repeats inside each one, and wire mappers live in one shared file.
Layer-first is the horizontal tree. domain/, application/, infra/, and presentation/ are the top folders. notes is a folder inside each of them. app/ is the only place that constructs NoteRepositoryImpl.
This is the shape to copy from a Serverpod server whose modules repeat by layer: an endpoint under presentation/notes, a use case under application/notes, a port under domain/notes, and an impl under infra/notes. Wire mapping sits in presentation/mappers/wire_mappers.dart, one file for every endpoint, instead of beside a single feature.
The tree
lib/src/domain/notes/entities/note.dart
lib/src/domain/notes/note_repository.dart
lib/src/application/notes/save_note_use_case.dart
lib/src/application/ports/clock.dart
lib/src/infra/notes/note_repository_impl.dart
lib/src/presentation/notes/notes_endpoint.dart
lib/src/presentation/mappers/wire_mappers.dart
lib/src/app/use_cases.dart
lib/src/bootstrap/talaria_monitoring.dartThe package is examples/serverpod/layer_first. 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
- Pros and cons
- When to use it
- Domain
- Application
- Infrastructure
- Presentation
- Composition root
- Tests
- Talaria
Compare this tree with feature-first and hybrid. The chooser is the table of where a file sits.