SuperAPI AI Directory

ddd-repository-placement

Coding & development

View repository

Updated 10-15 22:39

About this skill

DDD Repository Placement

Repository placement should prevent domain models from reaching outward for data.

Placement Rules

  • Aggregate code: no repository dependencies.

  • Application/use-case layer: depends on repository interfaces and orchestrates loading/saving.

  • Domain layer: may define repository abstractions only when the project convention treats them as domain contracts, but aggregates still must not call them.

  • Infrastructure/interface adapters: implement repositories using databases, APIs, or files.

Workflow

  1. Find repository interfaces, implementations, and all call sites.

  2. Move calls from domain objects into use cases or domain services invoked by use cases.

  1. Keep persistence mapping outside aggregates.

  2. Align package placement with the project's architecture style.

Detailed Reference

For non-trivial implementation, review, or refactoring work, read references/details.md before giving final guidance. It contains the detailed rules, examples, smells, and migration notes that do not belong in the short invocation body.

Output

Return a placement map, violations, corrected dependencies, and file moves.