Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Dynamic Pricing (AI-Driven Pricing)

Description / Background

AI-Driven Pricing adds a target-sales input to the pricing-rule flow. The pricing engine compares the restaurant’s target sale with its Organic Projection and recommends a price decrease or increase to support sales or profit maximization.

Objectives

  • Let a restaurant owner set a revenue target for the pricing-rule period.
  • Use the relationship between Target Sale and Organic Projection to select an AI pricing strategy.
  • Present the initial recommendation and pending AI-generated price modifiers for review.
  • Support approval or rejection of pending price modifiers.
  • For a new restaurant with missing Organic Projection data, the UI should show Calculating... or N/A.
  • An empty Target Sale blocks saving and shows required-field validation: Please enter a target amount.
  • Organic Projection is recalculated daily, so a restaurant can pivot from discount to surge during the month.
  • The critical validation rule is that Target Sale must be accepted when lower than, equal to, or higher than Organic Projection.
  • Pricing strategies:
    ScenarioConditionStrategy
    Revenue Gap (Demand Generation)Target Sale > Organic ProjectionDecrease price to stimulate demand and close the revenue gap.
    Target Met (Profit Optimization)Target Sale = Organic ProjectionIncrease price for profit optimization.
    High Demand (Surge Pricing)Target Sale < Organic ProjectionIncrease price aggressively to capitalize on high organic demand and scarcity.

Scope

  • adds AI-driven behavior to the Partner Portal pricing-rule flow:
    • includes create/edit form handling
    • initial recommendation retrieval
    • pending price-modifier retrieval
    • approval and rejection actions
    • and localized interface strings

Location

Partner Portal → Pricing Rules → create or edit a pricing rule. The rule type is ai_driven in the shipped payload.

How to find AI Driven Pricing Rule

  1. Open the Partner Portal Pricing Rules
  2. Choose the AI-Driven Pricing rule type when it is available. Current production note: the option is hidden in the UI as of 2026-07-16, so it is not reachable there today.

How to set AI Driven Pricing Rule

  1. Open Partner Portal -> Pricing Rules
  2. Create Pricing Rules -> Select the AI-Driven Pricing rule typ on Rules & Restrictions section
  3. Enter the Target Sale amount.
  4. Submit the pricing rule. The shipped frontend sends the target sale and target-sale period in the pricing-rule payload, with the AI rule using a range period and all-day application.
  5. Review pending AI-generated price modifiers and approve or reject them when presented.

Sequence Diagram / Flow

flowchart LR
    form["AI-driven pricing form"] --> recommendation["Initial recommendation API"]
    recommendation --> state["Pricing state"]
    state --> preview["Recommendation preview"]
    modifiers["Pending price modifiers API"] --> cards["Pending approval cards"]
    cards --> approve["Approve modifier"]
    cards --> reject["Reject modifier"]

ERD

erDiagram
    Restaurant ||--o{ PricingRule : "owns"
    Restaurant ||--o{ OrganicProjection : "has daily"
    Restaurant ||--o{ PricingRecommendation : "receives"
    PricingRule ||--o| PricingRecommendation : "produces"
    PricingRecommendation ||--o{ PriceModifier : "generates"
    PricingRecommendation }o--|| PricingStrategy : "selects"

    Restaurant {
        string id PK
    }

    PricingRule {
        string id PK
        string restaurant_id FK
        string rule_type "ai_driven"
        decimal target_sale
        string target_sale_period "monthly range"
        date start_date
        date end_date
        string mode "range"
        string application "all_day"
    }

    OrganicProjection {
        string id PK
        string restaurant_id FK
        decimal value
        date as_of_date
        datetime calculated_at
    }

    PricingRecommendation {
        string id PK
        string restaurant_id FK
        string rule_id FK
        decimal organic_projection
        decimal last_month_revenue
        decimal mtd_revenue
        decimal gap_to_close
        decimal confidence
        string strategy_code FK
        datetime created_at
    }

    PriceModifier {
        string id PK
        string restaurant_id FK
        string recommendation_id FK
        string menu_item_id
        decimal suggested_price
        string status "pending|approved|rejected"
        datetime created_at
    }

    PricingStrategy {
        string code PK
        string condition "gap|met|surge"
        string action "decrease|increase|surge_increase"
        string display_name
    }

Derived from flow + payload — no schema in PRD/PR. PricingStrategy seeded: gap (target>organic → decrease), met (= → increase), surge (< → aggressive). PriceModifier.status defaults pending; flips via /approve, /reject. OrganicProjection daily recalc.

Backend Implementation

no backend update.

Hybrid Implementation

No hybrid implementation is specified in the PRD, task, or feature PR.

Frontend Implementation

  • A new “AI-Driven” rule type is added to the pricing-rule dropdown, so the owner can pick it alongside the existing rule types. A show flag on each rule type lets product hide or show it without touching code (currently hidden in production — see the Improvement log).

  • The dates are fixed to the current month. Start date is today, end date is the last day of the month, and the period dropdown only offers “monthly”. The owner cannot pick custom dates or specific days/times — the rule is meant to run for the rest of the month, all day, every day.

  • The Target Sale field drives the AI recommendation live. Add a debounced fetch into the field so the price-engine returns an initial recommendation 500 ms after the owner stops typing. A skeleton shows while it waits.

  • A four-column metrics panel appears next to the Target Sale field, showing Last Month Revenue, Month-to-Date Revenue, Organic Projection (with a confidence badge — green / yellow / red), and Gap to Close. Add a tooltip so the owner knows what the Organic Projection means.

  • Pending price modifiers appear as cards the owner can approve or reject. Add the modifier list into the alert so it shows the rule name, business rationale, period, suggested adjustment, and affected menu items. After approve or reject, refresh the list so the owner always sees the current queue.

  • The AI-Driven option can be turned on or off with a single flag flip, so the production hide (2026-07-16) was a one-line change rather than a UI rewrite.

  • The Target Sale field becomes the single source of truth for what the AI recommends — the engine’s response drives the metrics panel automatically.

  • The pending-modifier list is store-driven and self-refreshing, so the owner always sees the current queue after every approve or reject.

PR #1149

Mobile Implementation

No mobile implementation is specified in the PRD, task, or feature PR.

PRD & Task

Design

No design asset is specified in the PRD, task, or feature PR.

API Blueprint

MethodPathURLDescriptionPayload
GET/pricing/recommendations/predictPrice-engine base URLFetch initial AI recommendationQuery parameters include the recommendation inputs; restaurant ID is sent in X-Restaurant-Id
GET/price_modifiersPrice-engine base URLFetch pending price modifiersQuery parameters include modifier status and restaurant ID
POST/price_modifiers/:id/approve?restaurant_id=:restaurant_idPrice-engine base URLApprove a pending modifierEmpty request body
POST/price_modifiers/:id/reject?restaurant_id=:restaurant_idPrice-engine base URLReject a pending modifierEmpty request body

New Query

No new query.

DB Schema / Database Migration

No database schema or migration.


Improvement:

Feature NameDateWhat ChangedDescription
Target Sales & Profit Maximization2026-06-18AI-Driven pricing shippedbook-bite PR 1149 merged with the AI pricing recommendation flow, pending modifier approval cards, API wiring, and localized interface text.
Target Sales & Profit Maximization2026-07-16AI-Driven rule option hiddenThe UI option was hidden by book-bite PR 1201, fix: hide ai driven, which added show: false. The driving task 86d3q83wv, “Hide dropdown option AI Driven”, has an empty description, so no reason is recorded there.
Target Sales & Profit Maximization2026-07-17RapidCanvas worker disabledhh-server PR 8447, “Fix/disable rapidcanvas worker”, was merged one day after the UI was hidden.