Tutorials

Build a catalog data layer

Assemble a domain Repository, remote and cache DataSources, mapping, observation, and shutdown.

v0.1.0-dev.1Intermediateark_data_layer

Build a catalog data layer

01

Declare the domain contract

Put CatalogRepository, CatalogData, and domain entities in the Domain layer. Expose only the current data, its stream, and business operations such as synchronize().

02

Declare technical source contracts

Create CatalogRemoteDataSource for network records and CatalogCacheDataSource for local records. Keep DTOs beside the technical boundary that owns them.

03

Implement the concrete Repository

Resolve both source contracts in the constructor. Read the cache for immediate data, fetch the remote representation, map it into domain entities, write the cache, and call setData only with domain data.

04

Choose a concurrency policy

If two refresh calls may overlap, decide explicitly whether to serialize, cancel older work, compare revisions, or accept last-completion-wins. The base Repository does not guess this policy.

05

Compose and close the graph

Build the sources, container, and Repository in the Composition Root. Cancel consumers first, close the Repository next, then close the source clients that the outer scope owns.

ARKTELOS

Purpose-built engineering systems for software that has to hold.