The repository pattern places a repository layer between services and datastore implementations, exposing consistent operations while hiding database-specific details. This abstraction supports cloud or database migration without rewriting service code. section 2.3.3
A platform can provide datastore implementations and repository abstractions for supported technologies. Services call repository functions; repositories call a datastore interface selected for the required cloud and database. 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 how service database calls pass through repository functions to relational or unstructured datastore implementations. section 2.3.3
Cloud and database migration
A service can move between GCP and another cloud, or change from AWS RDS for PostgreSQL to Aurora Serverless for MySQL, by rebuilding with a different datastore library. section 2.3.3
Validate the layering with architectural fitness functions:
- Allow handlers to access services, services to access repositories, and repositories to access datastores through explicitly defined layer rules. section 2.3.3








