Concept Flow - Repository pattern
Start
Service calls Repository
Repository handles data logic
Repository calls Database
Database returns data
Repository returns data to Service
Service returns data to Controller
Controller sends response
End
The Repository pattern separates data access logic from business logic by having the Service call the Repository, which interacts with the Database and returns data back.