This is part 2 of a short series about Picnic Store Intelligence, a small prototype I built after reading Picnic Engineering's Page Platform blog series. In part 1 I explained the idea. This post is about how the pieces fit together, and the one rule behind them: the backend decides, the frontend draws.

What "server-driven" means here

In a normal app, the frontend knows the layout: this section goes first, that one second, this one is hidden. In a server-driven setup, the frontend knows none of that. It receives a list of sections from the API and draws them in the order it was given.

So when I want to change what a customer sees, I change the backend. The frontend does not change at all.

What the backend sends

Each page is a list of sections, and each section carries everything the frontend needs:

// One section in the page response (shortened). private String sectionId; // for example "dairy" or "banner" private String type; // BANNER, PRODUCT_GRID, PROMO or RECIPE private String title; private int order; private boolean visible; // after the rule engine has decided private double score; // how relevant this section is to this customer private ScoreBreakdown scoreBreakdown; private int unlockProgress; // 0 to 100, how close it is to unlocking private List<ProductResponse> products; 

PageService builds the page in a few steps. It loads the cached catalog, makes one query for the customer's purchase history, decides visibility, scores each section and sorts them:

// A section is visible if the rules allow it OR the customer's // behavior has unlocked it (for example 3+ purchases unlock Recipes). boolean visible = ruleEngineService.isSectionVisible(section, rules) || ruleEngineService.isUnlockedByBehaviour(section.getId(), totalPurchases); // ... after every section is built, the highest score goes first: .sorted(comparingDouble(SectionResponse::getScore).reversed()) 

The order of sections on the page comes from this one line. The frontend never decides it.

What the frontend does

The frontend has a component registry: a map from a section type to a function that knows how to draw it. The loop that builds the page is only this:

page.sections.forEach(section => { // Look up how to draw this type. If it is unknown, use the fallback. const renderer = activeRegistry[section.type] || defaultRenderer; html += renderer(section, rank); rank++; }); 

There is no if (section is recipes) anywhere. The backend sends a type, and the registry knows how to draw it.

The fallback for newer section types

This is my favorite part. The backend can ship a new section type before every client knows about it, especially in a mobile app where users update at different times. If the frontend finds a type it does not know, it uses a defaultRenderer, so the page still works instead of breaking.

To show this in the demo, I added a "Legacy client fallback" checkbox. It simulates an older app version that only knows two section types:

// Pretend this is an old app: it only knows BANNER and PRODUCT_GRID. const activeRegistry = legacyMode ? { BANNER: renderers.BANNER, PRODUCT_GRID: renderers.PRODUCT_GRID } : renderers; 

Tick the box, and the Recipes and Promo sections still appear, drawn by the fallback and labeled "rendered via defaultRenderer fallback". Same backend, older client, nothing breaks.

One registry, more than one page

When you click a product, the app calls a second endpoint, /api/pages/product-detail, and draws the answer with the same registry:

sectionsEl.innerHTML = page.sections .map((section, idx) => (renderers[section.type] || defaultRenderer)(section, idx + 1)) .join(''); 

A whole new page, and no new frontend code. That was the moment the idea clicked for me. It is also the reason Picnic's team talks about extending the platform instead of building one feature at a time.

Small details I care about

  • Everything from the backend is escaped before it goes into the page, so a section title can never inject script.
  • The server reports how long it took to assemble the page, with a Server-Timing header, and the UI shows it.
  • The free hosting sleeps, so the frontend retries and shows a "waking up the server" message instead of an error.

Honest limits

In the demo I send hidden sections too, marked as hidden, so you can watch them unlock. A real store would simply not send them. And a real platform would need versioning and much more care around the contract between server and client than this prototype has.

Try it

Open the demo, tick "Legacy client fallback", then buy a few products and watch the page change:

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

Next in the series: the ranking score, and why I made every number explainable.

If you have built server-driven UI in production, I would love to hear what bit you that I have not run into yet.

Links

Connect with me: LinkedIn | X