Skip to main content

Fresh fridge inventory manager with expiry and low-stock alerts

Project description

# FreshFridge ๐ŸงŠ Package Function Documentation

A refrigerator inventory management system with expiry date alerts, low-stock detection, and shopping list generation.

PyPI version CI Status

PyPI: https://pypi.org/project/freshfridge/

Features

  • Add, use, remove, and list items in your fridge
  • Track expiry dates and receive alerts for items expiring soon
  • Monitor low-stock items and set custom thresholds
  • Generate and export shopping lists
  • Persistent storage using JSON
  • Interactive command-line interface (CLI)
  • Comprehensive unit tests with >75% coverage
  • Continuous integration via GitHub Actions
  • Exception handling in key methods (including custom InvalidExpiryDateError)

Installation

Install from PyPI (recommended):

pip install freshfridge

Or install from source (for development):

git clone https://github.com/ubco-mds-2025-labs/project-step-3-G14.git
cd project-step-3-G14
pip install -e .

Usage

Run the interactive CLI app

freshfridge

Available commands:

  1. addsmallcaps (or a) โ€“ Add a new item

  2. use (or u) โ€“ Use part of an item

  3. show (or s) โ€“ Show current inventory

  4. exp (or `expiry) โ€“ Check expiring items

  5. low (or l) โ€“ Check low-stock items and manage thresholds

  6. shop (or shopping) โ€“ Generate shopping list

  7. help (or h) โ€“ Show all commands

  8. quit (or q) โ€“ Save and exit


Project Structure

freshfridge/
โ”œโ”€โ”€ freshfridge/               # Core package
โ”‚   โ”œโ”€โ”€ inventory/             # Item management
โ”‚   โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”‚   โ”œโ”€โ”€ items.py
โ”‚   โ”‚   โ”œโ”€โ”€ operations.py
โ”‚   โ”‚   โ””โ”€โ”€ persistence.py
โ”‚   โ”œโ”€โ”€ alerts/                # Expiry & low-stock alerts
โ”‚   โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”‚   โ”œโ”€โ”€ expiry.py
โ”‚   โ”‚   โ””โ”€โ”€ lowstock.py
โ”‚   โ””โ”€โ”€ reporting/             # Summary & shopping list
โ”‚       โ”œโ”€โ”€ __init__.py
โ”‚       โ”œโ”€โ”€ base_report.py
โ”‚       โ”œโ”€โ”€ summary.py
โ”‚       โ””โ”€โ”€ shopping_list.py
โ”œโ”€โ”€ scripts/
โ”‚   โ””โ”€โ”€ freshfridge_app.py     # Interactive CLI application
โ”œโ”€โ”€ test/                      # Unit tests
โ”‚   โ”œโ”€โ”€ test_base_report.py
โ”‚   โ”œโ”€โ”€ test_expiry.py
โ”‚   โ”œโ”€โ”€ test_items.py
โ”‚   โ”œโ”€โ”€ test_lowstock.py
โ”‚   โ”œโ”€โ”€ test_operations.py
โ”‚   โ”œโ”€โ”€ test_shopping_list.py
โ”‚   โ”œโ”€โ”€ test_summary.py
โ”‚   โ””โ”€โ”€ test_suite.py
โ”œโ”€โ”€ pyproject.toml
โ”œโ”€โ”€ README.md
โ””โ”€โ”€ .github/workflows/ci.yml

The package is divided into three logical sub-packages:

  • inventory โ€” manages items stored in the refrigerator\
  • alerts โ€” checks expiry and low-stock warnings\
  • reporting โ€” generates summaries and shopping lists

inventory Sub-Package

items.py

This module defines the core data model used to represent a food item.

Class: BaseItem

Parent class representing a general item.

Method Description
__init__(name) Stores the item name.
rename(new_name) Updates the itemโ€™s name.

Class: FreshItem(BaseItem)

Child class that inherits from BaseItem.
Used for actual refrigerator items with quantity and expiry information.

Method Description
__init__(name, quantity, unit, expiry_date) Initializes a fresh item with quantity, measurement unit, and expiry date.
reduce_quantity(amount) Decreases the quantity, preventing values below zero.
is_expiring_within(days) Returns True if the item expires within the next X days.
is_expired() Returns True if the expiry date has passed.

operations.py

Manages the refrigerator inventory through a dictionary of FreshItem objects.

Class: InventoryOperations

Method Description
__init__() Creates an empty inventory dictionary.
add_item(name, quantity, unit, expiry_date) Adds or replaces an item in the inventory.
use_item(name, quantity) Reduces the quantity of an item.
remove_item(name) Deletes an item from the inventory.
list_items() Returns a list of all FreshItem objects.

persistence.py

Handles saving and loading the inventory from JSON.

Class: InventoryPersistence

Method Description
save_inventory(inventory, path) Writes the current inventory to a JSON file.
load_inventory(inventory, path) Reads a JSON file and reconstructs all items using add_item().
inventory_to_dict(inventory) Converts the entire inventory to a dictionary for serialization.

These functions ensure that the fridge state persists between program runs.


alerts Sub-Package

expiry.py

Checks whether any items are close to expiring.

Class: ExpiryAlerts

Method Description
check_expiring(inventory, within_days) Returns items that expire within the given number of days.
mark_expired(inventory) Returns a list of already expired items.
days_until_expiry(item) Calculates how many days remain before an item expires.

lowstock.py

Manages low-stock alerts based on user-defined thresholds.

Class: LowStockAlerts

Method Description
low_stock_alert(inventory, thresholds) Returns items whose quantity is below their threshold.
update_thresholds(thresholds, new_thresholds) Updates the threshold dictionary.
items_at_zero(inventory) Returns items with zero quantity remaining.

reporting Sub-Package

base_report.py

Parent class for other reporting modules.

Class: BaseReport

Method Description
count_items() Returns number of items in the inventory.
list_all() Returns a list of all items.
get_item_names() Returns names of all items in the inventory.

summary.py

Creates human-readable summaries of the fridge contents.

Class: SummaryReport (BaseReport)

Method Description
request_summary() Returns item information as a list of dictionaries.
display_summary() Prints a formatted table-like overview.
get_total_quantity() Sums quantities of all items.

shopping_list.py

Creates and exports recommended shopping lists.

Class: ShoppingListReport (BaseReport)

Method Description
generate_shopping_list(thresholds) Calculates which items should be restocked.
display_shopping_list(list) Prints a human-friendly shopping list.
export_shopping_list(list, path) Saves the list to a text file.

Testing & Coverage

All tests pass with >75% coverage:

pytest test/ --cov=freshfridge --cov-report=term-missing

Coverage report is automatically generated by GitHub Actions CI.

Development

  1. Clone the repository

  2. Install in editable mode:

pip install -e .
  1. Run tests:Bashpytest test/

  2. Run test suite:

python test/test_suite.py

License

MIT License

Contributors

  • Yin-Wen Tsai
  • Jiaqi Yao
  • Sasivimol Sirijangkapattana

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

freshfridge-0.2.2.tar.gz (72.3 kB view details)

Uploaded Source

Built Distribution

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

freshfridge-0.2.2-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file freshfridge-0.2.2.tar.gz.

File metadata

  • Download URL: freshfridge-0.2.2.tar.gz
  • Upload date:
  • Size: 72.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for freshfridge-0.2.2.tar.gz
Algorithm Hash digest
SHA256 081d183b62fda87990da82dd0749ad9c33d2c7c0dfef72341ae3f7a05a7dc262
MD5 2868c62f99811e3851b3ca7ac173916f
BLAKE2b-256 c5408950cdedcd5be3b72859da692c7c2de156da3932911b6067ba4f8b611e9f

See more details on using hashes here.

File details

Details for the file freshfridge-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: freshfridge-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 10.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for freshfridge-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d3023cb4172a9915a66ad15fc45f404b88d3d0a4067049779d181d4b4982caa9
MD5 db04af16f14eebd4b726f67e9dd48d16
BLAKE2b-256 792c60451cac4f579b6ef9743425727d7322c19b75d83162f565e13352517b14

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