Architecture: shop-service — Mobile Storefront Screen Delivery (GraphQL)

By Engineering Team•September 26, 2026•8 min read

This is the architecture behind the decision recorded in ADR-00006, satisfying the requirements in BRD-005 and SR-005. The gRPC join between shop-service, product-catalog, and inventory-service for per-product descriptive/price data is already covered in Architecture-00004; this doc is scoped specifically to the layer above that join — how the tenant’s own screen/section/banner/category configuration turns into the actual GraphQL response the mobile app renders.

Diagram

Storefront architecture flow — shipment-service, product-catalog, inventory-service, and search-service feeding shop-service, which serves the Admin React app over REST and the Flutter app over GraphQL

The diagram draws search-service and shop-service connected by arrows in both directions. That’s not backed by code: shop-service dials search-service over gRPC for the default/global product search path, and search-service has no outbound client and no reference to shop-service anywhere in its source — the relationship is one-directional, shop-service → search-service only. Treat the diagram’s bidirectional arrow as a drawing simplification, not a second call path.

Components

Component Language / Runtime Role
shop-service Go (gqlgen) Exposes getShopSections/searchProducts over GraphQL to the mobile app, and the mobile-app-config/category-mapping REST admin API to the Admin app. Assembles a tenant’s Shop-screen sections from its own screens/banners/category_mappings MongoDB collections (see SR-005), joined at request time with product-catalog/inventory-service over gRPC.
search-service — gRPC server providing ProductSearchService/SearchProducts, called only by shop-service’s default (GlobalSearchStrategy) search path. Never calls shop-service.
ui-application (Mobile — Flutter) Flutter Requests only the section fragments relevant to the screen it’s rendering; renders the returned ShopSection union via a Composite widget hierarchy (SectionComponent base type + one concrete widget per section type), composed into a single scrollable list.
ui-admin-application (Admin — React) React (MUI + Zustand) REST client of shop-service’s mobile-app-config admin API — the configuration source this doc’s GraphQL layer reads from (see the Mobile App Config Admin UI walkthrough).
product-catalog, inventory-service, shipment-service Go Per-diagram gRPC sources shop-service joins against for descriptive, price/stock, and fulfilment data respectively. The product-catalog/inventory-service join is detailed in Architecture-00004; shipment-service’s specific role in section assembly was not re-verified in this pass.

GraphQL surface

shop-service/src/graph/schema.graphqls (gqlgen; resolvers in schema.resolvers.go) defines:

type Query {
  getShopSections(screenType: String!, productId: ID): [ShopSection!]!
  searchProducts(filter: SearchProductsFilterInput!, offset: Int!, limit: Int!): SearchProductsResult!
}

ShopSection is a GraphQL union of 13 types — CategorySection | BannerSection | TopProductSection | NewItemsSection | FlashSaleSection | FlashSaleDetailSection | MostPopularSection | JustForYouSection | RecentViewSection | ProductFullSection | CartSection | WishlistSection | DeliveryLocationSection — each with its own title/sectionType: String! plus type-specific fields. Most share a common Product type; FlashSaleSection deliberately uses its own isolated FlashSaleProduct type (mrp/sellingPrice/discountPercentage/discountLabels) rather than overloading the shared one.

How a Shop screen actually assembles — a dispatch routine, not a Strategy pattern

The section-assembly path for getShopSections is real, and does read the tenant’s configured order/active-flag from Mongo — but it is not a Strategy pattern. There is no interface with one implementation per SectionType. The real shape, spread across three files in internal/service/shop/ and internal/transport/api/shop/:

  1. schema.resolvers.go’s GetShopSections builds a hardcoded Go map keyed by GraphQL fragment name (e.g. "TopProductSection": {Type: "top_products", Limit: 6}, 13 entries) to decide what to fetch, based on which inline fragments the client actually requested — determined by query_util.go’s getRequestedFragments.
  2. shop_imp_svc.go’s getShopProductSections is one long function with a sequence of if f, ok := filter.Filters["new_arrivals"]; ok { ... } blocks — an if/else-if chain keyed by string, not polymorphic dispatch — populating fields directly on a domain.Shop struct (shop.NewArrivals, shop.TopProducts, etc.).
  3. shop_mapper.go’s ToShopSectionResponseList is a plain switch sec.Section { case "NewItemsSection": ...; case "TopProductSection": ... } that turns the populated domain.Shop fields into the union response, iterating shop.Sections — the tenant’s ordered/active section list, sourced from the screens collection via screen_section.go’s GetScreenSections → screenRepo.GetActiveSections(ctx, screenType) (this part of the tenant-configuration sourcing is accurate, and is what BRD-005/SR-005 Step 1 actually configures).

BannerSection is a genuinely separate, independently healthy subsystem — banner_section.go → repository/mobileappconfig/banner/, sourced from the banners collection.

ProductFullSection, CartSection, WishlistSection, and DeliveryLocationSection are prepended unconditionally by the resolver, bypassing the tenant’s screens configuration entirely — these are structural/utility sections (cart, wishlist, delivery-location context, the full product page itself), not tenant-orderable merchandising content, so this is consistent with BRD-005’s scope (only content sections are tenant-configurable) rather than a gap.

Call this a switch/map-dispatch data-assembly routine. Don’t describe it as a Strategy pattern in any downstream doc — that term is reserved for the mechanism below, which is a genuine implementation of it.

Where a Strategy pattern genuinely exists — searchProducts

internal/service/product_search/ defines IProductSearchService and a domain.SectionSearchStrategy interface with six concrete implementations, one file each: global_search_strategy.go, flash_sale_search_strategy.go, new_arrivals_search_strategy.go, top_products_search_strategy.go, just_for_you_search_strategy.go, recent_view_search_strategy.go. product_search_svc.go’s NewSectionSearchStrategies builds a real registry — map[string]domain.SectionSearchStrategy{"": globalStrategy, "flash_sale": ..., ...} — keyed on filter.sectionType, with "" defaulting to GlobalSearchStrategy. internal/repository/product_search/product_search_repo.go is where GlobalSearchStrategy’s data actually comes from: a gRPC dial to search-service’s ProductSearchService/SearchProducts. This is the mechanism the “See All” grids (Top Products, New Arrivals, Flash Sale, Just For You, Search) use, and it’s a real, extensible Strategy implementation — a new section’s search behavior is added as a new strategy file, never a new branch in an existing one.

Flutter’s rendering — a genuine Composite pattern

ui-application/src/lib/features/dashboard/section/section_component.dart defines abstract class SectionComponent extends StatefulWidget {} — the shared base widget type every concrete section renders as (SR-005 FR-15). shop_section_builder.dart’s ShopSectionBuilder.buildSection(ShopSectionModel section, ...) is a type-switch factory (if (section is XSectionModel) return XSection(...), not a map-based registry) that returns one concrete SectionComponent subclass per model type — CategoriesSection, FashionBannerCarousel, TopProductsSection, NewItemsSection, FlashSaleSection, MostPopularSection, CartSection, WishlistSection, ProductFullSection, one file each under features/dashboard/section/. ShopController holds final RxList<SectionComponent> uiSections = <SectionComponent>[].obs;, and shop_view.dart composes them into one Column via ...List<Widget>.from(sections). Shared base type + one leaf widget per section + a parent composing them into a single tree: a real Composite shape, even though the leaf is selected via an if/else type-switch rather than a registry lookup. The same ShopSectionBuilder is explicitly reused by FlashSaleController, cart_view.dart, and wishlist_view.dart.

GraphQL Fragments — not present today

No .graphql codegen files and no fragment X on Y { ... } definitions exist anywhere in ui-application. Every GraphQL query is a raw triple-quoted string embedded in a repository class (e.g. data/shop/shop_repository.dart’s GraphQLShopRepository.load, via graphql_flutter), using inline union-type conditions (... on CartSection { ... }, ... on TopProductSection { ... }) with each section’s product field list — id, title, price, imageUrl, discount, … — repeated verbatim per inline fragment rather than factored into a shared named fragment. Tracked as a gap against SR-005 FR-16, not documented as an existing pattern — see Technical Debt — Mobile App Storefront Configuration Gaps, TD-02.

End-to-end flow

  1. A tenant operator configures screen/section order and active state, banners, and category mappings via ui-admin-application → shop-service’s REST admin API (BRD-005/SR-005 FR-01–FR-11).
  2. The Flutter app opens the Shop screen and issues getShopSections(screenType: "shop"), naming only the section fragments it needs (query_util.go’s getRequestedFragments).
  3. GetShopSections reads the tenant’s active, ordered sections from the screens collection (screen_section.go) and its banners from the banners collection (banner_section.go), and populates every other requested section’s data via shop_imp_svc.go’s if/else-if chain against product-catalog/inventory-service.
  4. shop_mapper.go’s switch converts the populated data into the ShopSection union response in the tenant’s configured DisplayOrder, skipping inactive sections; the four structural sections are always prepended regardless of configuration.
  5. ui-application receives the union list; ShopSectionBuilder’s type-switch factory instantiates one concrete SectionComponent per returned section, and ShopController/shop_view.dart compose them into a single scrollable list (Composite pattern, FR-15).
  6. Tapping “See All” on a section, or opening the Search screen, issues searchProducts(filter: { sectionType, ... }), dispatched through product_search_svc.go’s genuine Strategy registry to the matching SectionSearchStrategy — the default GlobalSearchStrategy calls search-service over gRPC; flash_sale/new_arrivals/etc. run their own strategy implementation.
  7. Opening a product from any section loads the Product Detail screen via getShopSections(screenType: "product", productId: ...), reusing the same resolver/assembly path with productId set.