Build-Operate-Transfer for a Retail Demand Forecasting System

How Devox Software helped an online retailer launch production demand forecasting, plug it into purchasing workflows, and bring operations in-house.

About the client

An established US-based online retailer manages a broad assortment with different sales patterns, promotional schedules, and replenishment lead times

Technology Stack

  • Data and ML: Python, SQL, pandas, LightGBM, Optuna, PyArrow (Parquet).
  • Orchestration and experiment tracking: Apache Airflow on Amazon MWAA, MLflow (tracking server and model registry).
  • Storage: PostgreSQL on Amazon RDS, Amazon S3.
  • Compute and infrastructure: Amazon ECS on AWS Fargate, Docker, Terraform, Amazon ECR.
  • CI/CD and monitoring: GitHub Actions with OIDC access to AWS, Amazon CloudWatch, Amazon SNS.
  • Reporting: Power BI in Import mode through a standard data gateway on Amazon EC2.

ML vs. AI engineering: a quick note on terms. This project is machine learning in the strict sense: a model trained on the client’s own sales history. That’s different from AI engineering, RAG systems, agents, chatbots, where you wire up a pre-trained LLM and nothing trains. Structured transaction data like this doesn’t need an LLM; it needs a model that learns from four years of the client’s own numbers.

Overview

The retailer had several years of transaction history, but purchasing teams still relied on historical reports and spreadsheet calculations to estimate future demand. Sales history covered about four years, which captured yearly seasonality for most established products. Newer items had less history and followed a separate fallback.

The Head of Demand Planning was responsible for keeping purchasing decisions consistent across the growing assortment. Each week the team patched together spreadsheets from different categories before reviewing replenishment needs. Crunching the numbers ate up time the team could’ve spent digging into unusual demand spikes and pressure-testing their buy decisions.

Things came to a head during a seasonal promo. Several promoted products sold out way earlier than expected, while other items just sat overstocked. The planning team had reviewed the available reports, but its spreadsheet process could not consistently account for promotions, stock availability, and changing sales patterns across thousands of products.

“These projects always come top-down. Management knows the data is there, years of sales history, and they’ve seen what others are doing with it. Then they go looking for people who can turn it into decisions.” — Mykhailo Dubovyi, ML Engineer at Devox

Before the next big campaign, the Head of Demand Planning wanted a forecast process the team could actually count on. The client also wanted its own engineers to maintain the system after launch.

Devox Software delivered the project through a Build-Operate-Transfer engagement. The initial release covered 25,000 active SKUs across selected categories and produced weekly forecasts for a rolling four-week horizon. Before the first production cycle, the engagement spelled out who owned what: which decisions stayed with the Head of Demand Planning, which data-source owners supplied inputs during Build, and which internal engineers would own scheduled runs, retraining, and failed-job recovery after the supervised handoff. Writing it all down meant both sides could see exactly how much work would land on the client’s plate after the handover.

The system forecast demand at the SKU × week level for total online demand, with no split by warehouse, so each run published about 100,000 values. Breaking that demand down by warehouse was handled later in the replenishment process.

The Hard Parts

Business Side

  • Planning across a growing assortment. Purchasing managers could closely review priority products, but giving thousands of items the same eyeball time was a manual slog. The Head of Demand Planning needed a repeatable way to flag SKUs that need attention.
  • Different demand patterns. Fast-moving products, seasonal items, and products with intermittent sales required different forecasting approaches. Category rollups kept hiding what was really going on at the SKU level.
  • A fixed purchasing deadline. Forecasts had to arrive before the weekly planning review and remain easy to compare with recent sales, promotions, and available stock.
  • Planner confidence. Category managers understood their products and needed enough context to sanity-check forecasts that didn’t match their gut. A solid backtest wasn’t going to win them over on its own.
  • Launching while building internal capability. The client’s engineers were already supporting the commerce platform and reporting systems. Hiring a dedicated ML team would have taken too long, but relying on an outside vendor indefinitely meant never really owning the system.

Tech Side

  • Sales history did not always represent demand. Products with no available stock recorded little or no sales. Treat those weeks like regular slow sales and the model learns the wrong lesson, then lowballs future demand.
  • Classic data trap. The pipelines treated weeks with zero available stock as censored observations rather than ordinary low-demand periods. Planners could still see the original sales figures next to the adjusted series used for training, so the distinction stayed visible in the weekly review.
  • Inconsistent source records. Orders, returns, stock snapshots, catalog changes, and promotional data followed different update schedules. The system needed consistent product identifiers and clear rules for cancellations, returns, and missing records.
  • Reliable historical evaluation. Model testing had to reproduce the information available at each forecast date. Information recorded later stayed out of training and evaluation. Several sources, including the catalog and promotion plan, were overwritten in place, so their past states had to be reconstructed or captured from launch onward.
  • Limited product history. New products needed a documented fallback when there was not enough history for a reliable ML forecast.
  • Production reliability. The complete workflow needed scheduled execution, input validation, forecast publication, monitoring, and recovery procedures.
  • Maintainability after transfer. Internal engineers needed to understand data dependencies, model updates, and failed runs well enough to operate the system independently.

Seven Months, Turnkey

The project lasted seven months: three months to build and launch, three months of production operations managed by Devox, and one month of supervised handoff.

Devox’s team included a full-time ML engineer acting as technical lead, a data engineer who was full-time during Build and part-time during Operate, a half-time data scientist during modeling and evaluation, and part-time DevOps and project management. On the client side, the Head of Demand Planning and data-source owners joined in the first week, two data engineers and a DevOps engineer joined part-time in the first month, and a data science specialist joined in the third month. The client engineers took part in DAG reviews, model-registry promotions, and incident walkthroughs during Operate, and their hours were tracked, so the handoff plan reflected the capacity that would actually remain once Devox stepped back.

The Head of Demand Planning remained responsible for business requirements and final acceptance. Devox worked with purchasing managers and internal engineers to build the system around their existing planning cycle.

The engagement was turnkey on purpose. The client didn’t hand over prepped datasets or ready-made pipelines, just raw sources. Devox designed the storage, the transformations, the features, the evaluation, the training loop, and the monitoring, and advised on what was worth doing at each step.

Build

The project began with a review of how purchasing decisions were made: which products managers reviewed, what information they used, and when forecasts had to be available.

Together, the teams agreed on a weekly forecast covering the next four weeks. The first release focused on established products with sufficient history, giving managers a consistent assortment to evaluate before expanding coverage.

Architecture

The system ran entirely in the client’s AWS account, defined in Terraform:

  • Orchestration. Apache Airflow on Amazon MWAA scheduled the weekly forecast, monthly retraining, and data quality DAGs. Data preparation, training, and batch inference ran as separate ECS tasks on AWS Fargate, so Airflow only coordinated dependencies.
  • Storage. Original extracts were kept in Amazon S3 and converted to Parquet after validation. PostgreSQL on Amazon RDS, in private subnets, held reference data, run metadata, and published forecasts.
  • Experiment tracking. The MLflow tracking server ran as an ECS service on Fargate, with its metadata in a separate PostgreSQL database on RDS and model artifacts in S3.
  • Reporting. Power BI used Import mode through a standard data gateway on a Windows EC2 instance in the same VPC. A read-only database user queried reporting views of the current published forecast.
  • Environments. Separate development, test, and production environments shared the same Terraform modules and container images.

All infrastructure modules, container images, and secrets stayed in the client’s account and repositories from the first environment. Devox held temporary roles that were removed at the end of the supervised handoff; the internal DevOps engineer could still plan, apply, and roll back the same Terraform modules.

When the Sales HistorWhen the Sales History Liesy Lies

Scheduled pipelines combined order history, stock availability, prices, promotions, and product attributes. Data preparation included rules for returns, canceled orders, duplicate records, and product identifier changes.

All sources were loaded daily:

Source Method
Orders, cancellations, returns Incremental SQL queries from a read replica of the commerce platform
Available stock Compressed CSV files from the warehouse system over SFTP
Prices and catalog Full SQL extracts
Promotion calendar Approved CSV export from the commercial team

Airflow kept the original extracts in S3 and converted them to Parquet after validation. Every load carried its source date, load time, and batch ID. Incremental queries re-read the last seven days to catch late-arriving changes, and reloads never created duplicates. Canceled orders were excluded, returns were netted against the original sale week, and a mapping table linked old and new identifiers for relabeled or replaced products. Planners could still see the original sales figures next to the adjusted series used for training, so the distinction stayed visible in the weekly review.

Availability was the tricky part. Periods when products were unavailable were flagged and handled separately during training-data preparation. That way the model wouldn’t read a stockout as ‘nobody wants this thing.’

Because the forecast covered total online demand, availability was based on stock sellable online across the whole network. A day with zero available stock was marked unavailable, while a missing snapshot was marked unknown rather than zero. Weeks with fewer than four available days were excluded from training targets, and weeks with four to six available days received an adjusted sales estimate and a lower training weight.

Availability was a feature only for completed periods, the previous week and the last four weeks, never for the week being forecast. Accuracy evaluation used only fully available weeks with known availability.

Point-in-Time Correctness

From the start of the project, every source was stored as an immutable daily snapshot with its receipt date and, where possible, the record’s validity period. Features for a historical forecast were computed only from data available before that date.

Past promotions were rebuilt from archived calendars and change logs, historical prices from transactions and available price history, and the catalog from its change history where one existed. Overwritten states with no remaining source were not guessed: the related features were left out of retrospective experiments. Evaluation reports stated which date ranges used captured history and which relied on reconstruction.

One Model, Forty Trials

Model development compared seasonal baseline forecasts with a LightGBM model using historical sales, rolling statistics, calendar features, pricing, and promotional indicators. Evaluation used successive historical forecast dates, with results reviewed by category and sales volume.

The production model was a single global LightGBM model for the initial assortment, using the one-to-four-week forecast horizon as a feature. Each horizon was predicted directly, without feeding earlier predictions into later ones. Features included:

  • Sales lags of 1, 2, 3, 4, 8, 13, and 52 weeks from the forecast date.
  • Rolling means, medians, and variability over 4, 8, and 13 weeks.
  • Share of zero-sales weeks and time since the last sale.
  • Historical availability.
  • Category, brand, and product age.
  • Calendar features of the forecast week.
  • The promotion and planned price approved at run time.
  • The forecast horizon.

The objective was Tweedie, suited to non-negative volumes with many zeros, chosen over Poisson and standard regression on time-based validation. Hyperparameters were tuned with Optuna in about 40 trials on separate development folds, never on the final test year.

The baseline was a seasonal naive forecast with a 52-week lag, scaled for recent changes in sales level using only information available before the forecast date. Products without a year of history used a simple fallback baseline. Final evaluation used 12 rolling origins across the last year. At each origin, the model was retrained on the history available then and forecast the next four weeks, with the same targets, stockout filters, and assortment as the baseline.

Products with less than 13 weeks of usable history went to a fallback based on available sales and category patterns. For products with sales history, the team calculated an average daily sales rate, converted it to weekly volume, and adjusted it using the category’s historical seasonal profile. Products without sales were estimated from an agreed set of comparable products and flagged as low confidence for planner review. Every fallback row carried its method (category_seasonal or cold_start), and category managers saw it in the review view, where they could accept or override the value before the purchasing deadline.

Monday at 04:00

The production workflow ran through scheduled Airflow jobs. MLflow tracked training runs and model artifacts. Each published forecast included its generation date, forecast period, and model version.

The weekly DAG started on Monday at 04:00 Eastern Time, after Sunday’s data closed, and ran ingestion, validation, feature preparation, scoring, and publication. Scoring was due by 06:30, and publication with the Power BI refresh by 08:00, ahead of the 10:00 purchasing review. Forecasts were written to PostgreSQL under a new run ID, and the run became current only after all checks passed. Airflow then triggered the Power BI refresh through the REST API, and a separate daily morning refresh loaded actuals and monitoring results.

Purchasing managers accessed the results in Power BI, alongside recent sales and current stock levels. Acceptance criteria for each weekly run included on-time publication, completeness against the active assortment, and a short list of SKUs the Head of Demand Planning marked for manual review. Those criteria were agreed in the first two weeks and used to decide when a run was ready for the purchasing meeting.

Getting Planners to Actually Trust the Numbers

During the pilot, better numbers on paper didn’t automatically buy planner trust. Category managers pushed back on forecasts that didn’t match their gut, especially for promoted products and items coming back in stock.

The Head of Demand Planning worked with Devox to review those disagreements against actual sales. Some came down to business context the model didn’t have; others showed that spreadsheet-based judgment no longer held up.

The forecast view was expanded to show recent sales, stock availability, and promotion indicators together. Managers could investigate a forecast without stitching the supporting data together themselves. The report also showed the forecasting method used for each product and highlighted items where the forecast differed sharply from the last four weeks of sales.

From there, the forecast rolled out one category at a time; managers signed off on each batch before it joined the weekly routine.

Operate

For three months after launch, Devox supported the system through live purchasing cycles.

Because the planning team needed results before its weekly review, monitoring covered source-data arrival, pipeline completion, forecast coverage, and publication timing. ECS task logs and Airflow task results went to Amazon CloudWatch. CloudWatch alarms sent notifications through Amazon SNS to a shared support email for failed DAGs or tasks, stale sources, blocked or late publication, and missing results. During Operate, a Devox ML engineer was on call as the primary responder, with the data engineer as backup and infrastructure issues escalated to DevOps. Coverage ran during working hours, with a dedicated check of the Monday morning run.

As actual sales came in, the team reviewed forecast error and bias across categories and sales-volume segments. That surfaced systematic under- and over-forecasting that one overall accuracy number would’ve hidden. A weekly evaluation job calculated WAPE and signed bias for the model, the fallback, and the seasonal baseline, excluding weeks affected by stockouts, and wrote the results to a Power BI monitoring page.

One real production issue was an incomplete source-data load: the processing job would have continued and built a forecast on partial inputs.

To keep incomplete data out of purchasing reviews, the team introduced a publication gate checking source freshness, record volumes, and expected product coverage. Failed checks blocked the new forecast and triggered an alert. The previous forecast stayed available with its original generation date.

Before publication, the gate checked that:

  • The latest daily sources were no older than 24 hours, and the completed week was fully loaded.
  • Record counts stayed within 30% of the median of the previous four comparable loads.
  • At least 98% of the active assortment had a forecast, with all four horizons for every covered product.
  • There were no duplicates, negative values, or missing forecast quantities.

Volume and coverage deviations could be approved manually after the cause was reviewed, and the approver went on record. Structural errors and invalid values always blocked publication. Uncovered SKUs went to an exception list rather than being silently skipped.

Retraining followed the same discipline. A candidate model had to go up against the current production model and the seasonal baseline before anything shipped; a retrain by itself never replaced the production version.

Each month, a candidate was trained and scored on the same recent rolling-origin folds. To replace the production model, the candidate had to:

  • Improve WAPE by at least 2% relative to the production model.
  • Not worsen WAPE by more than 2 percentage points in any key category.
  • Keep overall signed bias within ±5%.
  • Pass data-contract and inference checks.

Otherwise, the current model stayed in production. Technical approval came from the Devox ML tech lead and, after transfer, from the client’s data science specialist; the Head of Demand Planning approved the business impact of significant changes. Promotion used MLflow model versions, approval tags, and a champion alias. Each run resolved the alias to a specific version and recorded it with the results. Rollback restored the previous version; fixing an already-released forecast meant a new run and publication.

Internal engineers participated in these reviews and incident investigations. As real incidents cropped up, each one produced a short written review and, where needed, a new check or runbook step.

Transfer

The handover moved work to the client’s data engineers, an internal data science specialist, and DevOps a step at a time.

Data engineers took over ingestion, transformations, and data validation. The data science specialist picked up model evaluation and retraining. DevOps handled environments, deployment, access, and infrastructure monitoring.

The Head of Demand Planning and purchasing managers still owned business requirements

The transfer included:

  • Source code, deployment configuration, and infrastructure definitions.
  • Documentation of data sources, transformations, features, and fallback rules, including a data dictionary and feature specification.
  • Procedures for training, evaluating, approving, and rolling back model versions.
  • Monitoring configuration and instructions for failed jobs or incomplete inputs, with runbooks for reruns, backfills, rollback, and recovery.
  • Recorded walkthroughs and working sessions.
  • A RACI matrix covering data, forecasts, models, incidents, and business acceptance.
  • Short architecture decision records on the forecast level, stockout handling, fallback, architecture, and model promotion.
  • Written reviews of significant incidents and a final handover checklist.

Most of the docs were written as the project went along and tightened during joint operation.

CI/CD was handed over in working form. GitHub Actions ran:

  • Step 1. Linting, unit tests, and data transformation checks.
  • Step 2. Data-contract tests on control fixtures.
  • Step 3. Integration tests and a small training and inference smoke test.
  • Step 4. Image build and push to Amazon ECR.
  • Step 5. DAG validation and Terraform plan.
  • Step 6. Deployment to staging.
  • Step 7. Manual approval for production deployment and Terraform apply.

GitHub Actions accessed AWS through OIDC rather than stored keys. Full backtests ran in the candidate evaluation process.

During the final month, the client’s engineers led operations while Devox watched and reviewed execution.

To close out the handover, the team independently ran four consecutive weekly forecasting cycles, evaluated a retrained model, and recovered from a simulated pipeline failure in the test environment. The drill removed the latest expected stock snapshot. The team had to receive the alert, identify the missing source, confirm the gate blocked the new forecast and the previous one stayed available with the right date, load the snapshot, rerun the affected tasks without duplicating data, and verify the new result, its publication, and the Power BI refresh. Runbook gaps found along the way were fixed before the handover closed.

Results

Business Outcomes

  • Benefit 1. Regular forecasts for purchasing decisions. Purchasing managers received four-week forecasts for 25,000 active SKUs before their weekly planning review.
  • Benefit 2. Less manual grunt work. The weekly data pull and spreadsheet prep went from about two working days down to half a day.
  • Benefit 3. Time back to chase down outliers. The Head of Demand Planning could begin weekly reviews with a prepared forecast and a list of products requiring attention. Meetings focused on purchasing decisions, unusual demand, and business context.
  • Benefit 4. Easier forecast reviews. Managers could see forecasts next to recent sales, promos, and stock in one place, so when the numbers didn’t match their gut, digging in was quick.
  • Benefit 5. Internal ownership. Their engineers own the scheduled runs, model evaluation, and routine maintenance after the supervised handoff.

Technical Outcomes

  • Improved forecasting performance. The model reduced weighted absolute percentage error by 18% relative to the seasonal baseline across the agreed historical evaluation periods for the initial assortment. It came from rolling-origin backtests on a shared evaluation sample, using only data available at each forecast date and excluding stockout-affected weeks. WAPE was calculated as total absolute error divided by total actual sales.
  • A complete production workflow. Data ingestion, validation, feature preparation, forecast generation, and publication ran as a scheduled process with defined dependencies.
  • Protection against incomplete inputs. Publication checks blocked new forecasts when source freshness or coverage fell outside agreed limits.
  • Traceable model releases. Training runs, model artifacts, evaluation results, and published forecasts were versioned, making production changes easier to investigate and reproduce.
  • Controlled model updates. Candidate models required evaluation and approval before deployment, with the previous production version retained for rollback.
  • Successful operational handoff. Internal engineers demonstrated independent operation through four weekly forecasting cycles, one retraining evaluation, and a recovery exercise.

For the Head of Demand Planning, the change showed up in the weekly routine. Less time reconciling spreadsheets, more time reviewing purchasing decisions, and a clear internal team keeping forecasts available.

One lesson from the handover: internal ownership has to be practiced. Running live forecasting cycles while Devox was still around gave the client’s engineers time to find gaps, settle open questions, and prove they could run the thing.

Planning a production ML system your team will eventually own? Talk to Devox Software about building it, running it, and handing it over.

Book a call

Want to Achieve Your Goals? Book Your Call Now!

Having trouble booking? Open the booking page.

Contact Us

We Fix, Transform, and Skyrocket Your Software.

Tell us where your system needs help — we’ll show you how to move forward with clarity and speed. From architecture to launch — we’re your engineering partner.

Book your free consultation. We’ll help you move faster, and smarter.

Let's Discuss Your Project!

Share the details of your project – like scope or business challenges. Our team will carefully study them and then we’ll figure out the next move together.







    By sending this form I confirm that I have read and accept the Privacy Policy

    Thank You for Contacting Us!

    We appreciate you reaching out. Your message has been received, and a member of our team will get back to you within 24 hours.

    In the meantime, feel free to follow our social.


      Thank You for Subscribing!

      Welcome to the Devox Software community! We're excited to have you on board. You'll now receive the latest industry insights, company news, and exclusive updates straight to your inbox.