-
Notifications
You must be signed in to change notification settings - Fork 5
Closed
Description
🧾 Issue: Implement Complete Stock Management System with Alert Lifecycle (Backend + Frontend)
🧩 Description
Implement a production-ready Stock Management System for the Laundry Buddy worker dashboard, including:
- Inventory tracking
- Alert lifecycle management
- Consumption history
- Analytics dashboards
- Real-time UI updates
The system must automatically trigger and resolve alerts when inventory crosses threshold levels and provide detailed analytics and audit history.
✅ Core Features to Implement
✔️ 1. Stock Management Dashboard (Frontend – 4 Tabs)
Tabs
- Overview — stock cards & actions
- Analytics — summary + charts
- Alerts — Active & Resolved alerts
- History — full consumption records
Overview Tab Requirements
- Item cards with quantity + progress bar
- Reorder level display
- Status colors (Green / Yellow / Red)
- Buttons: Record Usage / Restock
- Expandable item details
- Default items:
- Detergent
- Fabric Softener
- Soap
- Bleach
- Starch
✔️ 2. Backend Stock APIs (Node + Express)
GET
/stock/all/stock/:id/stock/analytics/stock/consumption-history/stock/alerts
POST
/stock/create/stock/:id/consume/stock/:id/add
PUT
/stock/:id/update
DELETE
/stock/:id/delete
✔️ 3. MongoDB Database Schema
Stock Model Fields
itemNamequantityunitreorderLevelconsumptionHistory[]alerts[]status(low | medium | high)averageDailyConsumptionestimatedDepletionDatelastRestockInfotimestamps
Additional Support
- Active & Resolved alerts
- Alert severity:
critical|warning - Automatic status updates
✔️ 4. Alert Lifecycle System
When Consumption is Recorded
- Trigger warning alert when
stock < 1.5 × reorderLevel - Trigger critical alert when
stock < reorderLevel - Prevent duplicate alerts per severity
- API returns:
alertTriggered: true | false
When Restocked
- Resolve critical alerts when
stock > reorderLevel - Resolve warning alerts when
stock ≥ 1.5 × reorderLevel - Track
resolvedAt - API returns:
alertsResolved: number
✔️ 5. Toast Notification System
- ✅ Success toast for normal operations
⚠️ Warning toast when alerts triggered- ❌ Error toast when operation fails
- Show number of resolved alerts
✔️ 6. Analytics & Insights
- Total consumption today
- Count of critical / warning / healthy items
- Item-wise usage chart
- Stock-health breakdown
✔️ 7. UI Requirements
- Fully responsive design
- Progress bars for stock levels
- Severity colors:
- 🔴 Critical
- 🟡 Warning
- 🟢 Healthy
- Active alerts section
- Resolved alerts section
- History timeline view
🧪 Testing Scenarios
- Trigger critical alert
- Trigger warning alert
- Auto-resolve alert after restock
- Multiple items with multiple alerts
- Full lifecycle: healthy → warning → critical → resolved
🚀 Acceptance Criteria
This issue is complete when:
- All 10 API routes are functional
- Database schema supports full lifecycle
- Dashboard shows live updates
- Alerts trigger & resolve automatically
- Full history is recorded
- Analytics data is correct
- UI is fully responsive
🎯 Goal
Deliver a production-ready stock management module with:
- Inventory tracking
- Automatic alert lifecycle
- Analytics dashboard
- Full audit history
Metadata
Metadata
Assignees
Labels
No labels