All skills

merchmix-arro-rust-be

current

ARRO is a Rust workspace providing Merchmix’s merchandise allocation, replenishment, store clustering, size mapping, analytics, and related operational APIs. The main `arro-api` binary exposes Axum HTTP and MCP interfaces, uses PostgreSQL and Redis for application state and caching, and integrates with external AI, synchronisation, customisation, and ERP connector services. Shared allocation, clustering, and refill calculation engines are implemented in `arro-core` and can also be compiled to WebAssembly for browser-side use. A separate `arro-worker` process runs background allocation-sync and store-metrics jobs.

main·76267747339b·generated by gpt-5.6-luna·9/4/2026, 12:51:06 PM View as Markdown

This service helps retailers decide how much stock each store should receive, replenish stores, and manage the rules behind those decisions. It supports purchase-order allocation, store grouping, size mapping, inventory and sales analysis, replenishment runs, and operational transfers. Retail users can work through APIs or connected Merchmix tools, while background workers keep allocation and store metrics up to date.

12
Inventory AllocationproductionwriteAllocationuser facingagent facing98%

Plans and manages how purchase-order stock is distributed across stores and other destinations for a product.

The API exposes purchase-order and SKU allocation reads, allocation edits, summaries, mapping coverage, completion, revert, cache clearing, bulk plan creation, and bulk revenue operations. `arro-core::allocation` contains the allocation operation, reconciliation, rounding, validation, waterfall, and rollup engines; allocation v2 persists append-style operations and supports replay and commit flows.

Replenishment PlanningproductionexecutePlanninguser facingagent facinginternal96%

Creates and executes refill plans to restore stock at stores based on available inventory, demand, and configured guardrails.

The v2 refill API supports refill periods, SKU and style-matrix reads, run creation, daily execution, grid retrieval, preview, commit, and distribution-centre guardrails. `arro-core::refill` provides engine, routing, scaling, hashing, and guardrail logic; the worker also contains allocation-sync processing.

Store ClusteringproductionwritePlanninguser facingagent facing97%

Groups stores with similar characteristics so allocation and planning rules can be applied appropriately.

Cluster handlers and services support cluster CRUD, automatic clustering, previews, projections, health and drift analysis, outliers, threshold suggestions, store movement, cell-store views, and resolving store assignments. `arro-core::clustering` implements k-means and robust threshold computation.

Size Mapping ManagementproductionwritePlanninguser facingagent facing97%

Maintains mappings between product size labels and consolidated size groups used for planning and reporting.

The consolidated size-mapping API supports list, detail, bulk update, import, export, refresh, validation, summaries, streaming synchronisation, and synchronisation to size mappings. Dedicated services cover import, suggestions, validation, normalisation, reporting, templates, and size strategies.

Size Curve and Size Strategy PlanningpartialexecutePlanninguser facingagent facinginternal87%

Uses size relationships and historical signals to support more appropriate size-level allocation and replenishment decisions.

The repository contains size-curve blending, confidence, fallback, generation, extraction, strategy resolution, validation, backtesting, templates, and size-reporting services. These services are connected to allocation and refill domain types, although the supplied endpoint inventory does not establish the complete public route surface for every service.

Inventory and Stock VisibilityproductionreadInventoryuser facingagent facing91%

Provides current and derived views of stock, including purchase-order stock, total stock-on-hand, in-transit stock, and inventory snapshots.

Handlers and services include inventory, inventory snapshots, DC inventory, in-transit stock, store caches, purchase-order reads, bulk-refill stock totals, and ERP connector contracts for pulling inventory snapshots.

Merchandise AnalyticsproductionreadReportinguser facingagent facinginternal95%

Helps retail teams identify coverage gaps, compare stores, and rank styles using sales and store performance data.

Analytics routes expose coverage gaps overall and by store, peer benchmarking, and style leaderboards. `arro-bigquery` contains analytics, store, purchase-order, and size-sales repositories; store-metrics refresh and worker jobs support derived metrics.

Buy Grade ManagementproductionwritePlanninguser facingagent facing88%

Maintains store or product buying grades that can influence merchandise planning decisions.

The API exposes buy-grade listing, retrieval, and store-related reads, backed by `buy_grades_service` and platform/domain buy-grade types.

Store Transfer OperationspartialexecuteLogisticsuser facingagent facinginternal84%

Coordinates stock transfers between stores and can route transfer documents to a tenant’s ERP.

A store-transfer service and MCP tools are present, and the ERP connector protobuf defines idempotent `PushStoreTransfer`, job-status lookup, held-order listing, and selected hold-release operations. The supplied HTTP route scan does not show the complete store-transfer route set, so public REST exposure is not fully established.

ERP Connector IntegrationpartialexecuteLogisticsinternalagent facing90%

Sends supported inventory transfer or purchase-order actions to a tenant’s configured ERP and tracks the result.

A vendored gRPC `ErpConnector` contract defines transfer push, purchase-order push, inventory pull, idempotent job status, held-order listing, and selected hold release. Tenant configuration selects ERP type and connector routing; comments mark purchase-order push, inventory pull, and some hold operations as unimplemented for relevant adapters.

Operational Refresh and Commit ProcessingproductionexecuteOtherinternal90%

Refreshes derived store metrics and queues or commits planning changes so operational data stays current.

Internal routes expose refresh status and store-metrics refresh. The platform includes commit queue types and run-queue services, while `arro-worker` runs allocation-sync and store-metrics processors. A one-shot worker mode is supported by the `arro-api` binary command line.

MCP Planning AssistancebetaexecuteOtheragent facing95%

Allows connected AI agents to query and operate supported Merchmix planning workflows through structured tools.

The API exposes `/.well-known/mcp-service` and a streamable HTTP MCP service using `rmcp`. MCP tools cover stores, clusters, buy grades, size templates, size mappings, allocation v1 and v2, and store transfers. MCP tenant resolution requires a `client_id` that exists in the loaded tenant configuration.

5
Purchase-order allocation

A planner reviews open purchase orders, edits or evaluates SKU allocation, and completes or reverts the allocation.

  1. 1.List open purchase orders or bulk-refill purchase orders.
  2. 2.Retrieve purchase-order detail and SKU allocation state.
  3. 3.Review allocation summary and size-mapping coverage.
  4. 4.Update, complete, revert, or clear cached allocation state.
  5. 5.Optionally create allocation plans in bulk and commit downstream planning changes.
Refill run execution

A planner or scheduled process builds a refill run, previews its result, and commits approved replenishment quantities.

  1. 1.Configure or select a refill period and DC guardrails.
  2. 2.Create a refill run for a purchase order, style, cluster, or period.
  3. 3.Retrieve the refill grid or style replenishment matrix.
  4. 4.Preview the run and inspect calculated quantities.
  5. 5.Commit the approved run or execute the daily run path.
Cluster-driven planning

Stores are analysed and assigned to clusters that can be used by allocation and refill calculations.

  1. 1.Inspect cluster health, drift, outliers, and current store assignments.
  2. 2.Preview or calculate automatic clustering and threshold suggestions.
  3. 3.Move stores or resolve assignments.
  4. 4.Use the resulting cluster or projection in allocation or refill runs.
Size mapping synchronisation

Product size labels are validated, consolidated, and synchronised for downstream planning and reporting.

  1. 1.Import or inspect size mappings.
  2. 2.Validate mappings and review suggestions or summaries.
  3. 3.Apply bulk updates or synchronise to the size-mapping representation.
  4. 4.Refresh or stream synchronisation data and export the result.
ERP transfer submission

A supported transfer is submitted to the configured tenant ERP with retry-safe job tracking.

  1. 1.Resolve the tenant and configured ERP connector route.
  2. 2.Submit the store-transfer request with an idempotency key.
  3. 3.Read the returned job result and, if needed, query status using the same key.
  4. 4.Treat each returned item’s success or error as authoritative for hold-release style operations.

A Cargo workspace separates shared domain types, pure planning engines, data repositories, HTTP/API orchestration, projections, worker jobs, and WebAssembly bindings. `arro-api` constructs shared and tenant-specific PostgreSQL pools, optional Redis and secondary data pools, outbound service clients, and Axum routers. Request tenant identity is resolved against configured tenant state; MCP calls reproduce this check because they bypass the normal REST middleware.

Components
`arro-types`: shared common, domain, and platform data models.`arro-core`: pure allocation, clustering, refill, state, and tenant SQL logic.`arro-bigquery`: analytics, store, purchase-order, and size-sales repository layer; despite its name, its declared SQL dependency and `BQ_DATA` configuration indicate a secondary PostgreSQL data connection in this repository.`arro-projection`: Arrow IPC projection and codec support.`arro-api`: Axum REST API, MCP server, tenant state, handlers, services, migrations, outbound HTTP and gRPC clients.`arro-worker`: scheduled/background allocation-sync and store-metrics processors.`arro-wasm`: browser-compilable bindings for allocation, clustering, refill, replenishment, and size projection engines.PostgreSQL migrations: application tables and indexes for inventory snapshots, store attributes, size mappings, store/DC relationships, metrics, cluster overrides, and committed snapshots.
Patterns
Cargo workspace with shared crates and dependency injection through application state.Axum route modules with handler and service layers; some handlers perform SQL directly.Pure calculation engines in `arro-core`, reused by the API, worker, and WebAssembly build.Per-tenant database pools and tenant-aware routing configuration.Append/replay style persisted allocation operations for allocation v2.Redis-backed or cache-manager-assisted read/cache paths where configured.Background worker and run-queue processing for refresh and synchronisation.Streamable HTTP MCP server with structured tool definitions.gRPC protobuf contract for ERP integration.
10
KindIdentifierDescription
httpREST `/api/v1/allocation/*`Purchase-order and SKU allocation reads, edits, completion, revert, summaries, mapping coverage, cache control, bulk plan creation, and bulk revenue operations.
httpREST `/api/v2/refill/*`Refill periods, SKU/style matrices, refill runs, previews, grids, commits, daily execution, and DC guardrails.
httpREST `/api/v1/clusters/*`Cluster creation and management, auto-clustering, projections, health, drift, outliers, previews, thresholds, and store assignments.
httpREST `/api/v1/consolidated-size-mappings/*`Consolidated size-mapping CRUD, import/export, validation, refresh, summaries, and synchronisation.
httpREST `/api/v1/analytics/*`Coverage gaps, store peer benchmarks, and style leaderboards.
httpREST `/api/v1/buy-grades*`Buy-grade and store buy-grade reads and management.
httpREST `/api/v1/internal/*`Internal refresh status and store-metrics refresh operations.
httpMCP `/.well-known/mcp-service` and streamable HTTP MCP endpointAgent-facing discovery and structured tools for stores, clusters, buy grades, size templates, size mappings, allocation, and store transfers.
grpc`merchmix.erp.v1.ErpConnector`Outbound tenant/ERP connector contract for transfer pushes, purchase-order pushes, inventory pulls, job status, held-order listing, and selected hold release.
cli`arro-api run-worker` and `cargo run -p arro-worker`Runs background processing, including a one-shot API run-queue worker mode and the standalone worker binary.
11
EntityOwnershipDescription
Tenant configuration and tenant stateownsTenant identifiers, tenant database connection configuration, ERP routing settings, and sales-tax divisor used by API and worker processes.
Allocation plans and allocation operationsownsPurchase-order/SKU allocation state, append-style allocation operations, actors, sequences, summaries, and commit/replay data.
Purchase ordersreadsOpen purchase orders and purchase-order detail used by allocation and refill workflows.
Inventory snapshots and stock-on-handownsInventory snapshot records, total stock, DC inventory, and in-transit stock used for allocation and replenishment.
Store attributes and store hierarchyownsStore metadata, active status, DC flags, climate and hierarchy information, and store/DC relationships.
Store clusters and assignmentsownsClusters, store membership, overrides, health/drift information, projections, and committed snapshots.
Store metrics and analytics factswritesDerived store metrics, coverage-gap inputs, peer benchmarks, style performance, and size-sales reporting data.
Size mappings and consolidated size mappingsownsProduct size labels, consolidated groups, mapping names, validation results, and synchronisation data.
Buy gradesownsBuy-grade records and store associations used by buying and planning workflows.
Refill periods, runs, grids, and guardrailsownsConfigured refill periods, replenishment runs, calculated grids, daily execution state, and DC guardrails.
ERP job resultswritesIdempotency keys and submitted connector job outcomes used to avoid duplicate downstream ERP actions and query status.
10
NameKindRelationshipCriticality
PostgreSQLdatabasereadscritical
Redisdatabaseusesrequired
Secondary analytics data storedatabasereadssupporting
Merchmix Basics serviceinternal servicecallssupporting
ARRO AI serviceinternal servicecallssupporting
Merchmix synchronisation serviceinternal servicecallsrequired
Customisation serviceinternal servicecallssupporting
ERP connectorinternal servicecallsrequired
Arrow IPClibraryusessupporting
MCP Rust SDKlibraryusessupporting
Rust 2021TokioAxum 0.7Serde and serde_jsonSQLx and tokio-postgresRefinery SQL migrationsRedisTonic/prost gRPCrmcp MCP SDKArrow IPCWebAssembly via wasm-bindgenPostgreSQLDockerAzure Container Apps and Google Cloud Run deployment definitions
6
  • The supplied HTTP endpoint scan is incomplete relative to the handler modules; several registered handler modules, including store transfers, inventory, stores, size strategies, and platform operations, are not fully represented in the listed routes.
  • No runtime deployment health, route authentication policy, request schemas, or production readiness evidence was supplied beyond source structure and manifests.
  • The repository contains comments identifying some ERP connector RPCs as unimplemented for relevant adapters; do not assume purchase-order push, inventory pull, or all held-order operations work for every tenant.
  • The evidence does not establish whether all listed capabilities are enabled for every tenant or whether all APIs are externally user-facing.
  • No screen or frontend route evidence was provided; this repository should be treated as a backend/API and shared-engine repository.
  • The exact MCP endpoint path beyond discovery is not included in the supplied HTTP route list.

Use this repository for allocation, replenishment, store clustering, size planning, inventory visibility, analytics, and related Merchmix operational workflows. Resolve tenant context before taking action and distinguish previews and reads from commits or ERP submissions.

  • For tenant-scoped operations, require a valid `client_id` matching the loaded tenant configuration; do not infer or silently default a tenant.
  • Prefer preview, summary, validation, health, and mapping-coverage operations before write, commit, revert, or ERP execution operations.
  • Treat allocation and refill calculations as shared domain logic; avoid duplicating business rules outside `arro-core` when modifying behaviour.
  • When using allocation v2, preserve append/replay semantics and validate operation payloads before persistence.
  • For ERP actions, always provide and preserve an idempotency key, inspect the returned job status, and treat per-item success/error fields as authoritative.
  • Do not assume an ERP RPC is implemented for every configured ERP type; verify adapter support before invoking it.
  • Use internal refresh and worker operations cautiously because they can rebuild derived metrics or process queued work.
  • Never read, print, or commit secret values from tenant configuration, environment files, connector credentials, or deployment manifests.