user-preference-service — Wishlist, Recent View, and Settings

By Engineering Team•October 10, 2026•5 min read

Responsibility

user-preference-service owns any data that is personal to a (tenant_id, user_id) pair rather than belonging to a product, cart, or order — current scope is Wishlist, Recent View, and Settings (region / addresses / card references / fashion profile / notifications). Product recommendations are named as future scope and not implemented.

  • Wishlist — SKU-level toggle (POST /api/v1/wishlist/:productId/:skuId), validated against inventory-service’s ReportQueryService.GetSkusByIDs on add; a gRPC WishlistService.GetWishlistedSkuIDs serves shop-service’s WishlistSection/heart-icon resolution.
  • Recent View — product-level only (no SKU), populated by consuming a Pub/Sub event product-catalog publishes on GetProductFullDetail, capped at 50 items, most-recent-last with re-view-moves-to-end semantics; served to shop-service via RecentViewService.GetRecentlyViewedProductIDs.
  • Settings — one document per (tenant_id, user_id) holding region, address references, card references, fashion profile, and notification toggles. Patched via RFC 7396 JSON Merge Patch, one SectionStrategy per section, so a partial update never rewrites or re-timestamps an untouched section (see ADR-00040).
  • Address bodies are never stored locally — every field is pushed to pii-service as encrypted attributes (entity_type="user_address") and hydrated back on read; this service’s own Mongo document keeps only address_id + billing/shipping flags.
  • Card bodies are never stored at all here — only cardId/createdAt references; the card body itself lives exclusively in pci-service and is never hydrated back to the mobile client.

Tech Stack

Concern Choice
Language Go
Data store MongoDB
HTTP Echo (REST)
gRPC Server (Wishlist/RecentView/Setting services) + Client (to inventory-service, for SKU validation)
Messaging Pub/Sub receiver (Firebase), consumes product-catalog’s recent-view event
DI Uber Fx
Template @templates/go-mongo-microservice, gRPC layers composed from @templates/go-grpc-microservice

Ports

Gateway HTTP gRPC Service Name
8000 (Nginx /user-preference/*) 8089 50056 user-preference-service

GRPC_INVENTORY_URL points at inventory-service’s ReportQueryService (default inventory-service:50052 in Docker).

API Endpoints

Method Path Purpose
POST /api/v1/wishlist/:productId/:skuId Toggle wishlist membership for a SKU
GET /api/v1/settings Read the caller’s settings document, with address references hydrated from pii-service
PATCH /api/v1/settings RFC 7396 Merge Patch — updates only the sections/fields present in the body
DELETE /api/v1/settings/addresses/:addressId Remove an address reference and its pii-service attributes
gRPC Service Method Consumer
WishlistService GetWishlistedSkuIDs shop-service (WishlistSection, ProductFullSection, CartSection heart-icon state)
RecentViewService GetRecentlyViewedProductIDs shop-service (RecentViewSection, “see all” pagination)
SettingService GetAddresses shop-service (checkout/order flow default billing/shipping resolution)

Data

Collection Purpose
wishlists One document per (tenant_id, user_id); items[] of {product_id, sku_id, created_at, updated_at}.
recent_views One document per (tenant_id, user_id); items[] of up to 50 {product_id, created_at, updated_at}, oldest evicted.
settings One document per (tenant_id, user_id); region/address-references/card-references/fashion-profile/notification sections, each owned by its own SectionStrategy. Address/card bodies are never present here — only references.

Real Consumers

Consumer Transport Usage
ui-application (Flutter) REST Wishlist toggle, Settings landing screen + Address/Payment sub-screens
shop-service gRPC Wishlist heart-icon resolution, Recent View sections, checkout address resolution
inventory-service gRPC (client of) SKU existence/ownership validation on wishlist add
pii-service gRPC (client of) Encrypted address-body storage/hydration under entity_type="user_address"
product-catalog Pub/Sub Publishes the recent-view event this service consumes

Implementation Notes

  • Address attribute keys (domain/setting.go) replaced a former single name key with separate first_name/last_name — an address saved before that rename resolves both to "" until re-saved; see TD-00020, TD-06.
  • AddressBody.Validate checks only line1, city, firstName, lastName, phoneNumber as required, and format-checks pincode (6 digits) only when present — it does not reject a non-Indian postal code shape, even though the Flutter client’s own validator does; see TD-00020, TD-05.
  • grpc/setting.proto declares package setting, not userpreference.setting like the other two protos — SettingService.GetAddresses resolves at /setting.SettingService/GetAddresses; a client copy that doesn’t match this exactly resolves to Unimplemented.
  • tenant_id/user_id for every gRPC method are read from incoming metadata, never the request message — consistent with every other cross-service gRPC call in this monorepo.

Architecture overview: Architecture — Customer Settings: Component Topology and Data Flow.