Retail and e-commerce · Playbook 22

I've worked in this sector

Demand forecasting and replenishment

Demand forecast by product, store and channel every night, with promotions, weather and local events built in. Suggested orders and allocations ready each morning, buyers and merchandisers approving them, and less fresh food thrown away.

  • Predictive ML
  • Event-driven integration
  • Agents with tools
  • Human in the loop
  • Groceries Supply Code of Practice
  • Food Standards Agency
  • Simpler Recycling
  • UK GDPR

At a glance

The problem
Orders are set from last year's sales and a spreadsheet, so stores run out of what sells and throw away what doesn't
Typical volume
Around 40,000 products, 300 stores and three online channels: tens of millions of store-product-day forecasts a week
Who's involved
Buying, merchandising, allocation, supply chain, store operations, e-commerce, finance, IT and data
Pilot
10–12 weeks on one category after a 3–4 week discovery
Platforms
AWS, Azure, or a sovereign or on-prem stack

An illustrative scenario. The numbers are typical examples, not a client case study. The cloud services and UK rules were checked on 9 November 2026.

The business problem

A multi-channel retailer sells the same product in stores, online for home delivery or click-and-collect, and through marketplaces. Demand for each one moves with promotions, the weather, school holidays, local events and what competitors are doing. Most replenishment still starts from last year's sales, adjusted by hand in spreadsheets by merchandisers who know their categories well but can't see every store and every channel at once.

The result is familiar. Stores run out of the lines that are selling and hold too much of the ones that aren't. Promotions are ordered on instinct, so some sell out on day two and others leave stock for weeks. Online orders are picked from the same stock as the shelves, so a miss in one channel shows up as a substitution or a cancellation in another.

Fresh lines make it expensive. Every pack of salad, bread or chilled food over-ordered is marked down or thrown away within days, and every pack under-ordered is a lost sale and an empty shelf. In this example, the retailer marks down or throws away around 4% of its fresh sales. For the largest grocers, forecasting is also a supplier issue: the Groceries Code Adjudicator expects forecasts to be made with due care, because suppliers carry the cost when they are wrong.

What AI changes

  • Demand is forecast every night for each product, store and channel, using sales history, promotions, prices, weather forecasts, holidays and local events.
  • Forecasts come with a range, not just a number, so a buyer can see how sure the model is, and order more cautiously where it isn't.
  • Suggested orders and store allocations are calculated from the forecast, stock in stores and warehouses, lead times, pack sizes, shelf space and shelf life.
  • Buyers and merchandisers review and approve the suggestions, working through an exceptions list instead of every line.
  • Fresh lines get earlier warnings: short-dated stock is flagged for markdown or redistribution before its use-by date, within rules the store teams set.
  • Every forecast, suggestion, approval and override is logged with the reason, so the team can see what the model got wrong and why.

How success is measured

Agree these, and measure the baseline, before anything is built. Example targets are typical, not promises.

Forecast error

Weighted error by category, store and channel, at the level orders are placed. Measured against today's method on the same weeks.

Example15–25% lower than today's method

Forecast bias

Whether the model leans towards over- or under-forecasting. A small error that is always high still builds stock.

ExampleClose to zero, checked weekly by category

Availability

The share of products on the shelf and available to order online when customers want them.

ExampleUp by 1–2 percentage points

Fresh waste

Fresh food marked down or thrown away, as a share of fresh sales, using the same measure as before.

ExampleDown by a quarter in pilot categories

Suggestions accepted

How often buyers approve a suggested order unchanged. Very low means it isn't helping; near 100% can mean nobody is checking.

ExampleStable, and reviewed weekly

Stock cover

Days of stock held across stores and warehouses for the pilot categories.

ExampleLower, without losing availability

UK regulation and controls

Cross-sector rules are on the UK regulation map.

  • GCAGroceries Supply Code of Practice: forecasting

    This applies only to the 14 grocers the CMA has designated. A retailer must compensate a supplier for its own forecasting errors unless it prepared the forecast in good faith, with due care and after consulting the supplier. Share forecasts with suppliers, capture their input, and log the model version and data behind each one so due care can be shown, with extra care for promotions and seasonal lines.

  • FSAFood safety and use-by dates

    Food can't be sold or given away after its use-by date. Markdown and redistribution suggestions use the date on the stock record and stop before use-by. Store teams decide what is marked down, redistributed or thrown away.

  • DefraFood waste measurement and Simpler Recycling

    Since 31 March 2025, businesses in England with ten or more employees have to separate food waste for collection. Public reporting of food waste by large businesses is voluntary at the time of writing, and the government has said it is reconsidering a mandate. Measure waste by product and store in a consistent way now, so the numbers stand up either way.

  • ICOUK GDPR

    Forecasts work on aggregated sales, so they usually involve no personal data. If loyalty-card data is used to understand demand, it is aggregated before it reaches the model, with a DPIA and a clear retention period, and providers are contractually barred from training their models on it.

  • CommercialSupplier agreements and EDI

    Suggested orders become purchase orders only after a buyer approves them, and are sent through the existing EDI or supplier portal. The AI never changes supplier terms, cancels an order or commits spend on its own.

The solution

Showing AWSAzuresovereign / on-prem services. Switch with the toggle; every diagram and table on this page follows it.

Demand forecasting and replenishment: reference architecture
  1. 01Sources

    • EPOS sales from stores
    • Web, app and marketplace orders
    • Weather, holidays and local events
  2. 02Intake

    • AWS GlueAzure Data FactoryApache Airflow, with Kafka ConnectData pipelines
    • Amazon S3 and Amazon RedshiftAzure Data Lake Storage and Microsoft FabricCeph or IONOS S3 Object Storage, with PostgreSQLData lake and warehouse
    • SageMaker Feature StoreAzure Machine Learning managed feature storeFeast, on KubernetesFeatures
  3. 03Intelligence

    • SageMaker AIAzure Machine LearningMLflow and Kubeflow on KubernetesDemand forecast models
    • SageMaker AI ProcessingAzure Machine Learning pipelinesOpen-source optimisation (e.g. OR-Tools) on KubernetesOrder and allocation optimiser
    • Agent
      Bedrock AgentCoreFoundry Agent ServiceLangGraph on Kubernetes, with open-weight models via vLLMPlanner assistant
  4. 04Orchestration

    • Step FunctionsData Factory pipelinesApache Airflow, or TemporalNightly forecast and order run
    • EventBridge + SQSEvent Grid + Service BusApache Kafka or RabbitMQEvents and queues
  5. 05Systems of record

    • ERP and merchandising system
    • WMS
    • EPOS and store stock
    • Supplier EDI
  6. 06People

    • Person
      Buyer: approves orders
    • Person
      Merchandiser and allocator
    • Person
      Store fresh-food manager
  • Cloud or platform service (AWSAzuresovereign / on-prem)
  • AI agent
  • A person decides
  • Your existing systems
  • Outside your organisation

Components, side by side

Demand forecasting and replenishment: components on AWS, Azure and a sovereign or on-prem stack
LayerAWSAzureSovereign / on-prem
Data pipelinesMost of the work is here. Sales, stock, prices, promotions and ranging must line up by product, store and day.AWS GlueAzure Data FactoryApache Airflow, with Kafka Connect
Data lake and warehouseReuse the data platform you have if it holds clean daily sales and stock.Amazon S3, Amazon RedshiftAzure Data Lake Storage, Microsoft FabricCeph or IONOS S3 Object Storage, with PostgreSQL or your existing warehouse
FeaturesPromotion flags, price, weather, holidays and events, calculated the same way for training and for the nightly run.SageMaker Feature StoreAzure Machine Learning managed feature storeFeast, on Kubernetes
Forecast modelsAmazon Forecast closed to new customers in 2024, so new AWS builds use SageMaker AI. Foundation models help most on new and slow-moving lines; established lines often do as well with simpler models.Amazon SageMaker AI: gradient-boosted models, plus time-series foundation models such as Chronos-2 from SageMaker JumpStartAzure Machine Learning: AutoML forecasting, or an open time-series foundation model on your own endpointMLflow and Kubeflow on Kubernetes, with open-source models (e.g. Chronos, LightGBM)
Order and allocation optimiserTurns forecasts into orders, respecting pack sizes, minimum orders, lead times, shelf space, shelf life and warehouse capacity.SageMaker AI Processing jobsAzure Machine Learning pipelinesOpen-source optimisation (e.g. OR-Tools) on Kubernetes
Planner assistantExplains forecasts and builds exception lists in plain English. It never produces the forecast itself: that is the job of the forecast models.Amazon Bedrock AgentCore, with Amazon Bedrock modelsFoundry Agent Service, with models in Microsoft FoundryAn open-source agent framework (e.g. LangGraph) with open-weight models via vLLM
WorkflowThe nightly run must finish before buyers start work. Plan for a late data feed.AWS Step FunctionsData Factory pipelines or Logic AppsApache Airflow, or Temporal
Middleware and eventsAmazon EventBridge, SQSEvent Grid, Service BusApache Kafka or RabbitMQ
Link to ERP, WMS and EDIApproved orders go into the ERP as purchase orders, and the existing EDI sends them. Don't build a second route to suppliers.API Gateway, plus your existing integration platform if you have oneAPI Management, plus your existing integration platform if you have oneKong or your existing API gateway, plus your existing integration platform if you have one
Human reviewBuyers approve where they already work. A new screen is only worth it if the existing one can't show the exceptions.In the buyers' existing replenishment or merchandising screensIn the buyers' existing replenishment or merchandising screensIn the buyers' existing replenishment or merchandising screens
Identity, keys, data protectionIAM Identity Center, KMSEntra ID, Key Vault, PurviewKeycloak or your existing Active Directory; OpenBao or HashiCorp Vault
Monitoring and model trackingSageMaker Model Monitor closed to new customers on 30 July 2026. Track forecast error and bias by category every week, and alert on drift.CloudWatch, CloudTrail, MLflow in SageMaker AI, with accuracy checks in your own pipelineAzure Monitor, Azure Machine Learning model monitoringPrometheus, Grafana, MLflow
UK data residencySales data is commercially sensitive. IONOS AI Model Hub runs in German data centres: EU, not UK, residency.eu-west-2 (London)UK South / UK WestYour own UK data centre, or a UK or EU provider

On a phone, the table shows the platform you pick. Sovereign / on-prem means open, portable components you can run in your own data centre or with a UK or European provider; IONOS is shown as one example, and others exist. What sovereign cloud means →

Hybrid and on-prem

Many organisations keep core systems and sensitive data on their own servers. This is how the same design works across both.

Stays on-prem

The ERP, merchandising system, WMS and EPOS stay where they are, often on your own servers or in stores. Purchase orders and supplier EDI keep flowing through the systems that send them today.

Uses cloud AI

Training and the nightly forecast run need a lot of computing for a few hours, then very little. That suits AWS or Azure. If sales data must stay in your estate, the same models run on your own Kubernetes cluster.

How they connect

A private link (AWS Direct Connect or Azure ExpressRoute) carries the nightly extract of sales, stock and promotions out, and suggested orders back to the API layer in front of the ERP and WMS.

If the link drops

Buyers fall back to yesterday's suggestions and their usual rules, so stores still get stock. The nightly run catches up when the link returns. No order is sent to a supplier without a buyer's approval, so nothing goes out twice.

The agents

What each agent may do through its tools, what it may not, and where a person signs off. The limits are enforced by the platform, not the prompt.

Planner assistant

May do

  • Read forecasts, suggested orders, stock, promotions and sales for the buyer's categories
  • Explain in plain English why a forecast or suggestion changed
  • Build the morning exceptions list: big changes, data gaps, promotions at risk
  • Flag short-dated fresh stock for markdown or redistribution, within the store's rules
  • Draft a note to a supplier about an upcoming promotion's forecast, for the buyer to send

May not do

  • Approve, place, change or cancel a purchase order
  • Change a forecast, a model or its settings
  • Change supplier terms, prices or ranging
  • Move stock between stores outside the allocation rules
  • Mark down below the price floor set by the trading team

Where a person signs offBuyers approve every purchase order and merchandisers approve every allocation, working through the exceptions list. The agent's permissions are enforced by the platform's identity and policy controls, not by instructions in a prompt.

Middleware and integration

The ERP and merchandising system stay the record of what was ordered. Approved suggestions go in through the API layer as purchase orders, and the existing EDI sends them to suppliers. The forecast never talks to a supplier directly.

Sales arrive from EPOS overnight, and from web, app and marketplaces as events through the day. Late or missing store feeds are spotted before the run, and the store is forecast from its last good data rather than from zero sales.

Every suggested order carries a run ID. If the run is repeated, the ERP sees the same order, not a duplicate. Stock moves from the WMS arrive as events, so allocations use today's stock, not last night's.

The forecast can be switched off by category without stopping the business. Paused, buyers order as they did before, from their usual reports.

Process and people

  • Buyers and merchandisers involved in setting the rules: which lines need review, what counts as an exception, and how much they can change without a reason.
  • Override reasons captured in a short list (local event, supplier issue, known error), so the model learns from them and the team can see where it is weak.
  • A weekly accuracy review by category with the commercial team, not just the data team.
  • Promotions agreed early enough to forecast them. Late promotions are flagged as higher risk.
  • For grocers covered by GSCOP: forecasts shared with suppliers, their input recorded, and the evidence kept.
  • A named owner for each model, with change control, and a rule that nothing changes in the four weeks before Christmas.

Delivery plan

  1. 3–4 weeks

    Discovery

    Check two to three years of sales, stock and promotion data, measure today's forecast error and waste, and pick a pilot category with fresh and ambient lines.

  2. Gate · must be true to passData quality understood, baseline agreed, pilot category and stores chosen, buyers involved.

  3. 10–12 weeks

    Pilot

    Forecasts and suggestions for one category in 20–30 stores, in shadow mode first: buyers order as normal, and the two are compared week by week.

  4. Gate · must be true to passError and bias better than today's method, no fall in availability, buyers willing to use it.

  5. 6–8 weeks

    Production

    Suggestions go live for the pilot category across all stores and channels, with monitoring, support and a rollback plan.

  6. Gate · must be true to passNightly run reliable, monitoring and support in place, buyers trained, rollback rehearsed.

  7. Ongoing

    Scale

    Add categories one at a time, then use the forecast for warehouse labour planning and supplier collaboration.

  8. Gate · must be true to passEach new category passes the same pilot gate.

Roles and RACI

Who is responsible, accountable, consulted and informed, by activity
ActivityCommercial directorProduct ownerSolutions architectI can fill thisTechnical PMI can fill thisData scientists and engineersI can fill thisSupply chainSecurityI can fill this
Business case and benefitsAccountableResponsibleConsultedConsultedInformedConsultedInformed
Target architecture and data platformInformedConsultedAccountable and ResponsibleConsultedConsultedConsultedConsulted
Data extracts from EPOS, ERP and WMSInformedConsultedAccountableResponsibleResponsibleConsultedConsulted
Model build and accuracy testingInformedAccountableConsultedConsultedResponsibleConsultedInformed
Integration of approved orders with ERP and EDIInformedConsultedAccountableResponsibleResponsibleConsultedConsulted
Go-live decisionAccountableResponsibleConsultedResponsibleInformedConsultedConsulted
Run, monitor and improveInformedAccountableConsultedConsultedResponsibleResponsibleConsulted

Business case and benefits

Commercial director
A · Accountable
Product owner
R · Responsible
Solutions architect
C · Consulted
Technical PM
C · Consulted
Data scientists and engineers
I · Informed
Supply chain
C · Consulted
Security
I · Informed

Target architecture and data platform

Commercial director
I · Informed
Product owner
C · Consulted
Solutions architect
A/R · Accountable and Responsible
Technical PM
C · Consulted
Data scientists and engineers
C · Consulted
Supply chain
C · Consulted
Security
C · Consulted

Data extracts from EPOS, ERP and WMS

Commercial director
I · Informed
Product owner
C · Consulted
Solutions architect
A · Accountable
Technical PM
R · Responsible
Data scientists and engineers
R · Responsible
Supply chain
C · Consulted
Security
C · Consulted

Model build and accuracy testing

Commercial director
I · Informed
Product owner
A · Accountable
Solutions architect
C · Consulted
Technical PM
C · Consulted
Data scientists and engineers
R · Responsible
Supply chain
C · Consulted
Security
I · Informed

Integration of approved orders with ERP and EDI

Commercial director
I · Informed
Product owner
C · Consulted
Solutions architect
A · Accountable
Technical PM
R · Responsible
Data scientists and engineers
R · Responsible
Supply chain
C · Consulted
Security
C · Consulted

Go-live decision

Commercial director
A · Accountable
Product owner
R · Responsible
Solutions architect
C · Consulted
Technical PM
R · Responsible
Data scientists and engineers
I · Informed
Supply chain
C · Consulted
Security
C · Consulted

Run, monitor and improve

Commercial director
I · Informed
Product owner
A · Accountable
Solutions architect
C · Consulted
Technical PM
C · Consulted
Data scientists and engineers
R · Responsible
Supply chain
R · Responsible
Security
C · Consulted

R ResponsibleA AccountableC ConsultedI Informed· not involved

Where I'd fit

Option A

Lead the architecture

If there's no architect on the programme, I'd own the design end to end: the data feeds from your EPOS, ERP and WMS, the forecasting platform, how approved orders reach suppliers, and the gates. I'd report to your programme board and work with your commercial and supply chain leads.

Option B

Support your architect

If your partner or your own team already has an architect, I'd take on the integration with your store, warehouse, merchandising and EDI systems under their lead, and give them a second senior opinion on the data platform and how the forecasts reach buyers.

Where this goes wrong

  1. Goes wrong

    The model is trained on sales, not demand, so every out-of-stock day looks like low demand and it orders less next time.

    How the design avoids it

    Correct for days with no stock or short shelves before training, using stock records from the EPOS and WMS.

  2. Goes wrong

    Promotions are added to the system late, so the forecast never sees them.

    How the design avoids it

    A promotions calendar fed into the run, with late changes flagged as a risk on the exceptions list.

  3. Goes wrong

    Buyers don't trust it and re-key their own orders, so nothing improves.

    How the design avoids it

    Shadow mode first, accuracy shared openly every week, and buyers setting the exception rules.

  4. Goes wrong

    A missing store feed shows as zero sales, and the next order is cut.

    How the design avoids it

    Data checks before every run, and missing stores forecast from their last good data.

  5. Goes wrong

    The data science is good, but the orders never reach the ERP properly.

    How the design avoids it

    Plan the ERP and EDI integration in discovery, not after the model is built.

On the horizon

Changes already announced or under way that affect this design. More in the UK horizon scan.

  1. 2026–2027
    The Groceries Code Adjudicator's focus on forecasting

    The GCA's 2025/26 annual report keeps forecasting among its priorities, and it raised forecasting with retailers' Code Compliance Officers in 2026. Sponsorship of the GCA moved to Defra on 1 July 2026. If you are a designated grocer, build supplier input and evidence of due care into the process now.

  2. Open
    A decision on mandatory food waste reporting

    Defra consulted in 2022 and has said it is reconsidering a mandate for large food businesses. Nothing is confirmed. Measure waste consistently by product and store now, so reporting is a report rather than a project.

  3. 1 April 2029
    Mandatory B2B e-invoicing on a Peppol model

    HMRC published the roadmap in October 2026. Supplier invoices will need to match purchase orders automatically. Keep purchase order data clean and structured, and plan Peppol alongside your existing EDI.

  4. Late 2026–2028
    The Cyber Security and Resilience Bill

    Medium and large managed service providers come into regulation, with faster incident reporting. If your data platform or forecasting service is run by a supplier, expect new duties for them and updated contracts for you.

Questions to ask your partner or vendor

Good answers are specific. Vague answers to any of these are worth following up.

Copy them into your next supplier meeting

  1. How does the model tell the difference between low demand and no stock on the shelf?
  2. How will we measure accuracy against our current method, on our own weeks and categories?
  3. What happens to tomorrow's orders if a store's sales feed is missing tonight?
  4. How do approved orders reach our ERP and suppliers, and what stops a duplicate?
  5. Which decisions can buyers hand to the system, and where is that limit enforced?
  6. What does the nightly run cost at our volume, and how does it grow with more categories?

Planning something like this?

Whether you need someone to lead the design or to support the architect you already have, let's talk it through.

Sam Naseem
Sam NaseemBirmingham, UK · UK & Europe
Available now