ADR-00040 — Customer Settings: Service Split and Partial-Update Semantics

By Engineering Team•October 10, 2026•5 min read
  • Status: Accepted
  • Date: 2026-10-10
  • Authors: Engineering Team

Context

The Flutter Settings feature area covers two very differently-shaped kinds of data: preference-shaped settings a shopper changes freely and often (region, fashion/size profile, notification toggles, saved addresses, saved payment-method references), and identity/credential-shaped data that’s gated behind verification or consent semantics (profile fields, phone/email change via OTP, Terms/Privacy acceptance). Both end up editable from the same Settings tab, which raises two separate, real decisions: where this data should live, and how its updates should be shaped over the wire.

Decision Drivers (FRs & NFRs)

Drivers come from SR-026:

  • FR-01, FR-03, FR-04, FR-05 — identity fields, OTP-commit phone/email change, and one-shot Terms/Privacy acceptance all carry verification or legal-acceptance semantics.
  • FR-06, FR-07, FR-08, FR-09, FR-10 — region, fashion profile, notifications, saved addresses, and saved payment-method references are freely-editable preferences with no verification gate.
  • NFR-01 — no client-held verification-ticket state; the commit must happen entirely server-side at the moment of OTP verification.
  • NFR-04 — every Terms/Privacy acceptance must be traceable to the exact policy version in effect at that moment.
  • NFR-07 — every read/write stays scoped to the shopper’s own tenant and identity.

Decision 1 — Where Settings data lives

Option 1 — One unified Settings service owning everything

Pros: A shopper’s entire settings surface is one API, one data store, one service to reason about. Cons (Why Rejected): It would need to re-implement, inside a brand-new service, capabilities user-secure-engine already owns and is the system of record for — Firebase token/identity handling, OTP issuance/verification, and PII encryption/decryption via its existing pii-service integration. Splitting identity-sensitive logic out of the service that already owns identity would duplicate that logic rather than share it, and would create two paths by which a shopper’s verified contact details could end up out of sync.

Option 2 — Split by identity/credential-sensitivity boundary (CHOSEN)

Preference-shaped settings (region, fashion/size profile, notifications, saved addresses, saved payment-method references) live in user-preference-service, which already owns the shopper’s standing preferences and is where [[Project: Mobile App Config Backend]]‘s broader preference work lives. Identity/credential/consent-gated settings (profile fields, phone/email OTP-commit change, Terms/Privacy acceptance) stay in user-secure-engine, which already owns Firebase token exchange, OTP, and PII encryption — the service is the natural, sole owner of anything that needs a verification or consent guarantee attached to it.

Pros & Accepted Trade-offs: No duplicated identity/verification/consent logic; each service’s data store only ever needs to satisfy the guarantees it already exists to provide (preference flexibility on one side, verification/consent integrity on the other). The trade-off is that the Flutter client talks to two services for one feature area instead of one — accepted because the client already composes multiple services for other features (e.g. TenantInfoService reading tenant-service for the same screens), and because SettingRepository/ProfileRepository/OtpRepository/ConsentRepository cleanly partition along the exact same boundary, so the split is invisible to any one screen’s own logic.

Decision 2 — Shape of the preference-update request

Option 1 — Full-document PUT, client resends the whole settings object

Pros: Simple, stateless, one obvious request shape. Cons (Why Rejected): user-preference-service’s settings object spans seven independent sections (region location, country, currency, language, address references, fashion profile, notifications), each editable from a different, independent control on the landing screen. A full-document PUT would force the client to always know and resend every other section’s current value just to change one toggle — and a client built against a slightly older section shape would silently clobber fields it doesn’t know about. This also directly conflicts with FR-07’s requirement that an unset, optional fashion field must never affect anything else — a full-document model has no clean way to represent “I’m not touching this” versus “I’m clearing this.”

Option 2 — One endpoint per settable field

Pros: Each change is its own precise, minimal request. Cons (Why Rejected): Seven sections, several of which (fashion profile, notifications) carry multiple independent fields apiece, would multiply into a long list of near-identical single-field endpoints — far more surface area than the actual rate of change in this data justifies, and out of proportion with how the rest of this service’s API is shaped.

Option 3 — RFC 7396 JSON Merge Patch (CHOSEN)

The update endpoint accepts a partial document under RFC 7396 Merge Patch semantics: a client sends only the keys it’s actually changing, and each section’s own strategy applies that partial update to just its own part of the stored settings, leaving every other section and every omitted field inside its own section untouched.

Pros & Accepted Trade-offs: One endpoint serves all seven sections without forcing the client to round-trip the full document first; an optional, never-set fashion field is simply never present in any request body rather than needing a special “don’t touch this” sentinel value, satisfying FR-07 directly. The trade-off — Merge Patch’s own well-known limitation that explicitly setting a field to null means “delete it,” so there’s no way to merge-patch a field to the literal value null — is accepted because no field in this settings shape has a meaningful null state; every field is either present with a real value or simply absent.

Final Decision

Settings persistence splits across user-preference-service (preference-shaped data) and user-secure-engine (identity/credential/consent-gated data), following each service’s existing ownership boundary rather than centralizing into a new unified service; user-preference-service’s update endpoint uses RFC 7396 JSON Merge Patch so any one of its seven independent sections can be updated without the client needing to know or resend the rest of the document.