# Repository
> [!Note]
> A **Repository** abstracts the **persistence layer** behind a collection-like interface, enabling retrieval and storage of [[Aggregate root]] by **identity**, and ensuring the domain model remains free from infrastructure concerns.
A **Repository** acts as the bridge between the in-memory domain model and the underlying data store, exposing methods to **add**, **remove**, and **find** [[Aggregate Root]] without leaking database details. By focusing on **identity-based access**, it allows the domain logic to request a specific [[Aggregate]] and trust that its complete, consistent state will be loaded. Similarly, saving changes routes through the **Repository**, which handles transactions and concurrency behind the scenes. This separation keeps the model clean, promotes testability via in-memory or mock implementations, and centralizes data access policies—such as caching strategies or query optimizations—away from business logic.
---
## References
- Vernon, V. (2016). _Domain-driven design distilled_. Addison-Wesley Professional.
- Vernon, V. (2013). _Implementing domain-driven design_. Addison-Wesley Professional.
- Khononov, V. (2021). _Learning domain-driven design: Aligning software architecture and business strategy_. O’Reilly Media.
- Alammar, J., & Grootendorst, M. (2024). _Hands-on large language models: Language understanding and generation_. O’Reilly Media.
- Evans, E. (2003). _Domain-driven design: Tackling complexity in the heart of software_. Addison-Wesley Professional.
- Millett, S., & Tune, N. (2015). _Patterns, principles, and practices of domain-driven design._ Wrox.