Update documentation for item categories feature

- Add categories.json to file structure in both docs
- Document itemCategories loading in frontend architecture
- Add Item Categories section to README with category table
- Update data model to include category field
- Update filtering documentation with categoryFilter
- Add customization instructions for adding categories

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Eric Wagoner
2025-12-24 12:46:50 -05:00
parent 459878f045
commit 25ec949798
2 changed files with 37 additions and 4 deletions

View File

@@ -13,6 +13,7 @@ Pantry is a simple web app for tracking kitchen pantry items. It's a single-page
- `index.html` - Frontend (HTML/CSS/JS all in one file)
- `api.php` - Backend API (JSON file-based storage)
- `containers.json` - Container type definitions with categories
- `categories.json` - Item category definitions (Flours, Spices, Pasta, etc.)
- `og-image.png` - OpenGraph image for social sharing
- `deploy` - Rsync deployment script
@@ -23,6 +24,7 @@ Pantry is a simple web app for tracking kitchen pantry items. It's a single-page
- Uses QRCode.js from CDN for QR code generation
- Custom CSS with CSS variables for theming (earthy color palette: cream, terracotta, forest green)
- Container types loaded from `containers.json` at startup into `containerTypes` object
- Item categories loaded from `categories.json` at startup into `itemCategories` object
- All API calls go through the `apiCall()` function which POSTs to `api.php`
**Backend (`api.php`)**:
@@ -36,6 +38,12 @@ Pantry is a simple web app for tracking kitchen pantry items. It's a single-page
- Categories have: `name`, `containers[]`
- Frontend displays as "Category: Container Name" (e.g., "Glass Spice Jars: Hex (Large)")
**Item Categories (`categories.json`)**:
- Defines item categories for organizing inventory (Flours, Spices, Pasta, Baking, etc.)
- Each category has: key (e.g., `flours`), `name`, `color`
- Category tabs are dynamically generated in the nav bar
- Items display their category as a colored tag
**Data Storage**:
- `data/inventory.json` - Inventory items
- `data/pin.txt` - 4-digit PIN for edit mode (plain text)
@@ -72,12 +80,13 @@ The `deploy` script uses rsync to push to YunoHost:
## Key Implementation Details
**Data model:**
- Items have: `id`, `name`, `container` (type ID), `outOfStock` (boolean)
- Items have: `id`, `name`, `container` (type ID), `category` (category key), `outOfStock` (boolean)
**Filtering:**
- `currentFilter` - Tab filter: 'all', 'in-stock', 'out', 'spices', 'qr'
- `currentFilter` - Tab filter: 'all', 'in-stock', 'out', 'category', 'recent', 'qr'
- `categoryFilter` - Category filter (null or category key), set by clicking category tabs
- `containerFilter` - Container type filter (null or container ID), set by clicking legend items
- Both filters combine with search text
- All filters combine with search text
**Container legend:**
- Clickable - filters inventory by that container type