Learn

Learn Ark Data Layer

Understand the boundaries, contracts, observable state, and ownership model behind ark_data_layer.

v1.1.0Beginner

Learn Ark Data Layer

Ark Data Layer supplies mechanics for concrete Repository implementations. It does not move persistence concerns into the domain or turn DataSourceContainer into an application-wide service locator.

Start with the problem

A catalog feature may read cached records, refresh them from an API, map transport DTOs into domain entities, expose the latest domain snapshot immediately, and notify background consumers after a successful commit. Without a clear boundary, network models leak into business code, several storage clients become an untyped bag, and every Repository invents different observation and shutdown behavior.

Ark Data Layer separates that work into three roles:

text
Remote / cache / database implementation
        implements a narrow DataSource contract
                         ↓
concrete Repository coordinates sources and maps technical data
                         ↓ commit
domain Data is readable synchronously and observable as a Stream

DataSourceContainer belongs to one Repository or one tightly bounded data component. It is constructor wiring for technical sources, not a substitute for application DI.

What the package standardizes

ConcernPackage decisionApplication decision
Source lookupExact typed resolution with missing and ambiguity errorsWhich source contracts exist
Current dataOne latest committed valueThe immutable domain shape
ObservationReplay-latest broadcast StreamWhich consumers subscribe
UpdatesExplicit setData or updateData commitsMapping, caching, and concurrency policy
ShutdownIdempotent Repository closeOwnership and order of the wider object graph
  1. Getting started builds one small but complete Repository.
  2. Architecture and boundaries assigns responsibilities to Domain, Data, Application, and Composition layers.
  3. DataSource contracts explains narrow technical contracts and strict resolution.
  4. Repository and domain interfaces separates the reusable base from the business-facing abstraction.
  5. Observable data and lifecycle defines replay, ordering, closing, and ownership.

Continue with Tutorials when you need a complete project flow, or open Recipes for one focused operation.

If you only need to call one client and return its result, a Repository base may add no value. Use Ark Data Layer when the component owns domain-facing current data, coordinates more than a trivial adapter, or needs a consistent observable lifecycle.