跳到正文
DEV Community· VINAYAK GOTE·· 1 小時前AI 評分31

閲讀 Picnic 的 Page Platform 系列網誌後,作者製作小型原型

I Read Picnic's Page Platform Blog Series, Then Built a Small Prototype to Understand It

AI 導讀

作者閲讀 Picnic Engineering 的 Page Platform 系列網誌後,製作 Picnic Store Intelligence 原型,探索伺服器驅動版面配置及按客戶購物行為排列頁面區塊。原型以三項手動設定的權重計算分數,並按購買次數解鎖食譜及週末優惠區塊;作者指出,這不是 Picnic 系統的複製品,也沒有使用機器學習。

正文

Some engineering blogs make you want to build something to see if you really understood it. Picnic Engineering's Page Platform series was that for me.

Picnic is an online grocery company, and its blog describes how it built a platform for its app pages. The part that stayed with me is a change in thinking: instead of asking "how do we build this feature?", the team asks "how do we extend the platform so this feature and the next ten are easy to build?"

I wanted to test that idea myself, so I built a small prototype: Picnic Store Intelligence. It is not a copy of Picnic's system. I only used their public blog posts, and I built it to think alongside them, not to replicate them.

The two ideas I wanted to explore

1. Server-driven layout. The backend decides which sections appear on the page, in what order and in what state. The frontend is a simple renderer with a component registry. Adding a new kind of section means adding one entry to the registry and nothing else:

// The backend decides WHAT to show. This registry decides HOW to draw it.
const renderers = {
  BANNER: (section) => `...`,
  PRODUCT_GRID: (section) => `...`,
  RECIPE: (section) => `...`,
  PROMO: (section) => `...`
};

// Unknown section types still render, with no code change needed.
const defaultRenderer = (section) => `...`;

2. Per-customer ranking. Rules decide which sections can be visible, but they do not decide the order. I added a score that quietly ranks sections for each customer based on their shopping behavior, with no human configuration.

How the ranking works

Each section gets a score between 0 and 1 from three simple inputs:

// How often the customer bought from this category (10 or more = maximum).
double frequencyScore = Math.min(purchaseCount / 10.0, 1.0);

// How recently they bought (fades to zero after 30 days).
double recencyScore = Math.max(0.0, 1.0 - daysSinceLastPurchase / 30.0);

// How relevant this category is at the current hour (for example, breakfast items in the morning).
// timeOfDayScore comes from a small lookup per category.

double score = (frequencyScore * 0.5) + (recencyScore * 0.3) + (timeOfDayScore * 0.2);

A score of 0.80 or more means "high purchase intent", 0.60 or more is a "strong conversion candidate", and so on down to "no purchase history". Every response also includes a ScoreBreakdown, so you can see exactly why a section ranked where it did.

Sections that unlock themselves

The rule engine and the ranker work together:

  • A new customer sees the default layout.
  • After 3 purchases, a Recipes section unlocks.
  • After 5 purchases, a weekend promo unlocks.

The page shows a progress bar toward each unlock. Two customers with different histories get two different stores from the same backend.

Try it

Open the demo, type any name, click "Buy" on a few products and watch the left panel re-rank in real time:

https://picnic-store-intelligence.vercel.app

If it loads slowly the first time, that is the free hosting waking up. Give it a moment.

Tradeoffs I chose on purpose

I want to be honest about the shortcuts, because a prototype should say what it is:

  • Hand-tuned weights, not machine learning. The score has three inputs, and any score can be traced back to them. A real system would move toward something like collaborative filtering.
  • String-based keys instead of full JPA relationships. This kept the focus on the platform idea. Production code would use real constraints.
  • Visible score explainer in the UI. In a real store, personalization stays silent. I made it visible so that anyone reviewing the project can see how it behaves.

What is next

This is the first post of a short series about the project. Next I will cover how the backend decides the page and why the frontend knows nothing about it, then the performance work (no N+1 queries), and how I used Picnic's own static analysis checks in the build.

If you work on server-driven UI or on a page platform, I would love to hear what I got wrong or what I missed.

Links

Connect with me: LinkedIn | X

來源:DEV Community · dev.to