Overview
The dashboard delivers:- Monthly production summary - Current month metrics for cheese and milk
- Month-over-month comparisons - Percentage changes vs. previous month
- 6-month historical trends - Graphical analysis by product and metric
- Daily production log - Today’s batches at a glance
- AI-powered alerts - Proactive notifications about production anomalies
Dashboard Location
The main dashboard is located at
/dashboard and is the first screen users see after authentication.Monthly Summary Metrics
The dashboard displays four key performance indicators:1. Cheese Production
2. Milk Sales
3. Total Waste
Waste percentage is calculated across all products. A lower percentage is better.
4. Total Costs
Data Calculation
The dashboard service aggregates data from production batches:Current Month Summary
Aggregation Logic
Month-over-Month Comparison
- Positive Trend
- Negative Trend
- No Previous Data
Production: Increase is good (green arrow up)Waste: Decrease is good (green arrow down)Costs: Context-dependent
Historical Comparison Chart
6-Month Trend Analysis
The dashboard includes a historical comparison chart showing trends over 6 months:Available Metrics
cantidad
Total production volume (kg or liters)
mermas
Total waste for the product category
costos
Total direct costs for the product category
Chart Data Processing
Daily Production Log
The dashboard includes a real-time view of today’s production:- Batches created today
- Production status (in progress vs. completed)
- Quick access to batch details
The daily log uses the
/api/lotes/produccion-del-dia endpoint to fetch today’s batches.Alerts Section
The dashboard sidebar shows AI-powered production alerts:Dashboard Layout
The dashboard uses a responsive grid layout:- Desktop
- Tablet
- Mobile
- 4-column KPI grid
- Side-by-side chart and alerts
- Full-width daily log
Data Refresh
The dashboard uses React Query for data management:- Fetched on component mount
- Cached for performance
- Automatically refetched on window focus
- Marked as pending during loading
Use Cases
Monthly Production Review
Monthly Production Review
Scenario: End-of-month analysis
- View current month totals for cheese and milk
- Compare with previous month percentages
- Identify trends (increasing/decreasing production)
- Check if waste percentage is within targets
- Review cost changes and investigate anomalies
Daily Operations Monitoring
Daily Operations Monitoring
Scenario: Daily production oversight
- Check Daily Production Log for today’s batches
- Verify all batches are progressing
- Review any new AI alerts in sidebar
- Address any flagged issues immediately
Trend Analysis
Trend Analysis
Scenario: Strategic planning
- Use Historical Comparison chart
- Select product (cheese/milk)
- View 6-month trends for quantity, waste, or costs
- Identify seasonal patterns
- Plan production adjustments
Cost Management
Cost Management
Scenario: Financial review
- Check total costs stat card
- Compare with previous month
- View cost trend in historical chart
- Drill down into specific batches if costs spike
- Investigate cost optimization opportunities
Performance Optimization
Database Indexing
Queries are optimized with indexes on
fechaProduccion and idUsuarioParallel Queries
Current and previous month data fetched in parallel using
Promise.allSelective Includes
Only necessary relations loaded (mermas, costosDirectos, producto)
Client Caching
React Query caches dashboard data to reduce API calls
Best Practices
Regular Monitoring
Check dashboard daily for real-time production insights
Investigate Trends
When percentages change significantly, drill into batch details
Complete Batches
Mark batches as complete promptly for accurate analytics
Review Alerts
Act on AI alerts to prevent production issues
Common Issues
No data showing
No data showing
Cause: No production batches in current monthSolution: Create production batches to populate dashboard metrics
Trend shows null
Trend shows null
Cause: No data from previous month for comparisonExplanation: This is expected in the first month of use. Trends will appear once there’s historical data.
Chart not loading
Chart not loading
Cause: Insufficient data for the selected product/metricSolution: Ensure there are completed batches for the selected product in the last 6 months
API Reference
| Endpoint | Method | Purpose |
|---|---|---|
/api/dashboard/mes-actual | GET | Get current month summary with comparisons |
/api/dashboard/grafico | GET | Get 6-month historical data for chart |
/api/lotes/produccion-del-dia | GET | Get today’s production batches |
