Single source of truth

Single source of truth

What is Single source of truth principle?

For every data type defined in your app (i.e a Note or User type) you should assign a Single Source of Truth (SSOT) to it. So this SSOT is the owner of that data and only he can expose the data using a inmutable type, and to modify data the SSOT exposes methods that are accessible from other layers. (This should be the Repository calling an API or Dao for a data base).

In an offline-first application, the source of truth for application data is typically a database.

This pattern brings multiple benefits:

Relates to

References