Zones - Zone-Driven Inventory & Merchandising

Domain: Zones Location: api/nextango/apps/zones/ Last Updated: 2025-12-21

Overview

The Zones app implements zone-driven inventory management where par levels define "what should be where" (ideal quantities) and inventory levels track "what is actually there" (actual quantities). Includes compliance tracking, merchandising standards, zone inventory, planogram management, and automatic infrastructure creation.

Core Documentation

FileDescription
models.mdZone, ZoneInventory, ParLevelItem, Planogram models
serializers.mdSanity webhook processing with camelCase conversion
views.mdAll 7 ViewSets with zone API endpoints
services.mdZoneAssignmentService business logic
signals.mdInfrastructure automation signals
examples.mdUsage examples and patterns

Key Features

Zone-Driven Architecture

  • Par levels - Define "what should be where" (ideal quantities)
  • Inventory levels - Track "what is actually there" (actual quantities)
  • Automatic infrastructure - Signals auto-create InventoryLevel records
  • Zone types - Compliance, merchandising, inventory
  • SKU validation - Validate SKUs against ProductVariant records
  • Sanity webhook integration - Automatic camelCase to snake_case conversion

Zone Types

  • Compliance zones - Checklists, photo requirements, frequency
  • Merchandising zones - Display standards, required products
  • Inventory zones - Par levels, count frequency, inventory tracking

Automation Features

  • Auto-create InventoryLevel - When ParLevelItem is created (signal)
  • Auto-cleanup orphaned records - When last ParLevelItem deleted (signal)
  • Auto-create zone configurations - When Zone is created (signal)
  • Bulk sync infrastructure - Via ZoneAssignmentService

API Endpoints

Zone Management

EndpointMethodDescriptionDoc Reference
/zones/GET, POST, PUT, PATCH, DELETEZone CRUD operationsviews.md
/zones/{id}/products/GETGet all products in zoneviews.md
/zones/{id}/sync_inventory/POSTCreate inventory infrastructureviews.md
/zones/by_store/GETGet zones by store locationviews.md

Zone Type Management

EndpointMethodDescriptionDoc Reference
/zones/compliance/GET, POST, PUT, PATCH, DELETECompliance configurationviews.md
/zones/merchandising/GET, POST, PUT, PATCH, DELETEMerchandising standardsviews.md
/zones/inventory/GET, POST, PUT, PATCH, DELETEInventory configurationviews.md
/zones/inventory/{id}/validate_skus/POSTValidate all SKUs in zoneviews.md

Par Level Management

EndpointMethodDescriptionDoc Reference
/zones/par-levels/GET, POST, PUT, PATCH, DELETEPar level CRUDviews.md
/zones/par-levels/{id}/ensure_inventory_level/POSTCreate InventoryLevel for par levelviews.md
/zones/par-levels/by_product/GETGet par levels for product variantviews.md

Planogram Management

EndpointMethodDescriptionDoc Reference
/planograms/GET, POST, PUT, PATCH, DELETEPlanogram CRUDviews.md
/planograms/{id}/target_assignments/GETGet target stores and zonesviews.md
/planograms/products/GET, POST, PUT, PATCH, DELETEPlanogram product CRUDviews.md

Full endpoint documentation: views.md

Architecture Highlights

Zone-Driven Inventory Flow

Zones → ZoneInventory → ParLevelItem → InventoryLevel
  ↓           ↓              ↓              ↓
Define     Configure    "Should have"   "Actually have"
 zone        type         10 units        5 units

Read more: models.md, services.md

Signal-Based Infrastructure Automation

Zones uses Django signals appropriately for infrastructure automation:

  • Auto-create InventoryLevel when ParLevelItem created
  • Auto-cleanup InventoryLevel when last ParLevelItem deleted
  • Auto-create zone type configurations when Zone created
  • Contrast with web_auth (service-based) approach

Read more: signals.md

Service Layer Business Logic

ZoneAssignmentService provides explicit business operations:

  • create_inventory_infrastructure_for_zone() - Bulk create InventoryLevels
  • validate_sku_assignments() - Validate SKUs match ProductVariants
  • get_products_for_zone() - Get all products assigned to zone
  • get_zone_assignments_for_product() - Find where product should be

Read more: services.md

Getting Started

1. Understand the Models

Start with models.md to understand:

  • Zone model (zone_name, store_location, zone_type)
  • ZoneInventory (count_frequency, last_count_date)
  • ParLevelItem (product, variant_sku, quantity)
  • Planogram (planogram_name, target_stores, target_zones)

2. Review the Data Flow

Read services.md to understand:

  • How zones define inventory organization
  • How par levels define ideal quantities
  • How InventoryLevel tracks actual quantities
  • How infrastructure is automatically created

3. Explore API Endpoints

Check views.md to learn:

  • Zone CRUD operations
  • Par level management
  • Planogram operations
  • SKU validation

4. Understand Sanity Integration

Review serializers.md for:

  • Webhook processing workflow
  • camelCase to snake_case conversion
  • Nested relationship handling
  • Field transformation patterns

Key Architectural Decisions

  1. Signals for infrastructure - Appropriate use of signals for automatic record creation
  2. Service layer for business logic - Explicit operations via ZoneAssignmentService
  3. Par levels vs inventory levels - Separate "should have" from "actually have"
  4. Automatic infrastructure creation - Signals ensure InventoryLevel always exists
  5. SKU validation - Prevent invalid product assignments

Common Use Cases

  • Zone setup - Create zones with compliance/merchandising/inventory configuration
  • Par level management - Define ideal product quantities per zone
  • Inventory sync - Auto-create InventoryLevel infrastructure
  • SKU validation - Ensure all par levels reference valid product variants
  • Planogram execution - Visual merchandising with product placement
  • Product distribution analysis - Find all locations where product should be stocked

Service Methods

ZoneAssignmentService

Infrastructure Management:

  • create_inventory_infrastructure_for_zone(zone) - Create all InventoryLevels for zone
  • sync_par_levels_to_inventory(store) - Bulk sync all par levels at store
  • cleanup_orphaned_inventory_levels(store) - Remove inventory without par levels

Product Assignment:

  • get_products_for_zone(zone) - Get all products assigned to zone
  • get_zone_assignments_for_product(product, variant_sku) - Find where product assigned

Validation:

  • validate_sku_assignments(zone_inventory) - Validate all SKUs in zone

Full documentation: services.md

Next Steps

  1. Start with models.md - Understand the data structure
  2. Then services.md - Learn the business logic
  3. Review views.md - Explore API endpoints
  4. Check signals.md - See infrastructure automation
  5. Review serializers.md - Understand Sanity integration

Was this page helpful?