Auto Inventory Balancing

I built this system to solve a logistics problem at scale: hundreds of retail locations, thousands of SKUs, and inventory that was never in the right place at the right time. The system automatically calculates optimal transfers between locations based on real-time supply and demand signals — no manual intervention required.

How it works

The pipeline runs in phases:

  • Data ingestion pulls adoption data, inventory levels, warehouse stock, and expired inventory from multiple databases, filtering out disabled or excluded locations
  • Target calculation determines how much inventory each location should hold for each SKU based on required quantities, sales velocity curves, and configurable multipliers (1.2x–1.5x of target)
  • Need and availability analysis identifies locations below threshold (need replenishment) and locations with surplus, while excluding stores in “rush period” (2 days before to 7 days after a key date) to avoid disruption
  • Balancing algorithm iterates through every need, scoring potential source locations on available quantity, rush proximity, and other factors, then executes transfers iteratively — subtracting from supply and demand as it goes
  • Transfer optimization consolidates small shipments (minimum 5 units), reallocates freed-up units back to the available pool, and maps transfers to the correct entities for routing

Multi-factor optimization

The system doesn’t just move inventory — it makes smart decisions about where to source it. A priority index ranks three supply tiers: warehouse fulfillment center (highest priority), expired inventory from locations that no longer need it, and inter-location transfers. Within each tier, a scoring algorithm weighs available quantity, geographic distance, and timing relative to key dates.

Geographic awareness

A pre-calculated distance matrix between all location pairs enables the system to factor logistics costs into every transfer decision. A mapping module visualizes all transfer routes on a US map, with line thickness proportional to transfer quantity — giving operations teams an instant read on the flow of goods.

The result

The system handled hundreds of locations and thousands of SKUs, running on a scheduled basis to continuously rebalance inventory as conditions changed. It eliminated manual transfer planning, reduced stockouts, and ensured surplus inventory was redistributed before it became obsolete.