The **Repository** pattern acts as a mediator between the domain and data mapping layers. It provides an interface that behaves like an in-memory collection of objects.
Its goal is to hide the details of the persistence infrastructure (SQL, NoSQL, external APIs) and allow business logic to work with simple domain objects.
# Difference with DAO
While a **DAO** (Data Access Object) is typically a direct abstraction over a database table, a **Repository** is a higher-level abstraction oriented towards the domain. It may use multiple DAOs internally to reconstruct a complex object (Aggregate).
# Common Implementation
public interface CustomerRepository {
void add(Customer customer);
void remove(Customer customer);
Customer findById(String id);
List<Customer> findByStatus(Status status);
}