Architecture: shop-service — Mobile Storefront Screen Delivery (GraphQL)
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

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/:
schema.resolvers.go’sGetShopSectionsbuilds 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 byquery_util.go’sgetRequestedFragments.shop_imp_svc.go’sgetShopProductSectionsis one long function with a sequence ofif f, ok := filter.Filters["new_arrivals"]; ok { ... }blocks — an if/else-if chain keyed by string, not polymorphic dispatch — populating fields directly on adomain.Shopstruct (shop.NewArrivals,shop.TopProducts, etc.).shop_mapper.go’sToShopSectionResponseListis a plainswitch sec.Section { case "NewItemsSection": ...; case "TopProductSection": ... }that turns the populateddomain.Shopfields into the union response, iteratingshop.Sections— the tenant’s ordered/active section list, sourced from thescreenscollection viascreen_section.go’sGetScreenSections→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
- 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). - The Flutter app opens the Shop screen and issues
getShopSections(screenType: "shop"), naming only the section fragments it needs (query_util.go’sgetRequestedFragments). GetShopSectionsreads the tenant’s active, ordered sections from thescreenscollection (screen_section.go) and its banners from thebannerscollection (banner_section.go), and populates every other requested section’s data viashop_imp_svc.go’s if/else-if chain againstproduct-catalog/inventory-service.shop_mapper.go’s switch converts the populated data into theShopSectionunion response in the tenant’s configuredDisplayOrder, skipping inactive sections; the four structural sections are always prepended regardless of configuration.ui-applicationreceives the union list;ShopSectionBuilder’s type-switch factory instantiates one concreteSectionComponentper returned section, andShopController/shop_view.dartcompose them into a single scrollable list (Composite pattern, FR-15).- Tapping “See All” on a section, or opening the Search screen, issues
searchProducts(filter: { sectionType, ... }), dispatched throughproduct_search_svc.go’s genuine Strategy registry to the matchingSectionSearchStrategy— the defaultGlobalSearchStrategycallssearch-serviceover gRPC;flash_sale/new_arrivals/etc. run their own strategy implementation. - Opening a product from any section loads the Product Detail screen via
getShopSections(screenType: "product", productId: ...), reusing the same resolver/assembly path withproductIdset.
Related Documents
- BRD-005 — Mobile App Storefront Configuration
- SR-005 — Mobile App Storefront Configuration System Requirements
- ADR-00006 — GraphQL for the Mobile Storefront API, REST for Admin
- Technical Debt — Mobile App Storefront Configuration Gaps
- Architecture: Product Catalog — Admin to Mobile Flow
- BRD-008 — Storefront Product Discovery Sections
- SR-008 — Storefront Product Discovery Sections System Requirements
- ADR-00016 — Query-Time Computation vs. a Dedicated Recommendation Engine for Storefront Merchandising Sections
- Technical Debt — Storefront Merchandising Section Accuracy Gaps
- Microservices: shop-service, search-service, product-catalog, inventory-service
- Mobile App Config Admin UI — Walkthrough Overview
- Flutter UI Walkthrough — Shop Screen (Home Dashboard)