# Client Stack

Clients are designed to be stacked one on top of each other. This way an application can make changes on the top layer, and only flush these changes to lower layers in batches and when considered necessary.

A default stack is built by the initDefaultClientStack(...) (opens new window) function.

This function will instantiate the following Client layers:

  • An on-memory ClientMutation as the top layer.
  • A local ClientMutation that persist changes on the browser IndexedDB
  • A ClientCache service that caches the perspective heads read from the ClientRemotes.
  • A ClientRouter service that routes mutations to their corresponding ClientRemote.
  • One or more ClientRemotes.

Besides the Clients stack, the app will also have an EntityResolver connected to some EntityRemotes.

The diagram below provides a detailed overview of the combination of multiple Client layers and the EntityResolver.

Some things to notice from the figure are:

  • The app interacts only with the EveesService.
  • There are two ClientMutation layers, one in memory, and the other one in the browser storage (indexedDB).
  • The EntityResolver is global, and is capable of resolving any Entity anywhere in the app.
  • There is one ClientRemote that uses the ClientRemoteLocal (opens new window) class, and one EntityRemoteLocal (opens new window). They both store the perspectives head and the entities in the browser storage.