The application layer contains service logic that coordinates capabilities while remaining independent of datastore functions. A service calls repository operations rather than coupling directly to a database implementation. section 2.3.3
This separation keeps service and repository code stable when the platform changes database technology or cloud provider. The repository depends on a datastore interface, while the service depends on the repository. section 2.3.3
A practical layered arrangement assigns responsibilities as follows:
- Handlers invoke service operations. section 2.3.3
- Services coordinate application behavior through repositories. section 2.3.3
- Repositories expose normal database methods through a datastore interface. section 2.3.3
Team onboarding API
A custom Teams API can construct a datastore, pass it to a teams repository, pass that repository to a team service, and pass the service to a handler. Replacing the datastore library then avoids rewriting service logic. section 2.3.3
Figure 2.12 When a particular service within the API needs to interact with the API database, it calls a repository function that provides all the normal database methods. The repository function would call the datastore functions for the type of database the API needs to use (relational or unstructured, in our case).
Trace the call path from an API service to repository methods and then to relational or unstructured datastore functions. section 2.3.3


