Repository is a class which purpose is to provide a clean API for accessing data. What that means is that the Repository can gather data from different data sources(different REST APIs, cache, local database storage) and it provides this data to the rest of the app. The other components don’t know where the data comes from, they just consume it. It also serves as a single source of truth. Its role is to keep the local database up to date with the newest fetched data from remote service so that the application can still provide its functionalities with bad Internet connection or no connection at all.
Let’s look at an example where the ViewModel asks the Repository for data which will be visualized in the View.