Arquitectura de Datos

Data Mesh: Source-Aligned, Aggregate, and Consumer-Aligned Data Products, How to Design Data Products by Purpose

Understand the differences, ownership models, and design criteria for Source-Aligned, Aggregate, and Consumer-Aligned Data Products in Data Mesh to avoid redundant layers and duplicated business rules.

Content explored 0%
18px

The indicator keeps the furthest percentage explored; marking the article complete is your choice.

One month after the Sales, Payments, and Inventory domains published their first interoperable data products at CommerceFlow (sales-orders, confirmed-payments, and inventory-availability), five different downstream teams—Business Intelligence, Finance, Marketing Attribution, Logistics Forecasting, and the Fraud Machine Learning team—needed to answer a seemingly straightforward question: which orders are actually paid, net of cancellations and refunds?

Because the catalog contained only the three primary domain products, each of the five teams independently wrote its own SQL query joining sales-orders with confirmed-payments. Three weeks later, during the monthly executive review, a crisis of trust erupted: the executive dashboard, Finance's monthly pre-close, and Marketing's return-on-ad-spend report showed three different numbers for monthly paid sales. Auditing the queries revealed that Marketing forgot to deduct partial refunds, BI duplicated orders paid with a combination of a gift card and a credit card, and Logistics Forecasting filtered by cart creation date rather than payment settlement date.

To fix the discrepancy, an architect proposed swinging to the opposite extreme: forcing every single dataset in CommerceFlow to pass through three mandatory sequential layers (Source-Aligned $\rightarrow$ Aggregate $\rightarrow$ Consumer-Aligned) and forbidding any user from querying a Source-Aligned product directly. Within days, warehouse analysts who simply needed to check current stock in inventory-availability were forced to open tickets asking engineers to build two identical intermediate pass-through layers that added zero business value.

This dilemma illustrates why neither publishing isolated domain facts nor blindly copying a rigid multi-layer warehouse architecture is enough: we need to understand the purpose of Source-Aligned, Aggregate, and Consumer-Aligned Data Products, determine who should own each one, and decide when creating a derived data product is actually warranted.


The Three Data Product Orientation Patterns (and Why They Do Not Equal Bronze, Silver, and Gold)

In Data Mesh: Delivering Data-Driven Value at Scale, Zhamak Dehghani describes three common orientations based on how closely a data product aligns with operational origins versus specialized downstream consumption:

  1. Source-Aligned Data Products: Represent business facts and entities as known and originated by a specific domain (for example, sales-orders in Sales or confirmed-payments in Payments). They decouple consumers from the domain's private operational tables, providing a clean, documented, quality-guaranteed view of that domain's reality.
  2. Aggregate Data Products: Combine, correlate, or enrich data from multiple products (typically across different domains, or across complex sources within a domain) to materialize a new business concept with high cross-organization reusability. At CommerceFlow, paid-sales joins orders from Sales with settlements and refunds from Payments to provide a single reconciled truth for every paid sale.
  3. Consumer-Aligned Data Products: Designed and optimized to serve the specialized needs of a specific consumer group or downstream application, applying domain-specific consumption rules that would not make sense as a universal company definition. For example, finance-monthly-revenue applies accounting accrual rules, tax exclusions, and monthly cutoff logic for statutory financial reporting.

Two Essential Architectural Clarifications

Before designing any of these products, we must dispel two widespread industry misconceptions:

  • They are NOT equivalent to the Bronze, Silver, and Gold layers of a Data Lakehouse: In a traditional Medallion architecture, the Bronze layer holds raw, unvalidated landing data. In Data Mesh, a Source-Aligned Data Product is never a raw dump of dirty operational tables: it is already a first-class product backed by a contract, verified quality guarantees, clear semantics, and direct consumability.
  • They are NOT a mandatory sequential pipeline and do not require separate storage technologies: A consumer can and should read a Source-Aligned product directly whenever it already answers their question. Moreover, all three are logical design orientations rather than distinct physical engines: in an AWS cloud environment, sales-orders (Source-Aligned), paid-sales (Aggregate), and finance-monthly-revenue (Consumer-Aligned) can all be stored as Apache Parquet / Apache Iceberg tables on Amazon S3, registered in AWS Glue Data Catalog, and queried via Amazon Athena.
DimensionSource-Aligned Data ProductAggregate Data ProductConsumer-Aligned Data Product
Primary PurposeFaithfully expose primary business facts generated inside a domain with verified quality.Consolidate an entity or state requiring cross-domain correlation so 5 teams do not repeat the same join logic.Tailor and transform data according to the specialized rules of a specific consumption workflow (Finance, ML, executive reporting).
Typical InputsInternal operational systems of the owning domain (via CDC, events, or controlled extraction).Two or more Source-Aligned (or Aggregate) products consumed via their public interfaces.Source-Aligned and/or Aggregate products.
Typical OwnerThe domain where the operational facts originate (Sales, Payments, Inventory).The domain whose semantics govern the composite concept (e.g., Sales or Payments), never the infrastructure platform team.The domain or functional team holding expertise in the consumer's rules (e.g., Corporate Finance or Fraud ML).
Reusability ProfileVery high: serves as the foundation for multiple domains and direct analysis.High: reused by multiple consumers sharing the same cross-domain need.Targeted: optimized for a specific consumer or narrow family of use cases.
Risk if Poorly DesignedExposing private internal microservice schemas without cleansing or abstraction.Creating an "intermediate monolith" with ambiguous ownership or without enough consumers to justify its cost.Duplicating logic that belongs upstream or coupling other domains to a one-off report.

The Ownership Question in Derived Products: Who Is Accountable When Two Domains Meet?

A SQL query with a JOIN and a GROUP BY saved as a database view is not an Aggregate Data Product. For a derived dataset to qualify as a true Data Product, it requires the exact same commitments as a primary product: an accountable human owner (Data Product Owner), a support channel, freshness guarantees, change management, and explicit input/output contracts.

When an Aggregate product like paid-sales combines data from Sales and Payments, an immediate question arises: who owns it?

  1. Why it must NOT be owned by the Self-Serve Data Platform team: The platform team builds deployment, storage, and automated governance tooling, but it lacks the business context to decide whether an order with an open partial chargeback dispute counts as a "paid sale." If the platform team assumes ownership of paid-sales, it silently reverts into a centralized ETL team.
  2. How to assign the right owner: Ownership of an Aggregate product belongs to the domain that holds primary semantic authority over the resulting entity or leads the composite business process. For paid-sales, because the product's grain is the commercial order (order_id) enriched with its financial settlement state, CommerceFlow's federated forum assigns ownership to Sales, backed by a formal input contract on confirmed-payments from the Payments domain.

End-to-End Walkthrough: Product Topology at CommerceFlow

Let's see how to connect all three patterns at CommerceFlow without introducing artificial pass-through layers.

[Private Operational Systems]
   │                  │                     │
   ▼                  ▼                     ▼
┌──────────────┐  ┌────────────────────┐  ┌────────────────────────┐
│ sales-orders │  │ confirmed-payments │  │ inventory-availability │ ◄── Orientation:
│  (Sales)     │  │    (Payments)      │  │      (Inventory)       │     SOURCE-ALIGNED
└──────┬───────┘  └─────────┬──────────┘  └───────────┬────────────┘
       │                    │                         │
       └─────────┬──────────┘                         │ (Direct consumption
                 ▼                                    │  without extra layers)
       ┌────────────────────┐                         ▼
       │     paid-sales     │ ◄── AGGREGATE    [Warehouse Operational
       │  (Owner: Sales)    │                        Analytics]
       └─────────┬──────────┘
                 │
        ┌────────┴──────────────────────┐
        ▼                               ▼
┌──────────────────────────┐   [Marketing Attribution
│ finance-monthly-revenue  │    & Commercial BI Models]
│ (Owner: Finance Domain)  │
└──────────────────────────┘
        ▲
        └── Orientation: CONSUMER-ALIGNED

Notice two deliberate architectural decisions in this diagram:

  • inventory-availability is consumed directly by warehouse operational analytics without passing through any Aggregate or Consumer-Aligned wrapper, because the Source-Aligned product already provides the exact grain and semantics warehouse managers need.
  • paid-sales (Aggregate) is created because multiple downstream teams require reconciled order-to-payment truth; in turn, finance-monthly-revenue (Consumer-Aligned) is built on top of paid-sales because Finance applies accrual accounting rules that should not alter the commercial definition of a paid order used by Marketing.

Step 1: Baseline Source-Aligned Data Products

We start from the three Source-Aligned products published by their respective domains (stored as Apache Parquet on Amazon S3 and registered in AWS Glue Data Catalog):

  • sales.sales_orders (Grain: order_id): contains order_id, customer_id, primary_sku_code, order_placed_at_utc, order_fulfilled_at_utc (NULL if not yet shipped to the customer), currency_code, gross_order_amount, tax_amount, net_merchandise_amount, and order_lifecycle_status (CHECKOUT_COMPLETED, FULFILLED, CANCELLED).
  • payments.confirmed_payments (Grain: payment_capture_id): contains payment_capture_id, order_id, payment_settled_at_utc, currency_code, settled_amount, refunded_amount, gateway_fee_amount, and payment_settlement_status (BANK_SETTLED, REFUNDED_PARTIAL, REFUNDED_FULL).
  • inventory.inventory_availability (Grain: sku_code, warehouse_id): contains sku_code, warehouse_id, snapshot_recorded_at_utc, available_units, and stock_availability_status.

Step 2: Design and SQL Transformation of the Aggregate Product (paid-sales)

The sales.paid_sales aggregate product resolves the reconciliation between an order and its multiple payment captures or refunds once and for all. Its explicit semantic rules are:

  1. Grain: 1 row per order_id and currency_code.
  2. Handling split payments and refunds: Sums all bank-settled captures (settled_amount) and subtracts any refunded amount (refunded_amount) linked to the same order_id.
  3. Excluding unpaid cancellations: Excludes orders with zero net collected funds and classifies each order into an unambiguous composite state (PAID_IN_FULL, PAID_PARTIALLY_REFUNDED, UNDERPAID_DISCREPANCY).
-- Transformation building the Aggregate Data Product: sales.paid_sales
-- Owner: Sales Domain | Inputs: sales.sales_orders + payments.confirmed_payments
-- Assumption: Both input products comply with global identifier and ISO-4217 currency standards.
WITH payment_summary_by_order AS (
    SELECT
        order_id,
        currency_code,
        COUNT(payment_capture_id) AS capture_count,
        MIN(payment_settled_at_utc) AS first_payment_settled_at_utc,
        MAX(payment_settled_at_utc) AS last_payment_settled_at_utc,
        SUM(settled_amount) AS gross_settled_amount,
        SUM(COALESCE(refunded_amount, DECIMAL '0.0000')) AS total_refunded_amount,
        SUM(settled_amount - COALESCE(refunded_amount, DECIMAL '0.0000')) AS net_collected_amount,
        SUM(gateway_fee_amount) AS total_gateway_fee_amount
    FROM payments_prod.confirmed_payments
    WHERE payment_settlement_status IN ('BANK_SETTLED', 'REFUNDED_PARTIAL', 'REFUNDED_FULL')
    GROUP BY
        order_id,
        currency_code
)
SELECT
    o.order_id,
    o.customer_id,
    o.primary_sku_code AS sku_code,
    o.order_placed_at_utc,
    o.order_fulfilled_at_utc,
    p.first_payment_settled_at_utc,
    p.last_payment_settled_at_utc,
    o.currency_code,
    o.gross_order_amount,
    o.tax_amount,
    o.net_merchandise_amount,
    p.gross_settled_amount,
    p.total_refunded_amount,
    p.net_collected_amount,
    p.total_gateway_fee_amount,
    p.capture_count,
    o.order_lifecycle_status,
    CASE
        WHEN p.net_collected_amount >= o.gross_order_amount
             AND p.total_refunded_amount = DECIMAL '0.0000'
            THEN 'PAID_IN_FULL'
        WHEN p.net_collected_amount > DECIMAL '0.0000'
             AND p.total_refunded_amount > DECIMAL '0.0000'
            THEN 'PAID_PARTIALLY_REFUNDED'
        ELSE 'UNDERPAID_DISCREPANCY'
    END AS paid_order_reconciliation_status
FROM sales_prod.sales_orders AS o
INNER JOIN payment_summary_by_order AS p
    ON o.order_id = p.order_id
    AND o.currency_code = p.currency_code
WHERE p.net_collected_amount > DECIMAL '0.0000';

Thanks to sales.paid_sales, neither Marketing, nor BI, nor Data Science ever has to rewrite capture aggregation or partial refund deduction logic again: they all consume net_collected_amount and paid_order_reconciliation_status from this single aggregate product.

Step 3: Design and SQL Transformation of the Consumer-Aligned Product (finance-monthly-revenue)

Why can't the Corporate Finance team simply run SUM(net_collected_amount) on sales.paid_sales to file the company's monthly income statement for external audit? Because under accounting revenue recognition standards (such as IFRS 15 / ASC 606):

  1. Value-added or sales tax (tax_amount) collected on behalf of tax authorities is not company revenue.
  2. An order paid on November 30 whose physical merchandise has not yet shipped (order_fulfilled_at_utc IS NULL at month-end close) cannot yet be recognized as earned revenue for November: it must be booked as deferred revenue (a liability) until fulfillment occurs.

Because these accounting rules are specific to financial reporting, the Corporate Finance domain publishes the Consumer-Aligned product finance.finance_monthly_revenue consuming sales.paid_sales:

-- Transformation for the Consumer-Aligned Data Product: finance.finance_monthly_revenue
-- Owner: Corporate Finance Domain | Input: sales.paid_sales
-- Purpose: Monthly close of recognized net revenue vs. deferred revenue excluding taxes.
SELECT
    DATE_TRUNC('month', last_payment_settled_at_utc) AS accounting_period_month_utc,
    currency_code,
    COUNT(order_id) AS total_paid_orders_count,
    -- Recognized net revenue: paid orders fulfilled within the same accounting month or earlier
    SUM(
        CASE
            WHEN order_fulfilled_at_utc IS NOT NULL
                 AND DATE_TRUNC('month', order_fulfilled_at_utc) <= DATE_TRUNC('month', last_payment_settled_at_utc)
            THEN (net_collected_amount - tax_amount)
            ELSE DECIMAL '0.0000'
        END
    ) AS recognized_net_revenue_amount,
    -- Deferred revenue (liability): orders paid in the month but unshipped at month-end close
    SUM(
        CASE
            WHEN order_fulfilled_at_utc IS NULL
                 OR DATE_TRUNC('month', order_fulfilled_at_utc) > DATE_TRUNC('month', last_payment_settled_at_utc)
            THEN (net_collected_amount - tax_amount)
            ELSE DECIMAL '0.0000'
        END
    ) AS deferred_revenue_liability_amount,
    SUM(total_gateway_fee_amount) AS total_payment_processing_cost_amount
FROM sales_prod.paid_sales
WHERE paid_order_reconciliation_status IN ('PAID_IN_FULL', 'PAID_PARTIALLY_REFUNDED')
GROUP BY
    DATE_TRUNC('month', last_payment_settled_at_utc),
    currency_code;

This contrast makes the boundary crystal clear: paid-sales (Aggregate) consolidates cross-domain order and payment facts for the whole company, whereas finance-monthly-revenue (Consumer-Aligned) applies specialized accounting cutoff and tax rules for statutory financial reporting.

Step 4: Declarative Metadata for Basic Lineage, Orientation, and Ownership

So that the corporate catalog understands how these products connect, who maintains them, and who consumes them, each product declares its orientation and upstream input dependencies (upstream_products) in its YAML manifest:

# File: commerceflow-product-topology.yaml
# Purpose: Declaration of orientation, ownership, grain, and dependencies across Data Products.
catalog_topology_version: "1.0.0"

data_products:
  - product_id: "sales.sales_orders"
    orientation: "source_aligned"
    owner_domain: "sales"
    owner_team: "checkout-and-orders-squad"
    grain: ["order_id"]
    storage_format: "apache_parquet_s3"
    catalog_table: "sales_prod.sales_orders"
    upstream_products: []
    registered_consumers: ["sales.paid_sales", "customer-support-analytics"]

  - product_id: "payments.confirmed_payments"
    orientation: "source_aligned"
    owner_domain: "payments"
    owner_team: "payments-core-squad"
    grain: ["payment_capture_id"]
    storage_format: "apache_parquet_s3"
    catalog_table: "payments_prod.confirmed_payments"
    upstream_products: []
    registered_consumers: ["sales.paid_sales", "fraud-detection-service"]

  - product_id: "inventory.inventory_availability"
    orientation: "source_aligned"
    owner_domain: "inventory"
    owner_team: "wms-and-catalog-squad"
    grain: ["sku_code", "warehouse_id"]
    storage_format: "apache_parquet_s3"
    catalog_table: "inventory_prod.inventory_availability"
    upstream_products: []
    registered_consumers: ["warehouse-operations-bi", "supply-replenishment-ml"]

  - product_id: "sales.paid_sales"
    orientation: "aggregate"
    owner_domain: "sales"
    owner_team: "checkout-and-orders-squad"
    grain: ["order_id", "currency_code"]
    storage_format: "apache_parquet_s3"
    catalog_table: "sales_prod.paid_sales"
    upstream_products:
      - "sales.sales_orders"
      - "payments.confirmed_payments"
    registered_consumers:
      - "finance.finance_monthly_revenue"
      - "marketing-attribution-models"
      - "executive-commercial-bi"

  - product_id: "finance.finance_monthly_revenue"
    orientation: "consumer_aligned"
    owner_domain: "corporate_finance"
    owner_team: "financial-engineering-squad"
    grain: ["accounting_period_month_utc", "currency_code"]
    storage_format: "apache_parquet_s3"
    catalog_table: "finance_prod.finance_monthly_revenue"
    upstream_products:
      - "sales.paid_sales"
    registered_consumers:
      - "statutory-financial-reporting"
      - "board-quarterly-deck"

Automated Verification of the Data Product Dependency Graph

As Aggregate and Consumer-Aligned products grow, three architectural risks emerge that should be caught automatically in the platform pipeline:

  1. Derived products whose ownership is mistakenly assigned to the infrastructure team (data_platform).
  2. Aggregate or Consumer-Aligned products that declare no upstream inputs, or conversely, a Source-Aligned product that depends upstream on a Consumer-Aligned product (dependency inversion).
  3. Dependency cycles in the product graph.

The following Python script is self-contained (Python 3.10+) and validates these invariants across the declared topology:

# File: validate_product_topology.py
# Purpose: Verify design invariants across Source-Aligned, Aggregate,
# and Consumer-Aligned Data Products in the Data Mesh dependency graph.

from typing import Any


def validate_topology(topology: dict[str, Any]) -> list[str]:
    errors: list[str] = []
    products = {p["product_id"]: p for p in topology.get("data_products", [])}

    for pid, prod in products.items():
        orientation = prod.get("orientation")
        owner_domain = prod.get("owner_domain", "")
        upstreams = prod.get("upstream_products", [])
        consumers = prod.get("registered_consumers", [])

        # 1. Forbid the infrastructure platform team from owning business data products
        if owner_domain in {"data_platform", "infra_team", "unassigned", ""}:
            errors.append(
                f"[TOP-OWN-001] '{pid}' has an invalid owner_domain ('{owner_domain}'). "
                "Every product must belong to an accountable business or consumer domain."
            )

        # 2. Orientation coherence rules
        if orientation == "source_aligned" and upstreams:
            for up_id in upstreams:
                up_prod = products.get(up_id)
                if up_prod and up_prod.get("orientation") in {"aggregate", "consumer_aligned"}:
                    errors.append(
                        f"[TOP-INV-002] Source-aligned product '{pid}' must not depend "
                        f"upstream on a '{up_prod['orientation']}' product ('{up_id}')."
                    )

        if orientation in {"aggregate", "consumer_aligned"} and not upstreams:
            errors.append(
                f"[TOP-DEP-003] '{orientation}' product '{pid}' must declare at least "
                "one input product in 'upstream_products'."
            )

        # 3. Flag redundant 1-to-1 Aggregate wrappers with a single source and single consumer
        if orientation == "aggregate" and len(upstreams) < 2 and len(consumers) <= 1:
            errors.append(
                f"[TOP-RED-004] Aggregate product '{pid}' has only {len(upstreams)} source "
                f"and {len(consumers)} consumer. Consider consuming the source_aligned product directly."
            )

        # 4. Verify every product has at least one registered consumer
        if not consumers:
            errors.append(
                f"[TOP-CON-005] Product '{pid}' declares no registered consumers."
            )

    # 5. Cycle detection in the directed dependency graph (DFS)
    visited: set[str] = set()
    active_stack: set[str] = set()

    def has_cycle(node: str) -> bool:
        visited.add(node)
        active_stack.add(node)
        for neighbor in products.get(node, {}).get("upstream_products", []):
            if neighbor in products:
                if neighbor not in visited and has_cycle(neighbor):
                    return True
                if neighbor in active_stack:
                    return True
        active_stack.remove(node)
        return False

    for pid in products:
        if pid not in visited and has_cycle(pid):
            errors.append(f"[TOP-CYC-006] Dependency cycle detected involving '{pid}'.")

    return errors


if __name__ == "__main__":
    valid_topology = {
        "data_products": [
            {
                "product_id": "sales.sales_orders",
                "orientation": "source_aligned",
                "owner_domain": "sales",
                "upstream_products": [],
                "registered_consumers": ["sales.paid_sales"],
            },
            {
                "product_id": "payments.confirmed_payments",
                "orientation": "source_aligned",
                "owner_domain": "payments",
                "upstream_products": [],
                "registered_consumers": ["sales.paid_sales"],
            },
            {
                "product_id": "sales.paid_sales",
                "orientation": "aggregate",
                "owner_domain": "sales",
                "upstream_products": ["sales.sales_orders", "payments.confirmed_payments"],
                "registered_consumers": ["finance.finance_monthly_revenue", "marketing-bi"],
            },
            {
                "product_id": "finance.finance_monthly_revenue",
                "orientation": "consumer_aligned",
                "owner_domain": "corporate_finance",
                "upstream_products": ["sales.paid_sales"],
                "registered_consumers": ["board-reporting"],
            },
        ]
    }
    assert validate_topology(valid_topology) == []

    # Flawed topology: platform as owner, redundant 1-to-1 aggregate, and dependency inversion cycle
    flawed_topology = {
        "data_products": [
            {
                "product_id": "inventory.inventory_availability",
                "orientation": "source_aligned",
                "owner_domain": "inventory",
                "upstream_products": ["inventory.redundant_agg"],
                "registered_consumers": ["inventory.redundant_agg"],
            },
            {
                "product_id": "inventory.redundant_agg",
                "orientation": "aggregate",
                "owner_domain": "data_platform",
                "upstream_products": ["inventory.inventory_availability"],
                "registered_consumers": ["single-dashboard"],
            },
        ]
    }
    detected = validate_topology(flawed_topology)
    assert any("[TOP-OWN-001]" in e for e in detected)
    assert any("[TOP-INV-002]" in e for e in detected)
    assert any("[TOP-RED-004]" in e for e in detected)
    assert any("[TOP-CYC-006]" in e for e in detected)
    print("Topology validation completed. Errors detected in flawed topology:")
    for err in detected:
        print(" -", err)

Three Real-World Scenarios with Different Design Decisions

Scenario 1: Justified Creation of an Aggregate Data Product (CommerceFlow)

  • Situation: Four distinct areas at CommerceFlow (Finance, Marketing, Customer Support, and Data Science) need to join sales-orders and confirmed-payments daily to know which orders are paid in full.
  • Design decision: Build the sales.paid_sales Aggregate Data Product under the ownership of the Sales domain. The cost of maintaining one additional product is easily offset by eliminating four duplicated pipelines and guaranteeing a single reconciled figure across the company.

Scenario 2: Consumer-Aligned Product for a Clinical Machine Learning Model

  • Situation: In a hospital network, the Clinical AI squad trains a 30-day hospital readmission prediction model. The model requires a denormalized matrix of 65 numerical features normalized with exact point-in-time correctness at the minute of patient discharge, combining admissions, vitals, and lab results.
  • Design decision: No other team in the hospital needs those 65 floating-point ML features. Instead of polluting the Source-Aligned Lab or Admissions products with ML-specific statistical columns, the Clinical AI squad (acting as a consumer domain) builds and owns the Consumer-Aligned product clinical_ml.readmission_training_features, consuming the public interfaces of the upstream clinical domains.

Scenario 3: When a Simpler Alternative Is Sufficient (Direct Consumption of a Source-Aligned Product)

  • Situation: The warehouse operations team at CommerceFlow needs a daily dashboard showing available units per warehouse and SKU to schedule restocking shifts.
  • Design decision: The Source-Aligned product inventory.inventory_availability already publishes (sku_code, warehouse_id, available_units, snapshot_recorded_at_utc) with verified quality. Creating an Aggregate product named inventory-aggregated-stock and another Consumer-Aligned product named warehouse-shift-dashboard-product would duplicate storage, latency, and maintenance without adding a single new business rule. The dashboard queries inventory.inventory_availability directly via Amazon Athena.

Using Artificial Intelligence to Design and Audit Product Topologies

Large language models can help spot repeated SQL logic across consumer teams to surface candidates for Aggregate products, provided domain owners make the final ownership decision.

Prompt 1: Discovering Aggregate Data Product Candidates from Consumer Queries

Act as a data architect specializing in Data Mesh.
Context: Several analytics and data science squads are running their own SQL queries on top of our Source-Aligned products (`sales-orders`, `confirmed-payments`, `inventory-availability`).

Constraints:
- Analyze the following 4 SQL queries written by different consumer teams.
- Identify which subqueries, JOINs, or business rules are repeated across at least 2 teams.
- Evaluate whether that shared logic warrants extraction into a reusable Aggregate Data Product or whether direct queries suffice.
- If you propose an Aggregate Data Product, specify: its grain, key columns, upstream input products, and which domain should own it based on business semantics.

[PASTE THE 4 CONSUMER SQL QUERIES]

What a human must verify: Confirm that the consumer teams genuinely share the same temporal and business definition (for example, if two queries look similar syntactically but one requires real-time unconfirmed checkout orders while the other requires settled bank batches, forcing a single premature aggregate may serve neither team well).

Prompt 2: Reviewing Boundaries Between Aggregate and Consumer-Aligned Products

Act as a data product architecture reviewer.
Context: The Sales domain wants to add 12 specialized columns to the shared `sales.paid_sales` Aggregate product that are only used by an external advertising agency for a summer campaign, along with tax rules specific to a single country.

Constraints:
- Evaluate the impact of adding those columns and filters to the shared Aggregate product.
- Explain which logic belongs in `sales.paid_sales` (Aggregate) and whether the advertising or country-tax use case warrants a consumer view or a separate Consumer-Aligned Data Product.
- Justify the recommendation in terms of coupling, contract stability, and maintenance cost.

What a human must verify: Assess how many real consumers need the specialized columns and whether the requesting squad has the engineering capacity to maintain a dedicated Consumer-Aligned product or whether a simple query inside their own BI tool is sufficient.


Practical Application Exercises

Exercise 1: Classification and Ownership Assignment at CommerceFlow

Three new datasets are proposed at CommerceFlow:

  1. inventory.warehouse_stock_movements: immutable ledger of every physical inbound and outbound merchandise movement recorded inside warehouses.
  2. logistics.order_fulfillment_sla: combines sales.sales_orders with inventory.warehouse_stock_movements to compute elapsed time from customer checkout to warehouse dispatch, consumed by Customer Support, Operations, Executive Leadership, and Procurement.
  3. marketing.campaign_roas_attribution_q4: joins sales.paid_sales with social media ad clicks applying a proprietary 7-day last-touch attribution heuristic used exclusively by the Growth Marketing squad.

Question: Classify each of the three products as Source-Aligned, Aggregate, or Consumer-Aligned, and identify which domain or squad should own it.

Exercise 2: Diagnosing Reverse Dependency Coupling

To save time checking whether an order has reserved stock, an engineer in the Sales domain modifies the pipeline of the primary Source-Aligned product sales.sales_orders so that it reads a column directly from the Consumer-Aligned product finance.finance_monthly_revenue.

Question: Why does this dependency break the data product architecture, and what will happen during next month's financial close?

Exercise 3: New Data Product or Simple Consumer Query?

A business analyst on the commercial squad needs to know how many orders in sales.paid_sales exceeded 500 USD during Black Friday to include a summary table in a one-off Monday presentation. They ask the Sales squad to publish and maintain a new Consumer-Aligned Data Product named sales.black_friday_orders_over_500.

Question: Should the Sales Data Product Owner approve creating this new Data Product? Justify your answer using cost and reusability criteria.


Reasoned Solutions to the Exercises

Solution to Exercise 1

  1. inventory.warehouse_stock_movements $\rightarrow$ Source-Aligned Data Product: Directly reflects operational facts generated inside the Inventory domain boundary. Owner: Inventory domain.
  2. logistics.order_fulfillment_sla $\rightarrow$ Aggregate Data Product: Correlates facts from two distinct domains (Sales and Inventory) to materialize a composite operational metric with high reuse across four areas of the company. Owner: Inventory domain (or the Fulfillment / Logistics Operations subdomain accountable for dispatch SLAs).
  3. marketing.campaign_roas_attribution_q4 $\rightarrow$ Consumer-Aligned Data Product: Applies a consumer-specific heuristic (7-day attribution window for Growth Marketing) that is neither a universal accounting fact nor a logistics truth. Owner: Growth Marketing domain/squad.

Solution to Exercise 2

Making a Source-Aligned product (sales.sales_orders) depend on a Consumer-Aligned product (finance.finance_monthly_revenue) that is itself built on sales.paid_sales (derived from sales.sales_orders) introduces a circular dependency cycle (sales_orders $\rightarrow$ paid_sales $\rightarrow$ finance_monthly_revenue $\rightarrow$ sales_orders) and contaminates primary sales facts with monthly accounting cutoff rules. Source-Aligned products must only be fed from their domain's operational sources or authoritative master reference identifiers—never from downstream aggregate or consumer-aligned products.

Solution to Exercise 3

A new Data Product should NOT be created. A Data Product carries an ongoing commitment to maintenance, versioning, quality monitoring, catalog registration, and support. A one-off filter (WHERE net_collected_amount > 500) for a single presentation has zero cross-domain reuse and introduces no new domain semantics: the analyst should simply run a SELECT query against the existing SQL output port of sales.paid_sales. Creating a new Data Product for every ad-hoc filter turns the catalog into a graveyard of single-use tables.


When to Apply Each Pattern and Final Summary

To choose the right product orientation at each stage, apply these three practical rules:

  1. Always start with solid Source-Aligned products: Ensure each domain publishes its core facts and entities with verified quality, clear contracts, and interoperable identifiers before building derived layers.
  2. Promote logic to an Aggregate Data Product when you observe cross-team duplication or divergence: If two or more squads are rewriting the same complex cross-domain join (such as reconciled orders and payments) and arriving at conflicting numbers, package that logic into an Aggregate product with an explicit domain owner.
  3. Reserve Consumer-Aligned Data Products for specialized semantics with ongoing value: Create a consumer-aligned product when an area like Finance, Risk, or Machine Learning needs to recurrently transform and persist data under proprietary regulatory or mathematical rules—while never forcing simple single-domain lookups through three bureaucratic layers.

Loading conversation…

Keep learning