Skip to content

Instantly share code, notes, and snippets.

@CiprianSpiridon
Last active June 3, 2025 05:57
Show Gist options
  • Save CiprianSpiridon/e7452eff282d04fc054820933c32c49c to your computer and use it in GitHub Desktop.
Save CiprianSpiridon/e7452eff282d04fc054820933c32c49c to your computer and use it in GitHub Desktop.
price-matching-explained-simply

Mumzworld Price Matching System - Explained Simply

A non-technical guide to understanding how our automated price matching works


🎯 What Does This System Do?

Imagine you're running a store and want to make sure your prices are competitive with other stores in the mall. Instead of manually checking every competitor's price every day, you hire a team of assistants to:

  1. Check competitor prices hourly across all your products
  2. Compare prices and find the best deals
  3. Apply smart business rules to decide if you should match those prices
  4. Update your prices automatically when it makes business sense

That's exactly what this system does for Mumzworld - but for thousands of products across UAE and Saudi Arabia, 24/7.


πŸͺ The Players in Our System

Our Store (Mumzworld)

  • UAE Store: mumzworld.com for UAE customers
  • Saudi Store: mumzworld.com/sa for Saudi customers

Competitor Stores We Watch

  • Amazon (UAE & Saudi versions)
  • Noon (UAE & Saudi versions)
  • FirstCry (UAE & Saudi versions)
  • Nahdi Online (Saudi only)

Our Products

  • Example: Baby stroller SKU "ABC123"
  • Cost Price: What we paid for it (including shipping, taxes)
  • Current Selling Price: What customers see on our website

πŸ”„ The Complete Price Matching Journey

Let's follow a single product through the entire process:

Step 1: The Hourly Check πŸ•

graph TD
    A[⏰ Every Hour] --> B[πŸ“‹ Get All Products]
    B --> C[🎯 For Each Product & Country]
    C --> D[πŸ“€ Send Scouts to Check Prices]
    D --> E[πŸͺ Check Our Own Website]
    D --> F[πŸ›’ Check Amazon]
    D --> G[πŸ›οΈ Check Noon]
    D --> H[πŸ‘Ά Check FirstCry]
    
    style A fill:#e1f5fe
    style B fill:#f3e5f5
    style C fill:#e8f5e8
Loading

What happens here? Every hour, our system creates a "to-do list" of all products that need price checking. For each product, it sends out "scouts" (automated checkers) to visit competitor websites and our own website to see current prices.

Step 2: Gathering Intel πŸ•΅οΈ

sequenceDiagram
    participant S as System
    participant A as Amazon Scout
    participant N as Noon Scout  
    participant F as FirstCry Scout
    participant M as Mumzworld Scout
    
    S->>A: Check price for Baby Stroller ABC123
    S->>N: Check price for Baby Stroller ABC123
    S->>F: Check price for Baby Stroller ABC123
    S->>M: Check our current price
    
    A-->>S: Found: $150 (was $180)
    N-->>S: Found: $155 (no discount)
    F-->>S: Out of stock
    M-->>S: Current: $165 (was $170)
Loading

What happens here? Each scout visits their assigned website and reports back:

  • What's the current price?
  • Is there a discount active?
  • Is the product in stock?
  • When did they check this information?

Step 3: Waiting for Everyone 🏁

graph LR
    subgraph "Completion Tracker"
        A[βœ… Amazon: Done]
        B[βœ… Noon: Done]
        C[❌ FirstCry: Checking...]
        D[βœ… Mumzworld: Done]
    end
    
    E[⏳ Wait for All Scouts] --> F{All Done?}
    F -->|No| E
    F -->|Yes| G[πŸš€ Start Price Analysis]
Loading

What happens here? The system waits until all scouts report back (or timeout after trying). Only when we have complete information do we move to the next step. This ensures we make decisions based on complete data.

Step 4: The Price Matching Decision 🧠

This is where the magic happens! Our system applies business rules in a specific order:

flowchart TD
    A[πŸ” Start Price Analysis] --> B{Is product on<br/>Exception List?}
    B -->|Yes| C[❌ Skip - No Price Matching]
    B -->|No| D[πŸ’° Find Cheapest Competitor Price]
    
    D --> E{Do we have a<br/>Preferred Competitor?}
    E -->|Yes| F[🎯 Use Preferred Competitor Price]
    E -->|No| G[πŸ’΅ Use Cheapest Price Found]
    
    F --> H{Is this a<br/>Price Increase?}
    G --> H
    H -->|Yes| I{Is product blocked<br/>from Price Increases?}
    H -->|No| J[πŸ“Š Check Profit Margin]
    
    I -->|Yes| K[❌ Block - No Price Increases Allowed]
    I -->|No| J
    
    J --> L{Will we still make<br/>minimum profit?}
    L -->|No| M[❌ Block - Margin Too Low]
    L -->|Yes| N[βœ… Approve Price Change]
    
    style C fill:#ffcdd2
    style K fill:#ffcdd2
    style M fill:#ffcdd2
    style N fill:#c8e6c9
Loading

πŸ›‘οΈ Business Rules Explained Simply

Rule 1: Exception List 🚫

What it is: A list of special products we never want to automatically price match.

Example: Limited edition items, products with complex pricing, or items where we have exclusive deals.

Why: Some products require human judgment and shouldn't be automated.

Rule 2: Preferred Competitor Override 🎯

What it is: For some products, we always want to match a specific competitor regardless of who's cheapest.

Example: For premium baby formula, we might always want to match Amazon's price (even if Noon is cheaper) because customers trust Amazon's pricing for sensitive products.

Why: Strategic positioning and customer perception matter more than just being cheapest.

Rule 3: Price Increase Protection πŸ“ˆ

What it is: Some products are marked as "never increase price automatically."

Example: Popular items during sales seasons, or products where price stability is important for customer trust.

Why: Price increases can hurt customer relationships and should be done carefully by humans.

Rule 4: Minimum Profit Margin πŸ’°

What it is: Every product must maintain a minimum profit percentage.

Example: If a baby stroller costs us $100, and our minimum margin is 15%, we'll never sell below $117.65.

Math: If price = $117.65, then profit = $17.65, margin = $17.65 Γ· $117.65 = 15%

Why: We need to cover operational costs and make reasonable profit.


πŸ”’ The Lock System - Like Booking a Meeting Room

Understanding our lock system is like understanding how meeting room bookings work in an office:

The Two-Lock System

graph TB
    subgraph "Lock System Analogy"
        A[🏒 Office Building<br/>Meeting Room System]
        
        subgraph "Room 1: Dispatch Lock"
            B[πŸ“… 65-minute booking<br/>'Checking Prices Room']
            C[Prevents double-booking<br/>price checks for same product]
        end
        
        subgraph "Room 2: Matching Lock"  
            D[πŸ“… 50-minute booking<br/>'Decision Making Room']
            E[Prevents two people<br/>making pricing decisions<br/>for same product]
        end
    end
    
    A --> B
    A --> D
Loading

Lock #1: The "Dispatch Lock" (65 minutes)

What it does: Prevents us from starting multiple price checks for the same product at the same time.

Real-world analogy: Like having a "Reserved" sign on a conference room. Once someone books "Baby Stroller ABC123 UAE Price Check," nobody else can book the same room until the meeting is over.

Why we need it: Without this lock, we might accidentally send out 5 different teams to check the same product's prices, wasting resources and potentially getting confused results.

Duration: 65 minutes (slightly longer than our hourly checks to prevent overlap)

Lock #2: The "Matching Lock" (50 minutes)

What it does: Prevents multiple pricing decisions for the same product happening simultaneously.

Real-world analogy: Like having an executive decision room where only one pricing decision can be made at a time for each product. If someone is already in the room deciding about "Baby Stroller ABC123 UAE," everyone else has to wait.

Why we need it: Imagine two people trying to change the price of the same product at the exact same time - chaos! This lock ensures orderly, one-at-a-time decision making.

Duration: 50 minutes (shorter than dispatch lock, as decisions happen faster than price collection)

Lock Coordination Example

gantt
    title Lock Coordination Timeline: Baby Stroller ABC123 UAE
    dateFormat HH:mm
    axisFormat %H:%M

    section Dispatch Lock (65min)
    Dispatch Lock Active    :active, dispatch, 10:00, 11:05
    Send Price Scouts       :milestone, scouts, 10:00, 0m
    
    section Price Collection
    Gather All Prices       :gather, 10:00, 10:15
    
    section Matching Lock (50min)
    Matching Lock Active    :active, match, 10:15, 11:05
    Price Decision          :decision, 10:15, 10:20
    Log Results            :milestone, log, 10:20, 0m
    
    section Status
    Ready for Next Hour     :milestone, ready, 11:05, 0m
Loading

Timeline Breakdown:

  • 10:00 AM: πŸ”’ Dispatch Lock acquired, scouts sent out
  • 10:15 AM: πŸ“Š All price data collected, πŸ”’ Matching Lock acquired
  • 10:20 AM: βœ… Decision made (Match Amazon's $150), πŸ”“ Matching Lock released
  • 11:05 AM: πŸ”“ Dispatch Lock released, ready for next hourly cycle

πŸ“Š Example: Complete Price Matching Scenario

Let's walk through a real example:

The Setup

  • Product: Baby Stroller Model ABC123
  • Country: UAE
  • Our Cost: $120 (what we paid including all expenses)
  • Current Price: $165
  • Minimum Margin Required: 15%

The Price Check Results

Store Original Price Discounted Price Status
Our Store $170 $165 βœ… Active
Amazon UAE $180 $150 βœ… On Sale
Noon UAE $160 $155 βœ… Regular
FirstCry UAE $175 - ❌ Out of Stock

The Decision Process

Step 1: Check Exception List

  • ❓ Is ABC123 on the "don't auto-match" list?
  • βœ… No, proceed to next check

Step 2: Find Target Price

  • ❓ Do we have a preferred competitor for this product?
  • βœ… No preference set
  • 🎯 Target Price: $150 (Amazon's discounted price - cheapest available)

Step 3: Check Price Direction

  • ❓ Is $150 higher than our current $165?
  • βœ… No, this is a price decrease (good for customers!)

Step 4: Check Profit Margin

  • πŸ’° New margin = ($150 - $120) Γ· $150 = 20%
  • ❓ Is 20% β‰₯ our minimum 15%?
  • βœ… Yes, we'll still make good profit

Final Decision: βœ… APPROVE - Change price from $165 to $150

The Result

graph LR
    A[πŸ’° Old Price: $165] --> B[🎯 New Price: $150]
    B --> C[πŸ’΅ Customer Saves: $15]
    B --> D[πŸ“ˆ Our Profit: $30 margin = 20%]
    B --> E[πŸ† Competitive with Amazon]
Loading

πŸ“ˆ Business Benefits

For Customers πŸ‘₯

  • Always Competitive Prices: Never pay more than necessary
  • Real-time Updates: Prices reflect market changes within hours
  • Transparent Pricing: Consistent pricing strategy across all products

For Mumzworld πŸͺ

  • Automated Efficiency: No manual price checking needed
  • Protected Profits: Never sell below minimum margins
  • Strategic Control: Business rules ensure smart decisions
  • 24/7 Operations: Works around the clock across all markets

For Management πŸ“Š

  • Complete Audit Trail: Every decision is logged and traceable
  • Performance Reports: Clear metrics on price changes and impacts
  • Risk Management: Multiple safeguards prevent costly mistakes
  • Scalability: Handles thousands of products across multiple countries

🚨 Safety Measures & Controls

What Prevents Mistakes?

Multiple Checkpoints: Every price change goes through 4+ business rule checks

Profit Protection: Mathematical guarantees we never lose money on a sale

Human Override: Exception lists allow manual control over sensitive products

Audit Trail: Complete records of every decision for review and analysis

Time Limits: Locks prevent system conflicts and ensure orderly processing

What Happens When Things Go Wrong?

Scout Fails: If a competitor's website is down, we use the last known price or skip that competitor

All Scouts Fail: No price changes happen - we maintain current prices

Business Rule Conflict: The most restrictive rule wins (e.g., if margin check fails, no price change)

System Overload: Lock system prevents chaos by ensuring orderly processing


πŸ“‹ Summary: The Complete Flow

graph TD
    A[⏰ Hourly Trigger] --> B[πŸ”’ Acquire Dispatch Lock]
    B --> C[πŸ“€ Send Price Scouts]
    C --> D[⏳ Wait for All Results]
    D --> E[πŸ”’ Acquire Matching Lock]
    E --> F[🧠 Apply Business Rules]
    F --> G{Approve Price Change?}
    G -->|βœ… Yes| H[πŸ’° Update Price]
    G -->|❌ No| I[πŸ“ Log Reason for Blocking]
    H --> J[πŸ”“ Release All Locks]
    I --> J
    J --> K[πŸ“Š Generate Reports]
    K --> L[βœ… Ready for Next Hour]
Loading

In Simple Terms:

  1. Every hour: Check all competitor prices
  2. Collect data: Get complete pricing picture
  3. Apply rules: Use business logic to decide
  4. Make changes: Update prices that make sense
  5. Stay safe: Multiple protections prevent mistakes
  6. Keep records: Track everything for analysis
  7. Repeat: Do it all again next hour

This system ensures Mumzworld stays competitive while protecting profits and maintaining business control - all automatically, 24 hours a day, across thousands of products in multiple countries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment