liveBook · Manning

Repository pattern

As explained in Effective Platform Engineering

A repository layer is an architectural layer that exposes datastore operations through repository abstractions to higher layers.

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).
A close-up of a text

AI-generated content may be incorrect.

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

How Effective Platform Engineering covers it

How deep it goes
Explains the layer arrangement, interface boundary, migration effect, and automated architectural checks, without detailing repository method implementations.
Examples
Uses GCP migration, AWS RDS for PostgreSQL, Aurora Serverless for MySQL, relational and unstructured datastores, and layered pseudocode.
What it assumes
Assumes familiarity with service layers, datastores, interfaces, and cloud technologies; teaches their dependency boundaries through the architecture.
What you can do after
Apply it via repository and datastore interfaces to change supported databases or clouds while minimizing service rewrites.
How it connects
Connects repository layers with datastore interfaces, service layers, architectural fitness functions, cloud migration, and database abstraction.

Also explained in

Compare how 9 books explain repository pattern →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Effective Platform Engineering. The section links point to the parts of the book it draws on.