Inventory Module
Relevant source files
The following files were used as context for generating this wiki page:
- src/lib/actions/inventory.ts
- src/app/(app)/inventory/[id]/page.tsx/inventory/[id]/page.tsx)
- src/components/InventoryCard.tsx
- src/app/(app)/inventory/new/page.tsx/inventory/new/page.tsx)
- src/lib/actions/import.ts
- src/lib/chat/tools.ts
- GLOSSARY.md
- ios-shell/www/app.js
The Inventory Module cataloguing system tracks household items and valuables. It maintains a database of possessions including their purchase details, physical locations, serial numbers, and relationships to warranties. This module is an opt-in component that stores high-level asset information without active warranty tracking, though it allows linking items to records in the Warranties Module.
Sources: src/app/(app)/inventory/new/page.tsx:24-30, GLOSSARY.md:12-15, PRODUCT.md:17-21
System Architecture
The module uses a server-side architecture built on Next.js Server Actions for data mutations and Prisma for database interactions. Access is governed by a module enablement check and user role permissions.
Data Flow for Item Creation
The diagram shows the standard flow for adding a new item, including validation and optional document attachment.
Sources: src/lib/actions/inventory.ts:46-83, src/lib/actions/import.ts:98-124
Data Model
The inventory system tracks items through the InventoryItem entity. Items are categorized into specific types to facilitate filtering and organization.
Supported Categories
| Category | Description |
|---|---|
| APPLIANCE | Domestic appliances (fridges, washing machines) |
| ELECTRONICS | Computers, phones, and entertainment tech |
| FURNITURE | Household fittings and furniture |
| TOOL | Hardware and maintenance equipment |
| CLOTHING | Apparel and garments |
| SPORTING | Sports equipment and gear |
| BOOK | Physical books |
| MEDIA | Physical media (CDs, DVDs, Vinyl) |
| OTHER | Miscellaneous items |
Sources: src/app/(app)/inventory/[id]/page.tsx:16-26, src/components/InventoryCard.tsx:5-15
Schema Fields
| Field | Type | Description |
|---|---|---|
| label | String | Primary name or description of the item |
| category | Enum | One of the supported category labels |
| brand | String | Manufacturer or brand name |
| model | String | Specific model name or number |
| serialNumber | String | Unique hardware identifier |
| purchaseDate | Date | Date of acquisition |
| purchasePrice | Decimal | Cost at time of purchase |
| currency | String | 3-letter currency code (e.g., USD, AUD) |
| location | String | Physical location within the household |
| notes | Text | Additional descriptive information |
| warrantyProductId | UUID | Foreign key to a linked Product record |
Sources: src/lib/actions/inventory.ts:16-30, ios-shell/www/app.js:203-221
Core Operations
Item Management
Mutation operations are restricted based on user roles. The ADMIN and MEMBER roles permit full CRUD operations, while READONLY users are restricted to viewing data.
- Creation: Validates input against
inventoryItemSchemaand creates a record. If a file is included in theFormData, it is automatically processed as an attached document. - Updating: Performs a partial update of the record. It uses
fullFormUpdateto ensure only provided fields are modified. - Deletion: Implements a "soft-delete" pattern by setting a
deletedAttimestamp. Items remain in the database for 30 days before permanent removal. - Restoration: Clears the
deletedAttimestamp to return a soft-deleted item to the active inventory.
Sources: src/lib/actions/inventory.ts:35-44, src/lib/actions/inventory.ts:85-117, src/lib/actions/inventory.ts:133-143
Integration with Assistant
The Inventory Module exposes its data to the AI Assistant via specific tools. This allows users to query their belongings using natural language.
list_inventory_items: Searches catalogued items based on labels, brands, or models.net_worth: Aggregates thepurchasePriceof all inventory items to calculate part of the total household net worth.
Sources: src/lib/chat/tools.ts:192-202, src/lib/chat/tools.ts:205-212
Document Association
Items in the inventory can have multiple associated documents, such as receipts, manuals, or photos.
The relationship shows how documents attach to inventory items and how items optionally link to warranty products.
Sources: src/app/(app)/inventory/[id]/page.tsx:45-53, src/components/InventoryItemDocumentList.tsx:17-25
Mobile Shell Implementation
The mobile shell (Capacitor) implements a standalone version of the inventory module using a local encrypted SQLite database. It mirrors the server schema to ensure data parity for offline users.
- Local Storage: Uses the
inventory_itemstable in SQLite. - Search Logic: Implements local filtering across
label,category,brand,model,serial_number, andlocation. - Filing: Supports filing documents from the mobile "Inbox" directly into an inventory record.
Sources: ios-shell/www/app.js:203-221, ios-shell/www/app.js:829-840, ios-shell/www/app.js:1010-1015
Summary
The Inventory Module provides a structured repository for household assets. By separating general item tracking from active warranty management, it allows for a comprehensive catalogue of possessions. It integrates with the broader system through document management, the AI Assistant, and mobile standalone support, serving as a key component of the household "system of record."
Sources: PRODUCT.md:11-16, GLOSSARY.md:3-5