LagerGuru v4.0.0 — SAFETY INTELLIGENCE EDITION
Release Date: 2025-02-05
Type: Major Release
🔥 Summary
This major release introduces the first full Safety Intelligence engine in Europe, including predictive modeling, risk clustering, hazard mapping, OSHA compliance automation, permit-to-work workflows, and LMS integration. All features are production-ready, fully tenant-aware, and backward compatible.
✨ New Features
Phase 1: Predictive Safety Intelligence Foundation
Predictive Risk Scoring Engine
- Automated risk calculation for zones, drivers, workers, and equipment
- Configurable weight models per tenant (incidents, near misses, shift hours, workload)
- Confidence scoring (0-1) for risk predictions
- Real-time score computation via Edge Functions
- Predictive Dashboard with trend visualization
Database:
predictive_modelstable (tenant-specific weights)predictive_scorestable (computed risk scores)
UI:
- New Admin → Safety → Predictive Dashboard page
- Score table with filters (entity type, period)
- Trend line charts
- Zone risk color coding
- Safety Officer restricted view
Phase 2: Risk Cluster System
Intelligent Risk Clustering
- Automatic grouping of high-risk entities by severity patterns
- Severity-based cluster assignment
- Top 5 highest risk clusters visualization
- Cluster entity tracking
Database:
risk_clusterstablerisk_cluster_entitiestable
UI:
- Cluster map visualization
- Top 5 risk clusters list
- Filter by cluster
- Entity details per cluster
Phase 3: Hazard Mapping System
Warehouse Floor Plan Integration
- Risk overlay on existing floor plan system
- Smooth gradient visualization (Green → Yellow → Orange → Red)
- Threshold indicators for critical risk
- Tooltip details with risk information
- Manual hazard marking for Safety Officers
Database:
hazard_zonestable (linked to floorplan_zones)
UI:
- Enhanced FloorplanViewer with hazard overlay
- Hazard marking dialog
- Risk score slider
- Notes and documentation
Phase 4: OSHA / EU-OSHA Compliance Automation
Automated Compliance Checking
- Pattern matching against safety regulations
- Automatic violation detection
- Compliance status tracking (compliant, warning, breach)
- Multi-jurisdiction support (US, EU, Global)
Database:
safety_regulationstablesafety_compliance_eventstable
UI:
- Compliance summary cards (Total, Compliant, Warnings, Breaches)
- Violations log table
- Regulation management
- Compliance check automation
Phase 5: Permit-to-Work Workflow Engine
Complete Permit Management
- Permit request workflow
- Approval system (Safety Officers/Admins)
- Document management (attach safety plans, certificates)
- Status tracking (requested → approved → active → closed)
- Zone integration for location tracking
Database:
permitstablepermit_documentstable
UI:
- Permit Workflow page
- Request permit dialog
- Approval/Activation/Closure actions
- Document upload functionality
Phase 6: LMS Training Integration
Risk-Based Training Assignment
- Automatic course assignment when predictive risk exceeds thresholds
- Training course management
- Assignment tracking (manual, auto, risk-based)
- Completion tracking with scores and certificates
- Training analytics dashboard
Database:
training_coursestabletraining_assignmentstabletraining_completionstable
UI:
- Training Center for workers
- Training Analytics for admins
- Auto-assign functionality
- Completion rate tracking
🔧 Technical Improvements
Edge Functions
calculate-predictive-safety-scores— Risk score computationassign-risk-clusters— Risk clustering algorithmcheck-compliance-rules— Compliance automationauto-assign-training— Risk-based training assignment
Database
- 6 new tables with comprehensive RLS policies
- Helper SQL functions for analytics
- Automatic triggers for data consistency
- Optimized indexes for performance
React Query
- Complete hook system for all new features
- Proper query key structure
- Automatic cache invalidation
- Optimistic updates
Documentation
- Comprehensive VitePress documentation
- API reference for Edge Functions
- Usage examples and best practices
- Multilingual support (EN/DE/BG)
🐛 Bug Fixes
- Fixed Select component empty value issue in Permit Workflow
- Fixed SQL migration UNIQUE constraint syntax
- Fixed queryKeys circular dependency
- Fixed import conflicts (compliance automation hooks)
- Fixed SQL function alias conflicts
📊 Performance
- Edge Function aggregation reduces frontend load
- Optimized database queries with proper indexes
- Efficient RLS policy evaluation
- Cached query results with React Query
🔒 Security
- All tables protected with Row-Level Security (RLS)
- Multi-tenant isolation enforced
- Role-based access control (Admin, Safety Officer, Worker)
- Secure Edge Function authentication
📚 Documentation
- Added comprehensive Safety Intelligence documentation
- Updated API reference with new Edge Functions
- Added usage examples and best practices
- Multilingual documentation (EN/DE/BG)
🚀 Migration Guide
Database Migrations
Run the following migrations in order:
20250205000000_predictive_safety_intelligence_phase1.sql20250205000001_predictive_safety_intelligence_phase2.sql20250205000003_predictive_safety_intelligence_phase3.sql20250205000004_predictive_safety_intelligence_phase5_permit_workflow.sql20250205000005_predictive_safety_intelligence_phase6_lms_training.sql
Edge Functions Deployment
Deploy the following Edge Functions:
supabase functions deploy calculate-predictive-safety-scores
supabase functions deploy assign-risk-clusters
supabase functions deploy check-compliance-rules
supabase functions deploy auto-assign-trainingNo Breaking Changes
- All existing features remain unchanged
- Fully backward compatible
- No manual refactoring required
- Existing data remains valid
🎯 Upgrade Notes
- Before upgrading: Backup your database
- Run migrations: Execute all 5 migration files in order
- Deploy Edge Functions: Deploy all 4 new Edge Functions
- Verify RLS: Ensure RLS policies are active
- Test features: Verify Predictive Dashboard, Risk Clusters, Hazard Mapping, Compliance, Permits, and Training features
📈 What's Next
Future enhancements planned:
- Scheduled auto-assignment for training
- Email notifications for new assignments
- Certificate PDF generation
- Advanced analytics dashboards
- Mobile app integration
🙏 Acknowledgments
This release represents a major milestone in safety intelligence automation. All features are production-ready and fully tested.
Full Changelog: See individual phase commits in the repository.