Skip to content

Latest commit

ย 

History

History
109 lines (78 loc) ยท 3.4 KB

File metadata and controls

109 lines (78 loc) ยท 3.4 KB

๐Ÿงฎ Price Aggregator Architecture

This document defines the PriceAggregator business logic unit, its behavior, dependencies, data structures, and integration flow.


๐Ÿ”ง Overview

Unit Name: PriceAggregator

Type: Business Logic Unit (Microservice)

Purpose:
Consolidates raw price entries from various sources (e.g., Kroger, Amazon Fresh, User) into a unified, deduplicated format per ingredient and package type.


๐Ÿ“ฅ Inputs and ๐Ÿ“ค Outputs

๐Ÿ“ฅ Input Source

From: PriceSource Table

This is a raw ingestion table containing every known price record for ingredients.

๐Ÿ“ค Output Target

To: PriceAggregate Table

This is a filtered and computed table providing min/max/avg pricing for each unique product offering.


๐Ÿงช Logic Flow Diagram

flowchart LR
  subgraph  PriceAggregator [Business Logic Unit]
    PS["PriceSource (Raw Data)"]
    PA["PriceAggregate (Computed)"]
  end

  PS -->  PriceAggregator --> PA
Loading

๐Ÿ—ƒ๏ธ Entity Relationship Diagram (ERD)

erDiagram
    PriceSource {
        string ingredient
        string store
        float price
        string unit
        string package_size
        datetime updated_on
    }

    PriceAggregate {
        string ingredient
        string unit
        string package_size
        float price_min
        float price_max
        float price_avg
        float price_median
        float price_mode
        float price_std_dev
        integer price_count
        integer store_count
        float latest_price
        float earliest_price
        float price_range
        datetime calculated_on
    }

    PriceSource ||--o{ PriceAggregate : aggregates_into
Loading

๐Ÿ“Š Example

๐Ÿ“ฅ Input: PriceSource

Ingredient Store Price Unit Package Size Updated On
EGG Kroger 6.00 each 12 2025-06-14 10:00 AM
EGG Amazon Fresh 5.00 each 12 2025-06-14 10:01 AM
EGG Kroger 2.00 each 6 2025-06-14 10:02 AM

๐Ÿ“ค Output: PriceAggregate

Ingredient Unit Package Size Min Price Max Price Avg Price Median Price Mode Price Std Dev Price Count Store Count Latest Price Earliest Price Price Range Calculated On
EGG each 12 5.00 6.00 5.50 5.50 5.00 0.50 2 2 5.00 6.00 1.00 2025-06-14 13:00:00Z
EGG each 6 2.00 2.00 2.00 2.00 2.00 0.00 1 1 2.00 2.00 0.00 2025-06-14 13:00:00Z

๐Ÿ“Œ Notes

  • The PriceAggregator is the only unit allowed to touch PriceSource directly for core computation.
  • All other business logic units must consume from the PriceAggregate table.
  • Timestamp fields:
    • updated_on: When the price source entry was collected.
    • calculated_on: When the price aggregate record was last calculated.