---
# System prepended metadata

title: Repository

---


# Repository

## Context

Describe the design context that justifies the selection of the pattern.

Repositories are classes or components that encapsulate the logic required to access data sources. They centralize common data access functionality, providing better maintainability and decoupling the infrastructure or technology used to access databases from the domain model layer.

In this module, the Repository pattern helps decouple the access to the different APIs of the other modules, essencially seperating concerns of how to fetch the required information from each individual API endpoint.

Repository pattern are mostly used where we need to modify the data before passing to the next stage. It centralizes data logic or business logic and service logic. It gives a substitution point for the unit tests. Provides a flexible architecture.

## Mapping

Explain how are mapped the pattern's roles, operations, and associations to the concrete design classes.

## Consequences

Explain the benefits and the liabilities of instantiating the pattern, eventually in comparison with other alternatives.



## Notes about this template

Documenting pattern instances is an important activity because it will help other developers to better understand the resulting concrete classes, attributes and methods, and the underneath design decisions. 

This provides a level of abstraction higher than the class level, highlighting the commonalities of the system and thus promoting the understandability, conciseness, and consistency of the documentation. 

At the same time, the documentation of pattern instances will help the designer instantiating a pattern, to certify himself that he is taking the right decision. 

In general terms, this results in better communication within the development team, and consequently on fewer bugs.
To more formally document a pattern instance we must describe the design context, to justify the selection of the pattern, to explain how the pattern roles, operations, and associations were mapped to the concrete design classes, and to state the benefits and liabilities of instantiating the pattern, eventually in comparison with other alternatives.