Eduard Kharaev
Home · Projects

AI Analytical Platform: Commercial Operations for FMCG Distribution

One platform runs the commercial side of a dairy distributor: field sales, two-way 1C ERP exchange, KPI and motivation, management BI, demand forecasting, shelf recognition and self-hosted AI agents. 100% of company orders flow through it.

Internal name: AI Chaban2

Case study by Eduard Kharaev · Source on GitHub

At a glance

ModuleWhat it doesScale / result
Field sales (offline PWA)Routes, GPS visits, orders, payments, returns, debt21 reps, ~1,500 outlets, 45.8k of 46.5k orders created offline
1C ERP integration15 inbound data types; orders, receipts and returns posted back145k+ envelopes; 100% of company orders
KPI & motivation12 production schemes, editable thresholdsRole-scoped for reps, supervisors, managers
Management BI13 analytical areas, PPTX management reportsDirectors and supervisors
Demand forecastingVersioned pipeline, walk-forward backtesting, customer allocationPer active SKU
Merchandising AIAndroid field capture + multimodal shelf recognition95.8% brand precision, 6k+ photos
AI agents & operationsDirector, KPI and dashboard agents; infrastructure botSelf-hosted on H200; agent traces evaluated offline in Langfuse

42 users from field reps to directors · 103 GB PostgreSQL, ~278M rows.

AI Analytical Platform architecture

What the platform is

The platform is the operating system of the commercial team. Its transactional core is the daily work of field sales representatives: routes, GPS-stamped visits, orders, cash receipts, returns, customer debt and stock, synchronized with 1C ERP and available offline.

Above that transactional layer sit:

By August 2026, 100% of company orders in 1C carried a platform-generated identifier, 9–11k orders/month, making the platform the primary order-entry channel for the commercial team.

Users & scale

Field Sales

The PWA is the working application for field sales representatives. It supports:

Orders, cash receipts and returns are posted from the platform into 1C ERP through SOAP services.

Offline Mobile

The field-sales PWA is local-first, not just an application shell with cached pages.

Dexie / IndexedDB stores:

A 13-step prefetch downloads working reference data before field use. The outbox handles order | receipt | return | visit_start | visit_end | client_gps with exponential backoff, 20 attempts, dead-letter state, send locks and UUID request IDs. Server-side duplicate controls protect document posting.

45.8k of 46.5k recorded platform orders were created in offline mode. Reps can continue the core sales workflow without connectivity; KPI and chat remain online-only.

KPI & Motivation

Twelve production motivation schemes are computed from ERP-backed sales, debt and planning data. They cover areas including:

Thresholds are editable in the UI, field reps see their own results on mobile, and supervisors / managers receive role-scoped views. A rep rating provides plan-attainment comparison.

BI & Management Analytics

The management dashboard contains 13 production analytical areas with common filters and role/team scoping:

The platform can also generate management PPTX reports. Dashboard query results are cached in Redis for 180 seconds; supervisors are scoped to their own teams.

Forecasting & Planning Engineering

Forecasting is a separate versioned data pipeline, not a single Prophet notebook.

The scheduled path starts from daily order history and produces a demand forecast per active SKU. The current baseline model is Prophet, but the surrounding engineering is at least as important as the model itself.

Forecast inputs & model safeguards

The pipeline combines:

Before fitting, extreme demand spikes can be capped with an IQR-based rule. For shorter histories the model can disable yearly seasonality and tighten trend flexibility rather than extrapolating a weak long-term pattern. Forecast outputs are clipped at zero before publication.

Versioned runs

Forecast executions have explicit run metadata rather than silently overwriting yesterday's result:

run_id + run_date + version + run_type + status

The run record can also keep execution statistics such as SKU count, record count, date range and runtime. This makes a forecast reproducible enough to compare versions and diagnose a bad run instead of treating “the forecast” as one mutable table.

Walk-forward backtesting

A dedicated as-of / walk-forward backtest replays historical forecast dates without modifying the live forecast tables.

Evaluation includes:

Using as-of dates is important because customer/SKU profiles and input data must be computed from the information that would actually have been available at that historical point rather than leaking future state into evaluation.

Top-down customer allocation

The SKU-level forecast can be allocated down to customers using recent demand profiles instead of training a separate unstable model for every customer × SKU combination.

The allocation layer includes recency-aware weighting and batch-size heuristics with fallback levels such as customer/category and SKU-wide history. The same code path understands simulation/as-of runs so backtests do not accidentally use today's customer behavior.

Simulation, adjustment & operations

The repository also contains explicit simulation/versioning and adjustment stages around the base forecast, plus scheduled execution and alerting. This allows changes to forecast rules to be tested as pipeline changes rather than immediately replacing the published output.

A simplified engineering flow is:

flowchart LR
    A[Orders history] --> B[Feature / input preparation]
    C[Holidays / promotions / weather] --> B
    B --> D[Prophet per active SKU]
    D --> E[Base forecast]
    E --> F[Adjustment / caps]
    F --> G[Versioned forecast run]
    G --> H[Top-down customer allocation]
    H --> I[Planning / recommendations]

    G --> J[Walk-forward backtest]
    J --> K[WAPE / sMAPE / category error]
    K --> L[Parameter / rule iteration]

Measured quality (August 2026)

This feature is intentionally not oversold. The audited forecast had WAPE ~57%, which is weak for a decision-support forecast and remains an improvement area rather than a headline result.

The value of the current implementation is therefore twofold:

  1. it provides a live planning signal and customer-level allocation path;
  2. it provides the versioning, backtesting and error-analysis machinery needed to improve that signal without evaluating changes on anecdotal examples.

Procurement and production planning are not part of the platform's production product; the forecast is used for commercial planning / recommendations rather than being presented as an autonomous supply planning system.

Merchandising AI

The platform includes a production merchandising subsystem: an offline-first Android terminal for shelf photos and a multimodal recognition pipeline (GroundingDINO, Qwen-VL OCR, catalog retrieval, visual matching, deterministic fusion and guardrails). It reached 95.8% brand precision and 73.1% SKU precision end to end, and fed share-of-shelf, pricing and store-compliance reports.

AI Agents & Operations

The platform includes self-hosted, tool-calling agents rather than unconstrained chatbots:

There is no agent framework. The chat agents are hand-written tool-calling loops bounded at four rounds against a shared self-hosted Qwen; the in-app assistant is a single tool-calling pass behind explicit routing. Routing is deliberately simple: a keyword pre-check decides whether the first round must call a data tool, and the in-app assistant classifies a question into a premium / data / help path first. Persistent state is limited to the chat context and a poller cursor.

Agent traces were evaluated offline in self-hosted Langfuse: a monkeypatched runner replays a question set against the production bot outside the request path. Production calls themselves are not traced.

The agent infrastructure is production, but current business adoption is low; it should not be represented as a heavily used daily workflow.

1C ERP Integration

The integration is bidirectional.

1C → Platform

1C pushes 15 document/data types into the platform as JSON envelopes, including orders, shipments/sales, receipts, receivables, stock, prices, agreements, discounts, clients, products and sales representatives. More than 145k inbound envelopes were present in the audited production system. Processing uses business-key upserts and per-type rollback boundaries.

Platform → 1C

The platform posts:

through SOAP web services, then reconciles platform documents against the ERP mirror.

In Aug 2026, 100% of ERP orders originated from the platform. Recorded order-send failure rate was 1.7%, with failed sends reprocessed and no remaining failed documents in the audited snapshot.

Business Impact: Verified Only

The strongest measurable effect is workflow adoption, not claimed sales uplift.

What is deliberately not claimed

Architecture

Field reps / supervisors / managers / merchandisers / directors
        ↓
PWA / Web / Android / Chat
        ↓
nginx
        ↓
Next.js route handlers + FastAPI services
        ↓
PostgreSQL / Redis / Qdrant / MinIO
        ↓
1C ERP (JSON inbound + SOAP outbound)

AI / ML host:
vLLM Qwen3-VL-32B FP8 + Qwen3.6-35B
Qwen3-Embedding-8B
GroundingDINO · DINOv2 · ArcFace · OCR
        ↓
H200 self-hosted inference

My Role

Head of AI; Technical Owner / platform architect / Architecture Review Board chair.

I built the first production versions of the platform hands-on, then hired and led a team of 7 engineers who extended it. I kept ownership of the platform architecture and production contour, ran architecture/governance decisions, operated the production hosts/backups/secrets, and remained hands-on in key engineering areas including merchandising CV guardrails/evaluation, security monitoring, ERP exchange fixes, forecasting evaluation and production handover.

The platform today is a team system: this case study describes the foundation I built and the work of the team I led, not every later line of code as individual authorship.

Tech Stack

Python · FastAPI · SQLAlchemy · Next.js · React · Dexie / IndexedDB · Socket.IO · PostgreSQL 16 · PgBouncer · Redis · Qdrant · MinIO · Kotlin · Jetpack Compose · Room · WorkManager · 1C SOAP / JSON integration · vLLM · Qwen3-VL-32B (FP8) · Qwen2.5-VL-72B · Qwen3.6-35B · Qwen3-Embedding · Langfuse · GroundingDINO · DINOv2 · ArcFace · PyTorch · Prophet · pandas · nginx · PM2 · systemd · Docker · Prometheus / Grafana