Photo Management (per specs/photo-management.md): - Sharp integration for 3-size compression (thumb/medium/full) - WebP output with 80-90% quality - Client-side compression with browser-image-compression - PhotoUpload component with camera/drag-drop support - Upload API with bulk support and stats endpoint Testing: - Backend: Jest tests for all major API endpoints - Frontend: Vitest tests for utilities and API clients - CI: Updated Forgejo workflow for test execution Specs (100% coverage): - visitor-management.md (Phase 8) - messaging.md (Phase 9) - audit-and-documents.md (Phase 10) - accessibility-i18n.md (Phase 11) - hardware-integration.md (Phase 12) - advanced-features.md (Phase 13) Documentation: - OpenAPI 3.0 spec (docs/openapi.yaml) - All endpoints documented with schemas
3.4 KiB
3.4 KiB
Feature Spec: Environmental Monitoring & Financial Tracking
Priority: 🟡 Medium
Phase: 13
Status: ✅ Implemented
Overview
Advanced features for environmental sensor monitoring, financial tracking with cost-per-gram analysis, and AI-powered yield predictions.
Environmental Monitoring
Models
Sensor
id: UUIDname: stringtype: enum (TEMPERATURE, HUMIDITY, CO2, LIGHT_PAR, PH, EC, VPD, SOIL_MOISTURE)roomId: FK (optional)location: string (e.g., "North wall")deviceId: string (hardware ID)minThreshold: numbermaxThreshold: numberisActive: boolean
SensorReading
id: UUIDsensorId: FKvalue: numberunit: string (°F, %, ppm, etc.)timestamp: datetime
EnvironmentAlert
id: UUIDsensorId: FK (optional)roomId: FK (optional)type: string (TEMP_HIGH, HUMIDITY_LOW, etc.)severity: enum (INFO, WARNING, CRITICAL, EMERGENCY)message: stringacknowledgedAt: datetimeresolvedAt: datetime
API Endpoints
GET /api/environment/sensors- List sensorsPOST /api/environment/sensors- Create sensorPOST /api/environment/sensors/:id/readings- Submit readingGET /api/environment/sensors/:id/readings- Get reading historyGET /api/environment/alerts- Get alertsPOST /api/environment/alerts/:id/acknowledge- Ack alertGET /api/environment/dashboard- Real-time dashboard
Financial Tracking
Models
FinancialTransaction
id: UUIDtype: enum (EXPENSE, REVENUE, ADJUSTMENT)category: enum (LABOR, NUTRIENTS, SUPPLIES, EQUIPMENT, UTILITIES, etc.)amount: numberdescription: stringbatchId: FK (optional)date: datetime
BatchCost
id: UUIDbatchId: FK (unique)laborCost: numbernutrientCost: numberutilityCost: numbertotalCost: numberyieldGrams: numbercostPerGram: number
Sale
id: UUIDbatchId: FK (optional)product: stringquantity: numberpricePerUnit: numbertotalPrice: number
API Endpoints
GET /api/financial/transactions- List transactions with totalsPOST /api/financial/transactions- Create transactionGET /api/financial/sales- List salesPOST /api/financial/sales- Record saleGET /api/financial/batches/:id/costs- Batch cost breakdownGET /api/financial/reports/profit-loss- P&L reportGET /api/financial/reports/category-breakdown- Expense breakdownGET /api/financial/reports/cost-per-gram- CPG analysis
AI/ML Insights
Models
YieldPrediction
id: UUIDbatchId: FKpredictedYield: number (grams)confidence: number (0-1)factors: JSONactualYield: number (filled after harvest)accuracy: number
AnomalyDetection
id: UUIDentityType: stringentityId: FKanomalyType: stringseverity: stringdescription: stringisResolved: boolean
API Endpoints
POST /api/insights/predict/yield- Generate yield predictionGET /api/insights/predictions/:batchId- Get predictions historyPOST /api/insights/detect/anomalies- Run anomaly detectionGET /api/insights/anomalies- List anomaliesGET /api/insights/dashboard- AI insights overview
Future Enhancements
- Real ML model integration (TensorFlow/PyTorch)
- Predictive maintenance
- Automated threshold adjustment
- Integration with accounting software