AI-Enhanced Inventory Management and Sustainability Dashboard
Shelf Life Inc. is a web-based application designed to help users monitor and manage their personal or household food inventory while promoting sustainable practices and reducing waste. Built using Streamlit, the system provides a lightweight but powerful user interface that connects to a Google Sheets backend, enabling collaborative, cloud-based inventory tracking. Gemini Pro is used for SHELI, your virtual recipe finding assistant.
This project was initiated in the context of a digital transformation and sustainability initiative. The application specifically addresses key real-world challenges such as:
- Lack of visibility into food inventory across users
- High levels of food waste due to expiry
- Poor forecasting of grocery needs
- Minimal awareness of environmental (COβ) impact at the individual level
The system aims to:
- Improve food usage efficiency through item-level inventory tracking
- Automatically identify items close to expiry to reduce waste
- Generate dynamic grocery lists based on real usage
- Provide COβ and cost savings dashboards to raise sustainability awareness
- Offer AI-generated recipes based on available ingredients
The app is intended for:
- Individual households
- Roommates or families sharing an inventory
- Researchers or educators studying sustainable behavior
- Students or professionals building inventory-based AI projects
Each user logs in securely and has access only to their own inventory and metrics. This modular structure ensures both data integrity and privacy, while still maintaining a central dataset.
This solution offers the following practical benefits:
- Accessibility: Runs entirely in the browser using Streamlit, with zero setup for end users beyond login.
- Automation: Tracks expiry, calculates usage and waste metrics automatically.
- Accountability: Shows cost and environmental impact to encourage conscious choices.
- Adaptability: Users can export, re-upload, or even reconfigure their data pipeline.
This section provides complete guidance on how to install, configure, and run the Shelf Timer application, both in local development and cloud-hosted environments.
Ensure the following tools and resources are available before installation:
- Operating System: Windows 10+, macOS 12+, or Linux (Ubuntu 20.04+)
- Python: Version 3.9 or later
- pip: Python package manager
- Git (optional): To clone repositories
- Google Account: Needed for access to Google Sheets API
- Hugging Face Account: Required only for deployment on Hugging Face Spaces
secrets: Secure credentials for accessing your Google Sheet & Gemini Pro API Keysrequirements.txt: List of Python dependenciesstreamlit_app.py: Main Streamlit application logic- Google Sheet URL shared with the appropriate service account
Download the app files or clone from a version control repository:
https://huggingface.co/spaces/hgopalan/shelf_timer/tree/main
cd shelf-timerTo avoid dependency conflicts:
python -m venv venv
source venv/bin/activate # macOS/Linux
venv\Scripts\activate # WindowsUse the requirements.txt to install necessary libraries:
pip install -r requirements.txtIf you are missing requirements.txt, manually install:
pip install streamlit pandas gspread oauth2client matplotlib openpyxlThe Secrets tab enables secure communication with Google Sheets & Gemini Pro.
- Log into your Google Cloud Console.
- Enable:
- Google Sheets API and Gemini Pro API Key
- Add the API keys to the
secretstab on the space. - Share your Google Sheet with the service account email (e.g.,
---------.-------------.com) with Editor rights. For this project: emailemailemail@gmail.com passwordpasswordpassword
To start the Streamlit application:
streamlit run streamlit_app.pyAfter a few seconds, your browser will automatically open the app interface at:
http://localhost:8501
If not, copy the URL displayed in the terminal manually into your browser.
To deploy on Hugging Face Spaces:
- Create a new Space on Hugging Face as a "Streamlit" app.
- Upload:
streamlit_app.pyrequirements.txtcredentials.pklshelf_timer_logo.png
- Commit changes.
- Wait ~3β5 minutes for Hugging Face to build and deploy the app.
- Share the live space URL with users.
Example:
https://huggingface.co/spaces/hgopalan/shelf_timer
- Secure credentials: Do not expose
.pklor.jsonfiles publicly. - Environment Variables: For production, shift to
.envfiles or secrets storage. - Access Control: Hugging Face Spaces currently allows public access; restrict by token for private versions.
This section provides detailed guidance on how to interact with the Shelf Life Inc. application. It includes instructions for logging in, navigating the key features, and utilizing the LLM assistant. This serves as a hands-on training guide for both new and returning users.
To access the Shelf Life Inc. web app, go to the Hugging Face Space.
Username Options:
snackhoardercanofbeanshungryhippo
Password:
password
Note: All users share the same password. User data is isolated and filtered by username.
Once logged in, you will see several navigational tabs at the top of the interface:
- Displays items approaching or past expiry based on current date.
- Helps in prioritizing usage and reducing waste.
- Automatically flags items with warning badges.
- Allows you to manually subtract quantity from an inventory item.
- You can also mark an item as βtrashedβ to log it as waste.
- Dropdowns are searchable and auto-populated with your inventory data.
- Automatically generates a grocery list based on depleted stock.
- Rounds up item quantity for practical usability.
- Excludes items that have reached zero and avoids duplicate recommendations.
- Provides a visual summary of:
- Most used and wasted items
- COβ impact trends
- Sustainability metrics (money saved, emissions reduced)
- KPIs shown:
- Unique items
- Total entries
- Expired / Expiring soon
- Total savings
-
Login to the app using:
- Username:
snackhoarder - Password:
password
- Username:
-
Navigate to βSubtract Quantityβ tab:
- Select βTomatoesβ
- Subtract 2 units
- Add remark: βUsed in saladβ
- Save the update
-
Go to βGrocery Listβ tab:
- Review the list of low or missing items
- See that βTomatoesβ is now included if below threshold
-
Visit βDashboardβ:
- See updated usage and waste statistics
- View COβ impact and cost savings metrics
-
Use Chat Assistant:
- Click on π¬ βAsk SHELIβ
- Ask: βWhat can I cook with tomatoes, eggs, and rice?β
- The assistant will return AI-generated recipe suggestions
- Daily Routine: Start your day by checking the expiry tab.
- Weekly Cleanups: Use subtract tab to remove spoiled items and log usage.
- Grocery Planning: Visit the grocery list tab before shopping trips.
- Sustainability Tracking: Monitor your emissions and savings monthly via the dashboard.
- Educational: Use with students or roommates to promote awareness.
This section empowers users to operate the Shelf Life Inc. app independently, offering a clear process for inventory updates, usage tracking, and sustainability insights. The built-in AI assistant further enhances usability by offering context-aware support and meal planning.
This section outlines the key features available in the Shelf Life Inc. application and the structure and origin of the data sources that power the system.
Shelf Life Inc. integrates several features tailored to support household food inventory management, minimize waste, and enhance sustainability awareness. Each module is designed to be intuitive, informative, and useful for various end users including families, students, and sustainability-focused individuals.
- Lists all food items sorted by their expiry dates.
- Flags expired items and those expiring within the next 7 days.
- Helps users prioritize consumption based on shelf life.
- Allows users to manually subtract consumed or trashed quantities from inventory.
- Optional remarks field to specify whether the item was consumed, donated, or wasted.
- Updates the underlying Google Sheet or CSV in real-time.
- Dynamically generates shopping recommendations based on user consumption trends.
- Considers current stock, past usage frequency, and expiry to suggest items.
- Filters out items with sufficient quantities remaining.
- Provides interactive KPIs and visualizations:
- Unique food items, money saved, COβ savings, expired/soon-to-expire items.
- Pie charts for most wasted and most consumed items.
- Sustainability level summary (Levels 0β4 based on performance).
- Enables quick diagnostics on stock health and environmental footprint.
- AI-powered chatbot using Hugging Face integration.
- Responds to prompts such as:
- βGive me a recipe using carrots and potatoes.β
- βWhatβs the most wasted item in my stock?β
- βHow many items will expire next week?β
- Provides a natural language interface for convenience and guidance.
The application pulls data primarily from a centralized Google Sheet which acts as a lightweight cloud database. The following columns are expected for proper functionality:
| Column Name | Description |
|---|---|
Username |
Logged-in user ID |
Food_Name |
Name of the item in stock |
Date_of_Entry |
Date when the item was added |
Expiry_Date |
Expiration date |
Quantity |
Quantity of units available |
QUnit |
Unit type (e.g., pack, item, kg) |
Weight |
Approximate weight per unit |
WUnit |
Weight unit (e.g., g, kg) |
Price |
Cost per unit |
Brand |
Brand name (optional but supported) |
Remarks |
Descriptive notes (e.g., trashed, used, donated) |
CO2_Emitted |
Estimated COβ footprint per item (if available) |
The system supports backup/reload of .csv files when the Google Sheet fails, enabling offline usage or local testing.
- Google Sheets API: For real-time cloud storage and user-specific data syncing.
- Matplotlib & Pandas: For generating insights and visuals.
- Streamlit: Framework used to build and serve the user interface.
- Hugging Face Spaces: Hosts the LLM-based chatbot assistant.
- OpenPyXL: Reads
.xlsxfiles when needed. - OAuth2Client: Manages authorization with Google APIs.
Each of these tools has been configured to work seamlessly with minimal overhead for users while supporting advanced analytics on the backend.
This section outlines common issues users and developers may encounter when using or extending the Shelf Life Inc. application, along with step-by-step resolutions and diagnostic tips. These insights aim to ensure smooth and continued operation of the platform, especially during updates or onboarding of new contributors.
- Symptom: The username dropdown is empty or displays invalid entries.
- Cause: The
Usernamecolumn in the Google Sheet includes blank cells or non-string values. - Solution:
- Ensure each row in the sheet includes a valid, non-empty username.
- Add a
.dropna()and.strip()in the backend to clean empty or malformed usernames:usernames = df['Username'].dropna().astype(str).str.strip().unique() usernames = [u for u in usernames if u != '']
- Symptom: The app crashes with
ValueErrororTypeErroron dashboard charts. - Cause: Empty or non-numeric data being passed to
matplotlib.pyplot.pie(). - Solution:
- Validate numerical fields before plotting:
df = df[pd.to_numeric(df["Quantity"], errors="coerce").notnull()]
- Validate numerical fields before plotting:
- Symptom: Items marked as expired do not show up or dashboard metrics display
NaT. - Cause: Date columns (
Expiry_Date,Date_of_Entry) are not parsed correctly. - Solution:
- Use:
df["Expiry_Date"] = pd.to_datetime(df["Expiry_Date"], errors="coerce")
- Use:
- Symptom: App does not load or throws error logs during Hugging Face Spaces launch.
- Cause: Missing or misconfigured
requirements.txt, or missing environment variable setup. - Solution:
- Ensure
requirements.txtis uploaded. - Confirm the Hugging Face Space runtime is set to
Pythonandstreamlitis declared in dependencies.
- Ensure
- Symptom: Changes made in the app are not reflected in Google Sheets.
- Cause: Missing write access for the service account or API rate limiting.
- Solution:
- Share the sheet with the full service account email listed in your
google_credentials.jsonfile. - Verify that write methods such as
worksheet.update()orset_dataframe()are being called.
- Share the sheet with the full service account email listed in your
- Symptom: Page becomes unresponsive or operations time out.
- Cause: Hugging Face Free tier may restrict processing time or simultaneous users.
- Solution:
- Restart the Space manually from the Hugging Face dashboard.
- Consider migrating to a paid tier if scaling is needed.
- Test new features with a small mock dataset before full deployment.
- Use
st.write()andst.exception()liberally during development for logging. - Structure app logic modularly to isolate faults and enhance maintainability.
If you encounter issues not listed above, please reach out via one of the following channels:
- Support Email:
- Development Lead: Maria Kouider β mariakouider@mail.mcgill.ca Hari Gopalan - hari.gopalan@mail.mcgill.ca
Provide screenshots, app logs, or a copy of the dataset (with sensitive information removed) to help diagnose the problem effectively.
This document outlines the long-term maintenance strategy, development standards, and handover procedures for the Shelf Life Inc. Streamlit app. It ensures continuity, reliability, and secure transfer of knowledge for future maintainers and developers.
| Frequency | Task |
|---|---|
| Weekly | Review Google Sheet sync logs and backup dataset locally. |
| Monthly | Validate expiry tracking formulae and AI grocery list behavior. |
| Quarterly | Update COβ conversion constants and UI/UX enhancements. |
| Annually | Perform code review and refactor; collect user feedback for KPIs. |
- Rotate Hugging Face tokens and Streamlit secrets annually.
- Maintain secure API key storage through environment variables.
- Share Google Sheet access on a need-to-know basis.
- Weekly export of current Google Sheet to a timestamped CSV file (e.g.,
inventory_2025_07_01.csv). - Backups should be stored in a secure, access-controlled folder in Google Drive or Git LFS if versioned.
- Store both
.csvand.parquetversions if feasible. - Keep a snapshot of the app version and data dictionary with each backup.
/ShelfTimer/
β
βββ streamlit_app.py # Main Streamlit app
βββ requirements.txt # Package dependencies
βββ credentials.pkl # Hugging Face credentials (if used)
βββ shelf_timer_logo.png # UI Logo
βββ README.md # Project documentation
- Transfer Hugging Face space access and credentials.
- Provide access to shared Google Sheets and backup directory.
- Share this README set and training materials.
- Schedule a Q&A session or training walkthrough.
- Fork or clone the repository and test locally.
- Set up virtual environment and confirm Streamlit runs end-to-end.
- Validate Google Sheets access and permissions.
- Update and commit changes via Pull Request with reviews.
For any issues or handover assistance:
- Primary Developer: Maria Kouider & Hari Golapan (H&M Consulting)
- Email: mariakouider@mail.mcgill.ca & hari.gopalan@mail.mcgill.ca
- Support Contact: mariakouider@mail.mcgill.ca & hari.gopalan@mail.mcgill.ca
This handover strategy ensures robust transfer of operational knowledge, with backup practices and collaboration guidelines tailored to support institutional or academic continuity.