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: 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:
-
addsmallcaps(ora) โ Add a new item -
use(oru) โ Use part of an item -
show(ors) โ Show current inventory -
exp(or `expiry) โ Check expiring items -
low(orl) โ Check low-stock items and manage thresholds -
shop(orshopping) โ Generate shopping list -
help(orh) โ Show all commands -
quit(orq) โ 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
-
Clone the repository
-
Install in editable mode:
pip install -e .
-
Run tests:Bashpytest test/
-
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file freshfridge-0.2.3.tar.gz.
File metadata
- Download URL: freshfridge-0.2.3.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e1864edb445579a40780d9e8b03e23117e70e96ccfddc250511e2bd2b7a535e
|
|
| MD5 |
f76f31f1451d10f35ee88a85e7552b7a
|
|
| BLAKE2b-256 |
cac2e8132545f167254ae1a3a410c20ca23245000e920e17bf0a0be920e8f4fc
|
File details
Details for the file freshfridge-0.2.3-py3-none-any.whl.
File metadata
- Download URL: freshfridge-0.2.3-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6ea93fd05a41abc65ce4272cbc8ab5917e81c57a9423da1880872f855c38caf5
|
|
| MD5 |
f7c38c8dc976d49061c1dac802dd2cb3
|
|
| BLAKE2b-256 |
ee1b5ed62cb57cd7dac4a19b34c08c9b3d5697d719f5ff130856b95c572555cf
|