Skip to main content

Custom inventory management library for FreshShelves - stock analysis, expiry predictions, and reorder recommendations

Project description

InventoryKit - Custom Inventory Management Library

Version: 1.0.0
Author: Harshitha (NCI Cloud Computing Student)
Purpose: Object-oriented library for FreshShelves inventory calculations


Overview

InventoryKit is a comprehensive, object-oriented Python library designed specifically for inventory management in the FreshShelves application. It provides advanced algorithms for stock analysis, expiry predictions, inventory valuation, and optimization.

Features

Object-Oriented Design - Clean class hierarchy with SOLID principles
Stock Analysis - Calculate stock status, reorder points, days of stock
Expiry Management - Analyze expiry dates, calculate waste risk
Inventory Valuation - Calculate total value, turnover rates, carrying costs
Optimization - Generate purchasing plans, reorder recommendations
Type Hints - Full type annotation for IDE support
Enums - Type-safe status enumerations
Dataclasses - Structured data models


Installation

# Install from local directory
pip install -e ./inventorykit

# Or in requirements.txt
-e ./inventorykit

Architecture

Class Hierarchy

InventoryKit
├── StockAnalyzer (Stock Level Analysis)
├── ExpiryAnalyzer (Expiry Date Analysis)
├── InventoryValuator (Financial Calculations)
└── InventoryOptimizer (Comprehensive Analysis)

Enums

  • StockStatus: CRITICAL, LOW, ADEQUATE, OVERSTOCKED
  • ExpiryStatus: EXPIRED, CRITICAL, WARNING, CAUTION, FRESH

Data Classes

  • Product: Product data model
  • InventoryMetrics: Analysis results model

Usage Examples

1. Stock Analysis

from inventorykit import StockAnalyzer, StockStatus

analyzer = StockAnalyzer(safety_factor=1.2)

# Check stock status
status = analyzer.calculate_stock_status(
    current=15,
    minimum=50
)
print(status)  # StockStatus.CRITICAL

# Calculate reorder quantity
reorder_qty = analyzer.calculate_reorder_quantity(
    current=15,
    minimum=50,
    average_daily_usage=10,
    lead_time_days=7
)
print(f"Reorder: {reorder_qty} units")

# Calculate days of stock
days = analyzer.calculate_days_of_stock(
    current=100,
    average_daily_usage=10
)
print(f"Stock lasts: {days} days")

2. Expiry Analysis

from inventorykit import ExpiryAnalyzer, ExpiryStatus

analyzer = ExpiryAnalyzer()

# Check expiry status
status, days = analyzer.calculate_expiry_status("2026-04-15")
print(f"Status: {status}, Days: {days}")

# Calculate waste risk
risk_score = analyzer.calculate_waste_risk_score(
    expiry_date="2026-04-20",
    quantity=100,
    average_daily_usage=5
)
print(f"Waste risk: {risk_score}%")

3. Inventory Valuation

from inventorykit import InventoryValuator

valuator = InventoryValuator()

products = [
    {'product_id': '1', 'quantity': 100},
    {'product_id': '2', 'quantity': 50}
]

price_map = {'1': 10.0, '2': 15.0}

# Calculate total value
total = valuator.calculate_total_value(products, price_map)
print(f"Total inventory value: ${total}")

# Calculate turnover rate
turnover = valuator.calculate_turnover_rate(
    sales_quantity=500,
    average_inventory=100
)
print(f"Turnover rate: {turnover}")

# Calculate carrying cost
carrying_cost = valuator.calculate_carrying_cost(
    total_value=10000,
    carrying_cost_percentage=0.25
)
print(f"Annual carrying cost: ${carrying_cost}")

4. Comprehensive Analysis

from inventorykit import InventoryOptimizer

optimizer = InventoryOptimizer()

products = [
    {
        'product_id': '1',
        'name': 'Milk',
        'quantity': 20,
        'minimum_stock': 50,
        'expiry_date': '2026-04-15'
    },
    {
        'product_id': '2',
        'name': 'Bread',
        'quantity': 80,
        'minimum_stock': 30,
        'expiry_date': '2026-04-12'
    }
]

usage_data = {
    '1': 10,  # 10 units per day
    '2': 5    # 5 units per day
}

# Analyze inventory
metrics = optimizer.analyze_inventory(products, usage_data)

print(f"Total value: ${metrics.total_value}")
print(f"Low stock items: {metrics.low_stock_items}")
print(f"Expiring items: {metrics.expiring_items}")
print(f"Turnover rate: {metrics.turnover_rate}")
print(f"Reorder recommendations: {len(metrics.reorder_recommendations)}")

# Generate purchasing plan
price_map = {'1': 5.0, '2': 3.0}

plan = optimizer.generate_purchasing_plan(
    products=products,
    budget=500,
    usage_data=usage_data,
    price_map=price_map
)

for item in plan:
    print(f"Order {item['quantity_to_order']} units of {item['product_name']}")
    print(f"  Cost: ${item['total_cost']}, Priority: {item['priority']}")

5. Quick Analysis

from inventorykit import quick_inventory_analysis

products = [...]  # Your product list

results = quick_inventory_analysis(products)

print(f"Health score: {results['health_score']}/100")
print(f"Total items: {results['total_items']}")
print(f"Low stock: {results['low_stock_count']}")
print(f"Expiring: {results['expiring_count']}")

API Reference

StockAnalyzer

Methods:

  • calculate_stock_status(current, minimum) -> StockStatus
  • calculate_reorder_quantity(current, minimum, avg_daily_usage, lead_time_days) -> float
  • calculate_days_of_stock(current, avg_daily_usage) -> float

ExpiryAnalyzer

Methods:

  • calculate_expiry_status(expiry_date) -> Tuple[ExpiryStatus, int]
  • calculate_waste_risk_score(expiry_date, quantity, avg_daily_usage) -> float

InventoryValuator

Methods:

  • calculate_total_value(products, price_map) -> float
  • calculate_turnover_rate(sales_quantity, average_inventory) -> float
  • calculate_carrying_cost(total_value, carrying_cost_percentage) -> float

InventoryOptimizer

Methods:

  • analyze_inventory(products, usage_data) -> InventoryMetrics
  • generate_purchasing_plan(products, budget, usage_data, price_map) -> List[Dict]

Design Patterns

1. Strategy Pattern

Different analysis strategies encapsulated in separate classes.

2. Facade Pattern

InventoryOptimizer provides a simple interface to complex subsystems.

3. Data Class Pattern

Immutable data structures for type safety.


Testing

# Run tests (when available)
pytest inventorykit/tests/

Integration with FreshShelves

# In aws_services.py
from inventorykit import InventoryOptimizer

optimizer = InventoryOptimizer()

def get_dashboard_stats(user_id):
    products = get_all_products(user_id)
    metrics = optimizer.analyze_inventory(products)
    
    return {
        'total_products': metrics.total_items,
        'low_stock_count': metrics.low_stock_items,
        'expiring_soon_count': metrics.expiring_items,
        'inventory_value': metrics.total_value,
        'turnover_rate': metrics.turnover_rate
    }

Why This Library?

Academic Requirements

Object-Oriented Design - Required by project rubric
Reusable - Can be used in other inventory projects
Well-Documented - Comprehensive documentation
Type-Safe - Full type hints for static analysis

Technical Benefits

Separation of Concerns - Business logic separated from AWS services
Testable - Pure functions, no external dependencies
Extensible - Easy to add new analyzers
Performance - Efficient algorithms for calculations


Future Enhancements

  • Machine learning for demand forecasting
  • ABC analysis for inventory classification
  • Multi-warehouse support
  • Batch processing for large inventories
  • Real-time optimization algorithms

License

Educational Project - NCI Cloud Computing Module


Author

Harshitha
PG Cloud Computing Student
National College of Ireland (NCI) Dublin


This library fulfills the 15% "Library Creation" requirement of the project rubric.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

inventorykit-1.0.0.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

inventorykit-1.0.0-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file inventorykit-1.0.0.tar.gz.

File metadata

  • Download URL: inventorykit-1.0.0.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for inventorykit-1.0.0.tar.gz
Algorithm Hash digest
SHA256 1031b062f1659812e152d572a25db80f567f953b562016dd545c85041bd0465d
MD5 5d16a2052f2b8d412f43a1b6d5794f41
BLAKE2b-256 f40c00c171af9358c77d6366bbc906dc552ae8153108274e67f3a65117f4cf72

See more details on using hashes here.

File details

Details for the file inventorykit-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: inventorykit-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for inventorykit-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 46e78fb5b0ce67aa146805c43f50a9b7dd79ba93f3a7460f752ab49123021a79
MD5 418471a437c344af7925cef3041feb6c
BLAKE2b-256 7b3594b85ce9fa0fc1d7c78680c0b45e357b6e3453082e49e88e8725260e9a20

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page