Files
bakery-ia/services/orchestrator/app/api/dashboard.py

772 lines
31 KiB
Python
Raw Normal View History

feat: Complete JTBD-aligned bakery dashboard redesign Implements comprehensive dashboard redesign based on Jobs To Be Done methodology focused on answering: "What requires my attention right now?" ## Backend Implementation ### Dashboard Service (NEW) - Health status calculation (green/yellow/red traffic light) - Action queue prioritization (critical/important/normal) - Orchestration summary with narrative format - Production timeline transformation - Insights calculation and consequence prediction ### API Endpoints (NEW) - GET /dashboard/health-status - Overall bakery health indicator - GET /dashboard/orchestration-summary - What system did automatically - GET /dashboard/action-queue - Prioritized tasks requiring attention - GET /dashboard/production-timeline - Today's production schedule - GET /dashboard/insights - Key metrics (savings, inventory, waste, deliveries) ### Enhanced Models - PurchaseOrder: Added reasoning, consequence, reasoning_data fields - ProductionBatch: Added reasoning, reasoning_data fields - Enables transparency into automation decisions ## Frontend Implementation ### API Hooks (NEW) - useBakeryHealthStatus() - Real-time health monitoring - useOrchestrationSummary() - System transparency - useActionQueue() - Prioritized action management - useProductionTimeline() - Production tracking - useInsights() - Glanceable metrics ### Dashboard Components (NEW) - HealthStatusCard: Traffic light indicator with checklist - ActionQueueCard: Prioritized actions with reasoning/consequences - OrchestrationSummaryCard: Narrative of what system did - ProductionTimelineCard: Chronological production view - InsightsGrid: 2x2 grid of key metrics ### Main Dashboard Page (REPLACED) - Complete rewrite with mobile-first design - All sections integrated with error handling - Real-time refresh and quick action links - Old dashboard backed up as DashboardPage.legacy.tsx ## Key Features ### Automation-First - Shows what orchestrator did overnight - Builds trust through transparency - Explains reasoning for all automated decisions ### Action-Oriented - Prioritizes tasks over information display - Clear consequences for each action - Large touch-friendly buttons ### Progressive Disclosure - Shows 20% of info that matters 80% of time - Expandable details when needed - No overwhelming metrics ### Mobile-First - One-handed operation - Large touch targets (min 44px) - Responsive grid layouts ### Trust-Building - Narrative format ("I planned your day") - Reasoning inputs transparency - Clear status indicators ## User Segments Supported 1. Solo Bakery Owner (Primary) - Simple health indicator - Action checklist (max 3-5 items) - Mobile-optimized 2. Multi-Location Owner - Multi-tenant support (existing) - Comparison capabilities - Delegation ready 3. Enterprise/Central Bakery (Future) - Network topology support - Advanced analytics ready ## JTBD Analysis Delivered Main Job: "Help me quickly understand bakery status and know what needs my intervention" Emotional Jobs Addressed: - Feel in control despite automation - Reduce daily anxiety - Feel competent with technology - Trust system as safety net Social Jobs Addressed: - Demonstrate professional management - Avoid being bottleneck - Show sustainability ## Technical Stack Backend: Python, FastAPI, SQLAlchemy, PostgreSQL Frontend: React, TypeScript, TanStack Query, Tailwind CSS Architecture: Microservices with circuit breakers ## Breaking Changes - Complete dashboard page rewrite (old version backed up) - New API endpoints require orchestrator service deployment - Database migrations needed for reasoning fields ## Migration Required Run migrations to add new model fields: - purchase_orders: reasoning, consequence, reasoning_data - production_batches: reasoning, reasoning_data ## Documentation See DASHBOARD_REDESIGN_SUMMARY.md for complete implementation details, JTBD analysis, success metrics, and deployment guide. BREAKING CHANGE: Dashboard page completely redesigned with new data structures
2025-11-07 17:10:17 +00:00
# ================================================================
# services/orchestrator/app/api/dashboard.py
# ================================================================
"""
Dashboard API endpoints for JTBD-aligned bakery dashboard
"""
from fastapi import APIRouter, Depends, HTTPException, Query
from sqlalchemy.ext.asyncio import AsyncSession
from typing import Dict, Any, List, Optional
from pydantic import BaseModel, Field
from datetime import datetime
import logging
2025-11-15 21:21:06 +01:00
import asyncio
feat: Complete JTBD-aligned bakery dashboard redesign Implements comprehensive dashboard redesign based on Jobs To Be Done methodology focused on answering: "What requires my attention right now?" ## Backend Implementation ### Dashboard Service (NEW) - Health status calculation (green/yellow/red traffic light) - Action queue prioritization (critical/important/normal) - Orchestration summary with narrative format - Production timeline transformation - Insights calculation and consequence prediction ### API Endpoints (NEW) - GET /dashboard/health-status - Overall bakery health indicator - GET /dashboard/orchestration-summary - What system did automatically - GET /dashboard/action-queue - Prioritized tasks requiring attention - GET /dashboard/production-timeline - Today's production schedule - GET /dashboard/insights - Key metrics (savings, inventory, waste, deliveries) ### Enhanced Models - PurchaseOrder: Added reasoning, consequence, reasoning_data fields - ProductionBatch: Added reasoning, reasoning_data fields - Enables transparency into automation decisions ## Frontend Implementation ### API Hooks (NEW) - useBakeryHealthStatus() - Real-time health monitoring - useOrchestrationSummary() - System transparency - useActionQueue() - Prioritized action management - useProductionTimeline() - Production tracking - useInsights() - Glanceable metrics ### Dashboard Components (NEW) - HealthStatusCard: Traffic light indicator with checklist - ActionQueueCard: Prioritized actions with reasoning/consequences - OrchestrationSummaryCard: Narrative of what system did - ProductionTimelineCard: Chronological production view - InsightsGrid: 2x2 grid of key metrics ### Main Dashboard Page (REPLACED) - Complete rewrite with mobile-first design - All sections integrated with error handling - Real-time refresh and quick action links - Old dashboard backed up as DashboardPage.legacy.tsx ## Key Features ### Automation-First - Shows what orchestrator did overnight - Builds trust through transparency - Explains reasoning for all automated decisions ### Action-Oriented - Prioritizes tasks over information display - Clear consequences for each action - Large touch-friendly buttons ### Progressive Disclosure - Shows 20% of info that matters 80% of time - Expandable details when needed - No overwhelming metrics ### Mobile-First - One-handed operation - Large touch targets (min 44px) - Responsive grid layouts ### Trust-Building - Narrative format ("I planned your day") - Reasoning inputs transparency - Clear status indicators ## User Segments Supported 1. Solo Bakery Owner (Primary) - Simple health indicator - Action checklist (max 3-5 items) - Mobile-optimized 2. Multi-Location Owner - Multi-tenant support (existing) - Comparison capabilities - Delegation ready 3. Enterprise/Central Bakery (Future) - Network topology support - Advanced analytics ready ## JTBD Analysis Delivered Main Job: "Help me quickly understand bakery status and know what needs my intervention" Emotional Jobs Addressed: - Feel in control despite automation - Reduce daily anxiety - Feel competent with technology - Trust system as safety net Social Jobs Addressed: - Demonstrate professional management - Avoid being bottleneck - Show sustainability ## Technical Stack Backend: Python, FastAPI, SQLAlchemy, PostgreSQL Frontend: React, TypeScript, TanStack Query, Tailwind CSS Architecture: Microservices with circuit breakers ## Breaking Changes - Complete dashboard page rewrite (old version backed up) - New API endpoints require orchestrator service deployment - Database migrations needed for reasoning fields ## Migration Required Run migrations to add new model fields: - purchase_orders: reasoning, consequence, reasoning_data - production_batches: reasoning, reasoning_data ## Documentation See DASHBOARD_REDESIGN_SUMMARY.md for complete implementation details, JTBD analysis, success metrics, and deployment guide. BREAKING CHANGE: Dashboard page completely redesigned with new data structures
2025-11-07 17:10:17 +00:00
from app.core.database import get_db
from app.core.config import settings
feat: Complete JTBD-aligned bakery dashboard redesign Implements comprehensive dashboard redesign based on Jobs To Be Done methodology focused on answering: "What requires my attention right now?" ## Backend Implementation ### Dashboard Service (NEW) - Health status calculation (green/yellow/red traffic light) - Action queue prioritization (critical/important/normal) - Orchestration summary with narrative format - Production timeline transformation - Insights calculation and consequence prediction ### API Endpoints (NEW) - GET /dashboard/health-status - Overall bakery health indicator - GET /dashboard/orchestration-summary - What system did automatically - GET /dashboard/action-queue - Prioritized tasks requiring attention - GET /dashboard/production-timeline - Today's production schedule - GET /dashboard/insights - Key metrics (savings, inventory, waste, deliveries) ### Enhanced Models - PurchaseOrder: Added reasoning, consequence, reasoning_data fields - ProductionBatch: Added reasoning, reasoning_data fields - Enables transparency into automation decisions ## Frontend Implementation ### API Hooks (NEW) - useBakeryHealthStatus() - Real-time health monitoring - useOrchestrationSummary() - System transparency - useActionQueue() - Prioritized action management - useProductionTimeline() - Production tracking - useInsights() - Glanceable metrics ### Dashboard Components (NEW) - HealthStatusCard: Traffic light indicator with checklist - ActionQueueCard: Prioritized actions with reasoning/consequences - OrchestrationSummaryCard: Narrative of what system did - ProductionTimelineCard: Chronological production view - InsightsGrid: 2x2 grid of key metrics ### Main Dashboard Page (REPLACED) - Complete rewrite with mobile-first design - All sections integrated with error handling - Real-time refresh and quick action links - Old dashboard backed up as DashboardPage.legacy.tsx ## Key Features ### Automation-First - Shows what orchestrator did overnight - Builds trust through transparency - Explains reasoning for all automated decisions ### Action-Oriented - Prioritizes tasks over information display - Clear consequences for each action - Large touch-friendly buttons ### Progressive Disclosure - Shows 20% of info that matters 80% of time - Expandable details when needed - No overwhelming metrics ### Mobile-First - One-handed operation - Large touch targets (min 44px) - Responsive grid layouts ### Trust-Building - Narrative format ("I planned your day") - Reasoning inputs transparency - Clear status indicators ## User Segments Supported 1. Solo Bakery Owner (Primary) - Simple health indicator - Action checklist (max 3-5 items) - Mobile-optimized 2. Multi-Location Owner - Multi-tenant support (existing) - Comparison capabilities - Delegation ready 3. Enterprise/Central Bakery (Future) - Network topology support - Advanced analytics ready ## JTBD Analysis Delivered Main Job: "Help me quickly understand bakery status and know what needs my intervention" Emotional Jobs Addressed: - Feel in control despite automation - Reduce daily anxiety - Feel competent with technology - Trust system as safety net Social Jobs Addressed: - Demonstrate professional management - Avoid being bottleneck - Show sustainability ## Technical Stack Backend: Python, FastAPI, SQLAlchemy, PostgreSQL Frontend: React, TypeScript, TanStack Query, Tailwind CSS Architecture: Microservices with circuit breakers ## Breaking Changes - Complete dashboard page rewrite (old version backed up) - New API endpoints require orchestrator service deployment - Database migrations needed for reasoning fields ## Migration Required Run migrations to add new model fields: - purchase_orders: reasoning, consequence, reasoning_data - production_batches: reasoning, reasoning_data ## Documentation See DASHBOARD_REDESIGN_SUMMARY.md for complete implementation details, JTBD analysis, success metrics, and deployment guide. BREAKING CHANGE: Dashboard page completely redesigned with new data structures
2025-11-07 17:10:17 +00:00
from ..services.dashboard_service import DashboardService
2025-11-15 21:21:06 +01:00
from ..utils.cache import get_cached, set_cached, delete_pattern
from shared.clients import (
get_inventory_client,
get_production_client,
get_alerts_client,
ProductionServiceClient,
InventoryServiceClient,
AlertsServiceClient
)
from shared.clients.procurement_client import ProcurementServiceClient
feat: Complete JTBD-aligned bakery dashboard redesign Implements comprehensive dashboard redesign based on Jobs To Be Done methodology focused on answering: "What requires my attention right now?" ## Backend Implementation ### Dashboard Service (NEW) - Health status calculation (green/yellow/red traffic light) - Action queue prioritization (critical/important/normal) - Orchestration summary with narrative format - Production timeline transformation - Insights calculation and consequence prediction ### API Endpoints (NEW) - GET /dashboard/health-status - Overall bakery health indicator - GET /dashboard/orchestration-summary - What system did automatically - GET /dashboard/action-queue - Prioritized tasks requiring attention - GET /dashboard/production-timeline - Today's production schedule - GET /dashboard/insights - Key metrics (savings, inventory, waste, deliveries) ### Enhanced Models - PurchaseOrder: Added reasoning, consequence, reasoning_data fields - ProductionBatch: Added reasoning, reasoning_data fields - Enables transparency into automation decisions ## Frontend Implementation ### API Hooks (NEW) - useBakeryHealthStatus() - Real-time health monitoring - useOrchestrationSummary() - System transparency - useActionQueue() - Prioritized action management - useProductionTimeline() - Production tracking - useInsights() - Glanceable metrics ### Dashboard Components (NEW) - HealthStatusCard: Traffic light indicator with checklist - ActionQueueCard: Prioritized actions with reasoning/consequences - OrchestrationSummaryCard: Narrative of what system did - ProductionTimelineCard: Chronological production view - InsightsGrid: 2x2 grid of key metrics ### Main Dashboard Page (REPLACED) - Complete rewrite with mobile-first design - All sections integrated with error handling - Real-time refresh and quick action links - Old dashboard backed up as DashboardPage.legacy.tsx ## Key Features ### Automation-First - Shows what orchestrator did overnight - Builds trust through transparency - Explains reasoning for all automated decisions ### Action-Oriented - Prioritizes tasks over information display - Clear consequences for each action - Large touch-friendly buttons ### Progressive Disclosure - Shows 20% of info that matters 80% of time - Expandable details when needed - No overwhelming metrics ### Mobile-First - One-handed operation - Large touch targets (min 44px) - Responsive grid layouts ### Trust-Building - Narrative format ("I planned your day") - Reasoning inputs transparency - Clear status indicators ## User Segments Supported 1. Solo Bakery Owner (Primary) - Simple health indicator - Action checklist (max 3-5 items) - Mobile-optimized 2. Multi-Location Owner - Multi-tenant support (existing) - Comparison capabilities - Delegation ready 3. Enterprise/Central Bakery (Future) - Network topology support - Advanced analytics ready ## JTBD Analysis Delivered Main Job: "Help me quickly understand bakery status and know what needs my intervention" Emotional Jobs Addressed: - Feel in control despite automation - Reduce daily anxiety - Feel competent with technology - Trust system as safety net Social Jobs Addressed: - Demonstrate professional management - Avoid being bottleneck - Show sustainability ## Technical Stack Backend: Python, FastAPI, SQLAlchemy, PostgreSQL Frontend: React, TypeScript, TanStack Query, Tailwind CSS Architecture: Microservices with circuit breakers ## Breaking Changes - Complete dashboard page rewrite (old version backed up) - New API endpoints require orchestrator service deployment - Database migrations needed for reasoning fields ## Migration Required Run migrations to add new model fields: - purchase_orders: reasoning, consequence, reasoning_data - production_batches: reasoning, reasoning_data ## Documentation See DASHBOARD_REDESIGN_SUMMARY.md for complete implementation details, JTBD analysis, success metrics, and deployment guide. BREAKING CHANGE: Dashboard page completely redesigned with new data structures
2025-11-07 17:10:17 +00:00
logger = logging.getLogger(__name__)
# Initialize service clients
inventory_client = get_inventory_client(settings, "orchestrator")
production_client = get_production_client(settings, "orchestrator")
procurement_client = ProcurementServiceClient(settings)
alerts_client = get_alerts_client(settings, "orchestrator")
feat: Complete JTBD-aligned bakery dashboard redesign Implements comprehensive dashboard redesign based on Jobs To Be Done methodology focused on answering: "What requires my attention right now?" ## Backend Implementation ### Dashboard Service (NEW) - Health status calculation (green/yellow/red traffic light) - Action queue prioritization (critical/important/normal) - Orchestration summary with narrative format - Production timeline transformation - Insights calculation and consequence prediction ### API Endpoints (NEW) - GET /dashboard/health-status - Overall bakery health indicator - GET /dashboard/orchestration-summary - What system did automatically - GET /dashboard/action-queue - Prioritized tasks requiring attention - GET /dashboard/production-timeline - Today's production schedule - GET /dashboard/insights - Key metrics (savings, inventory, waste, deliveries) ### Enhanced Models - PurchaseOrder: Added reasoning, consequence, reasoning_data fields - ProductionBatch: Added reasoning, reasoning_data fields - Enables transparency into automation decisions ## Frontend Implementation ### API Hooks (NEW) - useBakeryHealthStatus() - Real-time health monitoring - useOrchestrationSummary() - System transparency - useActionQueue() - Prioritized action management - useProductionTimeline() - Production tracking - useInsights() - Glanceable metrics ### Dashboard Components (NEW) - HealthStatusCard: Traffic light indicator with checklist - ActionQueueCard: Prioritized actions with reasoning/consequences - OrchestrationSummaryCard: Narrative of what system did - ProductionTimelineCard: Chronological production view - InsightsGrid: 2x2 grid of key metrics ### Main Dashboard Page (REPLACED) - Complete rewrite with mobile-first design - All sections integrated with error handling - Real-time refresh and quick action links - Old dashboard backed up as DashboardPage.legacy.tsx ## Key Features ### Automation-First - Shows what orchestrator did overnight - Builds trust through transparency - Explains reasoning for all automated decisions ### Action-Oriented - Prioritizes tasks over information display - Clear consequences for each action - Large touch-friendly buttons ### Progressive Disclosure - Shows 20% of info that matters 80% of time - Expandable details when needed - No overwhelming metrics ### Mobile-First - One-handed operation - Large touch targets (min 44px) - Responsive grid layouts ### Trust-Building - Narrative format ("I planned your day") - Reasoning inputs transparency - Clear status indicators ## User Segments Supported 1. Solo Bakery Owner (Primary) - Simple health indicator - Action checklist (max 3-5 items) - Mobile-optimized 2. Multi-Location Owner - Multi-tenant support (existing) - Comparison capabilities - Delegation ready 3. Enterprise/Central Bakery (Future) - Network topology support - Advanced analytics ready ## JTBD Analysis Delivered Main Job: "Help me quickly understand bakery status and know what needs my intervention" Emotional Jobs Addressed: - Feel in control despite automation - Reduce daily anxiety - Feel competent with technology - Trust system as safety net Social Jobs Addressed: - Demonstrate professional management - Avoid being bottleneck - Show sustainability ## Technical Stack Backend: Python, FastAPI, SQLAlchemy, PostgreSQL Frontend: React, TypeScript, TanStack Query, Tailwind CSS Architecture: Microservices with circuit breakers ## Breaking Changes - Complete dashboard page rewrite (old version backed up) - New API endpoints require orchestrator service deployment - Database migrations needed for reasoning fields ## Migration Required Run migrations to add new model fields: - purchase_orders: reasoning, consequence, reasoning_data - production_batches: reasoning, reasoning_data ## Documentation See DASHBOARD_REDESIGN_SUMMARY.md for complete implementation details, JTBD analysis, success metrics, and deployment guide. BREAKING CHANGE: Dashboard page completely redesigned with new data structures
2025-11-07 17:10:17 +00:00
router = APIRouter(prefix="/api/v1/tenants/{tenant_id}/dashboard", tags=["dashboard"])
# ============================================================
# Response Models
# ============================================================
2025-11-20 19:14:49 +01:00
class I18nData(BaseModel):
"""i18n translation data"""
key: str = Field(..., description="i18n translation key")
params: Optional[Dict[str, Any]] = Field(default_factory=dict, description="Parameters for translation")
2025-11-13 16:01:08 +01:00
class HeadlineData(BaseModel):
"""i18n-ready headline data"""
key: str = Field(..., description="i18n translation key")
params: Dict[str, Any] = Field(default_factory=dict, description="Parameters for translation")
feat: Complete JTBD-aligned bakery dashboard redesign Implements comprehensive dashboard redesign based on Jobs To Be Done methodology focused on answering: "What requires my attention right now?" ## Backend Implementation ### Dashboard Service (NEW) - Health status calculation (green/yellow/red traffic light) - Action queue prioritization (critical/important/normal) - Orchestration summary with narrative format - Production timeline transformation - Insights calculation and consequence prediction ### API Endpoints (NEW) - GET /dashboard/health-status - Overall bakery health indicator - GET /dashboard/orchestration-summary - What system did automatically - GET /dashboard/action-queue - Prioritized tasks requiring attention - GET /dashboard/production-timeline - Today's production schedule - GET /dashboard/insights - Key metrics (savings, inventory, waste, deliveries) ### Enhanced Models - PurchaseOrder: Added reasoning, consequence, reasoning_data fields - ProductionBatch: Added reasoning, reasoning_data fields - Enables transparency into automation decisions ## Frontend Implementation ### API Hooks (NEW) - useBakeryHealthStatus() - Real-time health monitoring - useOrchestrationSummary() - System transparency - useActionQueue() - Prioritized action management - useProductionTimeline() - Production tracking - useInsights() - Glanceable metrics ### Dashboard Components (NEW) - HealthStatusCard: Traffic light indicator with checklist - ActionQueueCard: Prioritized actions with reasoning/consequences - OrchestrationSummaryCard: Narrative of what system did - ProductionTimelineCard: Chronological production view - InsightsGrid: 2x2 grid of key metrics ### Main Dashboard Page (REPLACED) - Complete rewrite with mobile-first design - All sections integrated with error handling - Real-time refresh and quick action links - Old dashboard backed up as DashboardPage.legacy.tsx ## Key Features ### Automation-First - Shows what orchestrator did overnight - Builds trust through transparency - Explains reasoning for all automated decisions ### Action-Oriented - Prioritizes tasks over information display - Clear consequences for each action - Large touch-friendly buttons ### Progressive Disclosure - Shows 20% of info that matters 80% of time - Expandable details when needed - No overwhelming metrics ### Mobile-First - One-handed operation - Large touch targets (min 44px) - Responsive grid layouts ### Trust-Building - Narrative format ("I planned your day") - Reasoning inputs transparency - Clear status indicators ## User Segments Supported 1. Solo Bakery Owner (Primary) - Simple health indicator - Action checklist (max 3-5 items) - Mobile-optimized 2. Multi-Location Owner - Multi-tenant support (existing) - Comparison capabilities - Delegation ready 3. Enterprise/Central Bakery (Future) - Network topology support - Advanced analytics ready ## JTBD Analysis Delivered Main Job: "Help me quickly understand bakery status and know what needs my intervention" Emotional Jobs Addressed: - Feel in control despite automation - Reduce daily anxiety - Feel competent with technology - Trust system as safety net Social Jobs Addressed: - Demonstrate professional management - Avoid being bottleneck - Show sustainability ## Technical Stack Backend: Python, FastAPI, SQLAlchemy, PostgreSQL Frontend: React, TypeScript, TanStack Query, Tailwind CSS Architecture: Microservices with circuit breakers ## Breaking Changes - Complete dashboard page rewrite (old version backed up) - New API endpoints require orchestrator service deployment - Database migrations needed for reasoning fields ## Migration Required Run migrations to add new model fields: - purchase_orders: reasoning, consequence, reasoning_data - production_batches: reasoning, reasoning_data ## Documentation See DASHBOARD_REDESIGN_SUMMARY.md for complete implementation details, JTBD analysis, success metrics, and deployment guide. BREAKING CHANGE: Dashboard page completely redesigned with new data structures
2025-11-07 17:10:17 +00:00
class HealthChecklistItem(BaseModel):
"""Individual item in tri-state health checklist"""
icon: str = Field(..., description="Icon name: check, warning, alert, ai_handled")
2025-11-13 16:01:08 +01:00
text: Optional[str] = Field(None, description="Deprecated: Use textKey instead")
textKey: Optional[str] = Field(None, description="i18n translation key")
textParams: Optional[Dict[str, Any]] = Field(None, description="Parameters for i18n translation")
feat: Complete JTBD-aligned bakery dashboard redesign Implements comprehensive dashboard redesign based on Jobs To Be Done methodology focused on answering: "What requires my attention right now?" ## Backend Implementation ### Dashboard Service (NEW) - Health status calculation (green/yellow/red traffic light) - Action queue prioritization (critical/important/normal) - Orchestration summary with narrative format - Production timeline transformation - Insights calculation and consequence prediction ### API Endpoints (NEW) - GET /dashboard/health-status - Overall bakery health indicator - GET /dashboard/orchestration-summary - What system did automatically - GET /dashboard/action-queue - Prioritized tasks requiring attention - GET /dashboard/production-timeline - Today's production schedule - GET /dashboard/insights - Key metrics (savings, inventory, waste, deliveries) ### Enhanced Models - PurchaseOrder: Added reasoning, consequence, reasoning_data fields - ProductionBatch: Added reasoning, reasoning_data fields - Enables transparency into automation decisions ## Frontend Implementation ### API Hooks (NEW) - useBakeryHealthStatus() - Real-time health monitoring - useOrchestrationSummary() - System transparency - useActionQueue() - Prioritized action management - useProductionTimeline() - Production tracking - useInsights() - Glanceable metrics ### Dashboard Components (NEW) - HealthStatusCard: Traffic light indicator with checklist - ActionQueueCard: Prioritized actions with reasoning/consequences - OrchestrationSummaryCard: Narrative of what system did - ProductionTimelineCard: Chronological production view - InsightsGrid: 2x2 grid of key metrics ### Main Dashboard Page (REPLACED) - Complete rewrite with mobile-first design - All sections integrated with error handling - Real-time refresh and quick action links - Old dashboard backed up as DashboardPage.legacy.tsx ## Key Features ### Automation-First - Shows what orchestrator did overnight - Builds trust through transparency - Explains reasoning for all automated decisions ### Action-Oriented - Prioritizes tasks over information display - Clear consequences for each action - Large touch-friendly buttons ### Progressive Disclosure - Shows 20% of info that matters 80% of time - Expandable details when needed - No overwhelming metrics ### Mobile-First - One-handed operation - Large touch targets (min 44px) - Responsive grid layouts ### Trust-Building - Narrative format ("I planned your day") - Reasoning inputs transparency - Clear status indicators ## User Segments Supported 1. Solo Bakery Owner (Primary) - Simple health indicator - Action checklist (max 3-5 items) - Mobile-optimized 2. Multi-Location Owner - Multi-tenant support (existing) - Comparison capabilities - Delegation ready 3. Enterprise/Central Bakery (Future) - Network topology support - Advanced analytics ready ## JTBD Analysis Delivered Main Job: "Help me quickly understand bakery status and know what needs my intervention" Emotional Jobs Addressed: - Feel in control despite automation - Reduce daily anxiety - Feel competent with technology - Trust system as safety net Social Jobs Addressed: - Demonstrate professional management - Avoid being bottleneck - Show sustainability ## Technical Stack Backend: Python, FastAPI, SQLAlchemy, PostgreSQL Frontend: React, TypeScript, TanStack Query, Tailwind CSS Architecture: Microservices with circuit breakers ## Breaking Changes - Complete dashboard page rewrite (old version backed up) - New API endpoints require orchestrator service deployment - Database migrations needed for reasoning fields ## Migration Required Run migrations to add new model fields: - purchase_orders: reasoning, consequence, reasoning_data - production_batches: reasoning, reasoning_data ## Documentation See DASHBOARD_REDESIGN_SUMMARY.md for complete implementation details, JTBD analysis, success metrics, and deployment guide. BREAKING CHANGE: Dashboard page completely redesigned with new data structures
2025-11-07 17:10:17 +00:00
actionRequired: bool = Field(..., description="Whether action is required")
status: str = Field(..., description="Tri-state status: good, ai_handled, needs_you")
actionPath: Optional[str] = Field(None, description="Path to navigate for action")
feat: Complete JTBD-aligned bakery dashboard redesign Implements comprehensive dashboard redesign based on Jobs To Be Done methodology focused on answering: "What requires my attention right now?" ## Backend Implementation ### Dashboard Service (NEW) - Health status calculation (green/yellow/red traffic light) - Action queue prioritization (critical/important/normal) - Orchestration summary with narrative format - Production timeline transformation - Insights calculation and consequence prediction ### API Endpoints (NEW) - GET /dashboard/health-status - Overall bakery health indicator - GET /dashboard/orchestration-summary - What system did automatically - GET /dashboard/action-queue - Prioritized tasks requiring attention - GET /dashboard/production-timeline - Today's production schedule - GET /dashboard/insights - Key metrics (savings, inventory, waste, deliveries) ### Enhanced Models - PurchaseOrder: Added reasoning, consequence, reasoning_data fields - ProductionBatch: Added reasoning, reasoning_data fields - Enables transparency into automation decisions ## Frontend Implementation ### API Hooks (NEW) - useBakeryHealthStatus() - Real-time health monitoring - useOrchestrationSummary() - System transparency - useActionQueue() - Prioritized action management - useProductionTimeline() - Production tracking - useInsights() - Glanceable metrics ### Dashboard Components (NEW) - HealthStatusCard: Traffic light indicator with checklist - ActionQueueCard: Prioritized actions with reasoning/consequences - OrchestrationSummaryCard: Narrative of what system did - ProductionTimelineCard: Chronological production view - InsightsGrid: 2x2 grid of key metrics ### Main Dashboard Page (REPLACED) - Complete rewrite with mobile-first design - All sections integrated with error handling - Real-time refresh and quick action links - Old dashboard backed up as DashboardPage.legacy.tsx ## Key Features ### Automation-First - Shows what orchestrator did overnight - Builds trust through transparency - Explains reasoning for all automated decisions ### Action-Oriented - Prioritizes tasks over information display - Clear consequences for each action - Large touch-friendly buttons ### Progressive Disclosure - Shows 20% of info that matters 80% of time - Expandable details when needed - No overwhelming metrics ### Mobile-First - One-handed operation - Large touch targets (min 44px) - Responsive grid layouts ### Trust-Building - Narrative format ("I planned your day") - Reasoning inputs transparency - Clear status indicators ## User Segments Supported 1. Solo Bakery Owner (Primary) - Simple health indicator - Action checklist (max 3-5 items) - Mobile-optimized 2. Multi-Location Owner - Multi-tenant support (existing) - Comparison capabilities - Delegation ready 3. Enterprise/Central Bakery (Future) - Network topology support - Advanced analytics ready ## JTBD Analysis Delivered Main Job: "Help me quickly understand bakery status and know what needs my intervention" Emotional Jobs Addressed: - Feel in control despite automation - Reduce daily anxiety - Feel competent with technology - Trust system as safety net Social Jobs Addressed: - Demonstrate professional management - Avoid being bottleneck - Show sustainability ## Technical Stack Backend: Python, FastAPI, SQLAlchemy, PostgreSQL Frontend: React, TypeScript, TanStack Query, Tailwind CSS Architecture: Microservices with circuit breakers ## Breaking Changes - Complete dashboard page rewrite (old version backed up) - New API endpoints require orchestrator service deployment - Database migrations needed for reasoning fields ## Migration Required Run migrations to add new model fields: - purchase_orders: reasoning, consequence, reasoning_data - production_batches: reasoning, reasoning_data ## Documentation See DASHBOARD_REDESIGN_SUMMARY.md for complete implementation details, JTBD analysis, success metrics, and deployment guide. BREAKING CHANGE: Dashboard page completely redesigned with new data structures
2025-11-07 17:10:17 +00:00
class BakeryHealthStatusResponse(BaseModel):
"""Overall bakery health status with tri-state checklist"""
feat: Complete JTBD-aligned bakery dashboard redesign Implements comprehensive dashboard redesign based on Jobs To Be Done methodology focused on answering: "What requires my attention right now?" ## Backend Implementation ### Dashboard Service (NEW) - Health status calculation (green/yellow/red traffic light) - Action queue prioritization (critical/important/normal) - Orchestration summary with narrative format - Production timeline transformation - Insights calculation and consequence prediction ### API Endpoints (NEW) - GET /dashboard/health-status - Overall bakery health indicator - GET /dashboard/orchestration-summary - What system did automatically - GET /dashboard/action-queue - Prioritized tasks requiring attention - GET /dashboard/production-timeline - Today's production schedule - GET /dashboard/insights - Key metrics (savings, inventory, waste, deliveries) ### Enhanced Models - PurchaseOrder: Added reasoning, consequence, reasoning_data fields - ProductionBatch: Added reasoning, reasoning_data fields - Enables transparency into automation decisions ## Frontend Implementation ### API Hooks (NEW) - useBakeryHealthStatus() - Real-time health monitoring - useOrchestrationSummary() - System transparency - useActionQueue() - Prioritized action management - useProductionTimeline() - Production tracking - useInsights() - Glanceable metrics ### Dashboard Components (NEW) - HealthStatusCard: Traffic light indicator with checklist - ActionQueueCard: Prioritized actions with reasoning/consequences - OrchestrationSummaryCard: Narrative of what system did - ProductionTimelineCard: Chronological production view - InsightsGrid: 2x2 grid of key metrics ### Main Dashboard Page (REPLACED) - Complete rewrite with mobile-first design - All sections integrated with error handling - Real-time refresh and quick action links - Old dashboard backed up as DashboardPage.legacy.tsx ## Key Features ### Automation-First - Shows what orchestrator did overnight - Builds trust through transparency - Explains reasoning for all automated decisions ### Action-Oriented - Prioritizes tasks over information display - Clear consequences for each action - Large touch-friendly buttons ### Progressive Disclosure - Shows 20% of info that matters 80% of time - Expandable details when needed - No overwhelming metrics ### Mobile-First - One-handed operation - Large touch targets (min 44px) - Responsive grid layouts ### Trust-Building - Narrative format ("I planned your day") - Reasoning inputs transparency - Clear status indicators ## User Segments Supported 1. Solo Bakery Owner (Primary) - Simple health indicator - Action checklist (max 3-5 items) - Mobile-optimized 2. Multi-Location Owner - Multi-tenant support (existing) - Comparison capabilities - Delegation ready 3. Enterprise/Central Bakery (Future) - Network topology support - Advanced analytics ready ## JTBD Analysis Delivered Main Job: "Help me quickly understand bakery status and know what needs my intervention" Emotional Jobs Addressed: - Feel in control despite automation - Reduce daily anxiety - Feel competent with technology - Trust system as safety net Social Jobs Addressed: - Demonstrate professional management - Avoid being bottleneck - Show sustainability ## Technical Stack Backend: Python, FastAPI, SQLAlchemy, PostgreSQL Frontend: React, TypeScript, TanStack Query, Tailwind CSS Architecture: Microservices with circuit breakers ## Breaking Changes - Complete dashboard page rewrite (old version backed up) - New API endpoints require orchestrator service deployment - Database migrations needed for reasoning fields ## Migration Required Run migrations to add new model fields: - purchase_orders: reasoning, consequence, reasoning_data - production_batches: reasoning, reasoning_data ## Documentation See DASHBOARD_REDESIGN_SUMMARY.md for complete implementation details, JTBD analysis, success metrics, and deployment guide. BREAKING CHANGE: Dashboard page completely redesigned with new data structures
2025-11-07 17:10:17 +00:00
status: str = Field(..., description="Health status: green, yellow, red")
2025-11-13 16:01:08 +01:00
headline: HeadlineData = Field(..., description="i18n-ready status headline")
feat: Complete JTBD-aligned bakery dashboard redesign Implements comprehensive dashboard redesign based on Jobs To Be Done methodology focused on answering: "What requires my attention right now?" ## Backend Implementation ### Dashboard Service (NEW) - Health status calculation (green/yellow/red traffic light) - Action queue prioritization (critical/important/normal) - Orchestration summary with narrative format - Production timeline transformation - Insights calculation and consequence prediction ### API Endpoints (NEW) - GET /dashboard/health-status - Overall bakery health indicator - GET /dashboard/orchestration-summary - What system did automatically - GET /dashboard/action-queue - Prioritized tasks requiring attention - GET /dashboard/production-timeline - Today's production schedule - GET /dashboard/insights - Key metrics (savings, inventory, waste, deliveries) ### Enhanced Models - PurchaseOrder: Added reasoning, consequence, reasoning_data fields - ProductionBatch: Added reasoning, reasoning_data fields - Enables transparency into automation decisions ## Frontend Implementation ### API Hooks (NEW) - useBakeryHealthStatus() - Real-time health monitoring - useOrchestrationSummary() - System transparency - useActionQueue() - Prioritized action management - useProductionTimeline() - Production tracking - useInsights() - Glanceable metrics ### Dashboard Components (NEW) - HealthStatusCard: Traffic light indicator with checklist - ActionQueueCard: Prioritized actions with reasoning/consequences - OrchestrationSummaryCard: Narrative of what system did - ProductionTimelineCard: Chronological production view - InsightsGrid: 2x2 grid of key metrics ### Main Dashboard Page (REPLACED) - Complete rewrite with mobile-first design - All sections integrated with error handling - Real-time refresh and quick action links - Old dashboard backed up as DashboardPage.legacy.tsx ## Key Features ### Automation-First - Shows what orchestrator did overnight - Builds trust through transparency - Explains reasoning for all automated decisions ### Action-Oriented - Prioritizes tasks over information display - Clear consequences for each action - Large touch-friendly buttons ### Progressive Disclosure - Shows 20% of info that matters 80% of time - Expandable details when needed - No overwhelming metrics ### Mobile-First - One-handed operation - Large touch targets (min 44px) - Responsive grid layouts ### Trust-Building - Narrative format ("I planned your day") - Reasoning inputs transparency - Clear status indicators ## User Segments Supported 1. Solo Bakery Owner (Primary) - Simple health indicator - Action checklist (max 3-5 items) - Mobile-optimized 2. Multi-Location Owner - Multi-tenant support (existing) - Comparison capabilities - Delegation ready 3. Enterprise/Central Bakery (Future) - Network topology support - Advanced analytics ready ## JTBD Analysis Delivered Main Job: "Help me quickly understand bakery status and know what needs my intervention" Emotional Jobs Addressed: - Feel in control despite automation - Reduce daily anxiety - Feel competent with technology - Trust system as safety net Social Jobs Addressed: - Demonstrate professional management - Avoid being bottleneck - Show sustainability ## Technical Stack Backend: Python, FastAPI, SQLAlchemy, PostgreSQL Frontend: React, TypeScript, TanStack Query, Tailwind CSS Architecture: Microservices with circuit breakers ## Breaking Changes - Complete dashboard page rewrite (old version backed up) - New API endpoints require orchestrator service deployment - Database migrations needed for reasoning fields ## Migration Required Run migrations to add new model fields: - purchase_orders: reasoning, consequence, reasoning_data - production_batches: reasoning, reasoning_data ## Documentation See DASHBOARD_REDESIGN_SUMMARY.md for complete implementation details, JTBD analysis, success metrics, and deployment guide. BREAKING CHANGE: Dashboard page completely redesigned with new data structures
2025-11-07 17:10:17 +00:00
lastOrchestrationRun: Optional[str] = Field(None, description="ISO timestamp of last orchestration")
nextScheduledRun: str = Field(..., description="ISO timestamp of next scheduled run")
checklistItems: List[HealthChecklistItem] = Field(..., description="Tri-state status checklist")
feat: Complete JTBD-aligned bakery dashboard redesign Implements comprehensive dashboard redesign based on Jobs To Be Done methodology focused on answering: "What requires my attention right now?" ## Backend Implementation ### Dashboard Service (NEW) - Health status calculation (green/yellow/red traffic light) - Action queue prioritization (critical/important/normal) - Orchestration summary with narrative format - Production timeline transformation - Insights calculation and consequence prediction ### API Endpoints (NEW) - GET /dashboard/health-status - Overall bakery health indicator - GET /dashboard/orchestration-summary - What system did automatically - GET /dashboard/action-queue - Prioritized tasks requiring attention - GET /dashboard/production-timeline - Today's production schedule - GET /dashboard/insights - Key metrics (savings, inventory, waste, deliveries) ### Enhanced Models - PurchaseOrder: Added reasoning, consequence, reasoning_data fields - ProductionBatch: Added reasoning, reasoning_data fields - Enables transparency into automation decisions ## Frontend Implementation ### API Hooks (NEW) - useBakeryHealthStatus() - Real-time health monitoring - useOrchestrationSummary() - System transparency - useActionQueue() - Prioritized action management - useProductionTimeline() - Production tracking - useInsights() - Glanceable metrics ### Dashboard Components (NEW) - HealthStatusCard: Traffic light indicator with checklist - ActionQueueCard: Prioritized actions with reasoning/consequences - OrchestrationSummaryCard: Narrative of what system did - ProductionTimelineCard: Chronological production view - InsightsGrid: 2x2 grid of key metrics ### Main Dashboard Page (REPLACED) - Complete rewrite with mobile-first design - All sections integrated with error handling - Real-time refresh and quick action links - Old dashboard backed up as DashboardPage.legacy.tsx ## Key Features ### Automation-First - Shows what orchestrator did overnight - Builds trust through transparency - Explains reasoning for all automated decisions ### Action-Oriented - Prioritizes tasks over information display - Clear consequences for each action - Large touch-friendly buttons ### Progressive Disclosure - Shows 20% of info that matters 80% of time - Expandable details when needed - No overwhelming metrics ### Mobile-First - One-handed operation - Large touch targets (min 44px) - Responsive grid layouts ### Trust-Building - Narrative format ("I planned your day") - Reasoning inputs transparency - Clear status indicators ## User Segments Supported 1. Solo Bakery Owner (Primary) - Simple health indicator - Action checklist (max 3-5 items) - Mobile-optimized 2. Multi-Location Owner - Multi-tenant support (existing) - Comparison capabilities - Delegation ready 3. Enterprise/Central Bakery (Future) - Network topology support - Advanced analytics ready ## JTBD Analysis Delivered Main Job: "Help me quickly understand bakery status and know what needs my intervention" Emotional Jobs Addressed: - Feel in control despite automation - Reduce daily anxiety - Feel competent with technology - Trust system as safety net Social Jobs Addressed: - Demonstrate professional management - Avoid being bottleneck - Show sustainability ## Technical Stack Backend: Python, FastAPI, SQLAlchemy, PostgreSQL Frontend: React, TypeScript, TanStack Query, Tailwind CSS Architecture: Microservices with circuit breakers ## Breaking Changes - Complete dashboard page rewrite (old version backed up) - New API endpoints require orchestrator service deployment - Database migrations needed for reasoning fields ## Migration Required Run migrations to add new model fields: - purchase_orders: reasoning, consequence, reasoning_data - production_batches: reasoning, reasoning_data ## Documentation See DASHBOARD_REDESIGN_SUMMARY.md for complete implementation details, JTBD analysis, success metrics, and deployment guide. BREAKING CHANGE: Dashboard page completely redesigned with new data structures
2025-11-07 17:10:17 +00:00
criticalIssues: int = Field(..., description="Count of critical issues")
pendingActions: int = Field(..., description="Count of pending actions")
aiPreventedIssues: int = Field(0, description="Count of issues AI prevented")
feat: Complete JTBD-aligned bakery dashboard redesign Implements comprehensive dashboard redesign based on Jobs To Be Done methodology focused on answering: "What requires my attention right now?" ## Backend Implementation ### Dashboard Service (NEW) - Health status calculation (green/yellow/red traffic light) - Action queue prioritization (critical/important/normal) - Orchestration summary with narrative format - Production timeline transformation - Insights calculation and consequence prediction ### API Endpoints (NEW) - GET /dashboard/health-status - Overall bakery health indicator - GET /dashboard/orchestration-summary - What system did automatically - GET /dashboard/action-queue - Prioritized tasks requiring attention - GET /dashboard/production-timeline - Today's production schedule - GET /dashboard/insights - Key metrics (savings, inventory, waste, deliveries) ### Enhanced Models - PurchaseOrder: Added reasoning, consequence, reasoning_data fields - ProductionBatch: Added reasoning, reasoning_data fields - Enables transparency into automation decisions ## Frontend Implementation ### API Hooks (NEW) - useBakeryHealthStatus() - Real-time health monitoring - useOrchestrationSummary() - System transparency - useActionQueue() - Prioritized action management - useProductionTimeline() - Production tracking - useInsights() - Glanceable metrics ### Dashboard Components (NEW) - HealthStatusCard: Traffic light indicator with checklist - ActionQueueCard: Prioritized actions with reasoning/consequences - OrchestrationSummaryCard: Narrative of what system did - ProductionTimelineCard: Chronological production view - InsightsGrid: 2x2 grid of key metrics ### Main Dashboard Page (REPLACED) - Complete rewrite with mobile-first design - All sections integrated with error handling - Real-time refresh and quick action links - Old dashboard backed up as DashboardPage.legacy.tsx ## Key Features ### Automation-First - Shows what orchestrator did overnight - Builds trust through transparency - Explains reasoning for all automated decisions ### Action-Oriented - Prioritizes tasks over information display - Clear consequences for each action - Large touch-friendly buttons ### Progressive Disclosure - Shows 20% of info that matters 80% of time - Expandable details when needed - No overwhelming metrics ### Mobile-First - One-handed operation - Large touch targets (min 44px) - Responsive grid layouts ### Trust-Building - Narrative format ("I planned your day") - Reasoning inputs transparency - Clear status indicators ## User Segments Supported 1. Solo Bakery Owner (Primary) - Simple health indicator - Action checklist (max 3-5 items) - Mobile-optimized 2. Multi-Location Owner - Multi-tenant support (existing) - Comparison capabilities - Delegation ready 3. Enterprise/Central Bakery (Future) - Network topology support - Advanced analytics ready ## JTBD Analysis Delivered Main Job: "Help me quickly understand bakery status and know what needs my intervention" Emotional Jobs Addressed: - Feel in control despite automation - Reduce daily anxiety - Feel competent with technology - Trust system as safety net Social Jobs Addressed: - Demonstrate professional management - Avoid being bottleneck - Show sustainability ## Technical Stack Backend: Python, FastAPI, SQLAlchemy, PostgreSQL Frontend: React, TypeScript, TanStack Query, Tailwind CSS Architecture: Microservices with circuit breakers ## Breaking Changes - Complete dashboard page rewrite (old version backed up) - New API endpoints require orchestrator service deployment - Database migrations needed for reasoning fields ## Migration Required Run migrations to add new model fields: - purchase_orders: reasoning, consequence, reasoning_data - production_batches: reasoning, reasoning_data ## Documentation See DASHBOARD_REDESIGN_SUMMARY.md for complete implementation details, JTBD analysis, success metrics, and deployment guide. BREAKING CHANGE: Dashboard page completely redesigned with new data structures
2025-11-07 17:10:17 +00:00
class ReasoningInputs(BaseModel):
"""Inputs used by orchestrator for decision making"""
customerOrders: int = Field(..., description="Number of customer orders analyzed")
historicalDemand: bool = Field(..., description="Whether historical data was used")
inventoryLevels: bool = Field(..., description="Whether inventory levels were considered")
aiInsights: bool = Field(..., description="Whether AI insights were used")
class PurchaseOrderSummary(BaseModel):
"""Summary of a purchase order for dashboard"""
supplierName: str
itemCategories: List[str]
totalAmount: float
class ProductionBatchSummary(BaseModel):
"""Summary of a production batch for dashboard"""
productName: str
quantity: float
readyByTime: str
class OrchestrationSummaryResponse(BaseModel):
"""What the orchestrator did for the user"""
runTimestamp: Optional[str] = Field(None, description="When the orchestration ran")
2025-11-13 16:01:08 +01:00
runNumber: Optional[str] = Field(None, description="Run number identifier")
feat: Complete JTBD-aligned bakery dashboard redesign Implements comprehensive dashboard redesign based on Jobs To Be Done methodology focused on answering: "What requires my attention right now?" ## Backend Implementation ### Dashboard Service (NEW) - Health status calculation (green/yellow/red traffic light) - Action queue prioritization (critical/important/normal) - Orchestration summary with narrative format - Production timeline transformation - Insights calculation and consequence prediction ### API Endpoints (NEW) - GET /dashboard/health-status - Overall bakery health indicator - GET /dashboard/orchestration-summary - What system did automatically - GET /dashboard/action-queue - Prioritized tasks requiring attention - GET /dashboard/production-timeline - Today's production schedule - GET /dashboard/insights - Key metrics (savings, inventory, waste, deliveries) ### Enhanced Models - PurchaseOrder: Added reasoning, consequence, reasoning_data fields - ProductionBatch: Added reasoning, reasoning_data fields - Enables transparency into automation decisions ## Frontend Implementation ### API Hooks (NEW) - useBakeryHealthStatus() - Real-time health monitoring - useOrchestrationSummary() - System transparency - useActionQueue() - Prioritized action management - useProductionTimeline() - Production tracking - useInsights() - Glanceable metrics ### Dashboard Components (NEW) - HealthStatusCard: Traffic light indicator with checklist - ActionQueueCard: Prioritized actions with reasoning/consequences - OrchestrationSummaryCard: Narrative of what system did - ProductionTimelineCard: Chronological production view - InsightsGrid: 2x2 grid of key metrics ### Main Dashboard Page (REPLACED) - Complete rewrite with mobile-first design - All sections integrated with error handling - Real-time refresh and quick action links - Old dashboard backed up as DashboardPage.legacy.tsx ## Key Features ### Automation-First - Shows what orchestrator did overnight - Builds trust through transparency - Explains reasoning for all automated decisions ### Action-Oriented - Prioritizes tasks over information display - Clear consequences for each action - Large touch-friendly buttons ### Progressive Disclosure - Shows 20% of info that matters 80% of time - Expandable details when needed - No overwhelming metrics ### Mobile-First - One-handed operation - Large touch targets (min 44px) - Responsive grid layouts ### Trust-Building - Narrative format ("I planned your day") - Reasoning inputs transparency - Clear status indicators ## User Segments Supported 1. Solo Bakery Owner (Primary) - Simple health indicator - Action checklist (max 3-5 items) - Mobile-optimized 2. Multi-Location Owner - Multi-tenant support (existing) - Comparison capabilities - Delegation ready 3. Enterprise/Central Bakery (Future) - Network topology support - Advanced analytics ready ## JTBD Analysis Delivered Main Job: "Help me quickly understand bakery status and know what needs my intervention" Emotional Jobs Addressed: - Feel in control despite automation - Reduce daily anxiety - Feel competent with technology - Trust system as safety net Social Jobs Addressed: - Demonstrate professional management - Avoid being bottleneck - Show sustainability ## Technical Stack Backend: Python, FastAPI, SQLAlchemy, PostgreSQL Frontend: React, TypeScript, TanStack Query, Tailwind CSS Architecture: Microservices with circuit breakers ## Breaking Changes - Complete dashboard page rewrite (old version backed up) - New API endpoints require orchestrator service deployment - Database migrations needed for reasoning fields ## Migration Required Run migrations to add new model fields: - purchase_orders: reasoning, consequence, reasoning_data - production_batches: reasoning, reasoning_data ## Documentation See DASHBOARD_REDESIGN_SUMMARY.md for complete implementation details, JTBD analysis, success metrics, and deployment guide. BREAKING CHANGE: Dashboard page completely redesigned with new data structures
2025-11-07 17:10:17 +00:00
status: str = Field(..., description="Run status")
purchaseOrdersCreated: int = Field(..., description="Number of POs created")
purchaseOrdersSummary: List[PurchaseOrderSummary] = Field(default_factory=list)
productionBatchesCreated: int = Field(..., description="Number of batches created")
productionBatchesSummary: List[ProductionBatchSummary] = Field(default_factory=list)
reasoningInputs: ReasoningInputs
userActionsRequired: int = Field(..., description="Number of actions needing approval")
durationSeconds: Optional[int] = Field(None, description="How long orchestration took")
aiAssisted: bool = Field(False, description="Whether AI insights were used")
2025-11-20 19:14:49 +01:00
message_i18n: Optional[I18nData] = Field(None, description="i18n data for message")
feat: Complete JTBD-aligned bakery dashboard redesign Implements comprehensive dashboard redesign based on Jobs To Be Done methodology focused on answering: "What requires my attention right now?" ## Backend Implementation ### Dashboard Service (NEW) - Health status calculation (green/yellow/red traffic light) - Action queue prioritization (critical/important/normal) - Orchestration summary with narrative format - Production timeline transformation - Insights calculation and consequence prediction ### API Endpoints (NEW) - GET /dashboard/health-status - Overall bakery health indicator - GET /dashboard/orchestration-summary - What system did automatically - GET /dashboard/action-queue - Prioritized tasks requiring attention - GET /dashboard/production-timeline - Today's production schedule - GET /dashboard/insights - Key metrics (savings, inventory, waste, deliveries) ### Enhanced Models - PurchaseOrder: Added reasoning, consequence, reasoning_data fields - ProductionBatch: Added reasoning, reasoning_data fields - Enables transparency into automation decisions ## Frontend Implementation ### API Hooks (NEW) - useBakeryHealthStatus() - Real-time health monitoring - useOrchestrationSummary() - System transparency - useActionQueue() - Prioritized action management - useProductionTimeline() - Production tracking - useInsights() - Glanceable metrics ### Dashboard Components (NEW) - HealthStatusCard: Traffic light indicator with checklist - ActionQueueCard: Prioritized actions with reasoning/consequences - OrchestrationSummaryCard: Narrative of what system did - ProductionTimelineCard: Chronological production view - InsightsGrid: 2x2 grid of key metrics ### Main Dashboard Page (REPLACED) - Complete rewrite with mobile-first design - All sections integrated with error handling - Real-time refresh and quick action links - Old dashboard backed up as DashboardPage.legacy.tsx ## Key Features ### Automation-First - Shows what orchestrator did overnight - Builds trust through transparency - Explains reasoning for all automated decisions ### Action-Oriented - Prioritizes tasks over information display - Clear consequences for each action - Large touch-friendly buttons ### Progressive Disclosure - Shows 20% of info that matters 80% of time - Expandable details when needed - No overwhelming metrics ### Mobile-First - One-handed operation - Large touch targets (min 44px) - Responsive grid layouts ### Trust-Building - Narrative format ("I planned your day") - Reasoning inputs transparency - Clear status indicators ## User Segments Supported 1. Solo Bakery Owner (Primary) - Simple health indicator - Action checklist (max 3-5 items) - Mobile-optimized 2. Multi-Location Owner - Multi-tenant support (existing) - Comparison capabilities - Delegation ready 3. Enterprise/Central Bakery (Future) - Network topology support - Advanced analytics ready ## JTBD Analysis Delivered Main Job: "Help me quickly understand bakery status and know what needs my intervention" Emotional Jobs Addressed: - Feel in control despite automation - Reduce daily anxiety - Feel competent with technology - Trust system as safety net Social Jobs Addressed: - Demonstrate professional management - Avoid being bottleneck - Show sustainability ## Technical Stack Backend: Python, FastAPI, SQLAlchemy, PostgreSQL Frontend: React, TypeScript, TanStack Query, Tailwind CSS Architecture: Microservices with circuit breakers ## Breaking Changes - Complete dashboard page rewrite (old version backed up) - New API endpoints require orchestrator service deployment - Database migrations needed for reasoning fields ## Migration Required Run migrations to add new model fields: - purchase_orders: reasoning, consequence, reasoning_data - production_batches: reasoning, reasoning_data ## Documentation See DASHBOARD_REDESIGN_SUMMARY.md for complete implementation details, JTBD analysis, success metrics, and deployment guide. BREAKING CHANGE: Dashboard page completely redesigned with new data structures
2025-11-07 17:10:17 +00:00
class ActionButton(BaseModel):
"""Action button configuration"""
2025-11-20 19:14:49 +01:00
label_i18n: I18nData = Field(..., description="i18n data for button label")
feat: Complete JTBD-aligned bakery dashboard redesign Implements comprehensive dashboard redesign based on Jobs To Be Done methodology focused on answering: "What requires my attention right now?" ## Backend Implementation ### Dashboard Service (NEW) - Health status calculation (green/yellow/red traffic light) - Action queue prioritization (critical/important/normal) - Orchestration summary with narrative format - Production timeline transformation - Insights calculation and consequence prediction ### API Endpoints (NEW) - GET /dashboard/health-status - Overall bakery health indicator - GET /dashboard/orchestration-summary - What system did automatically - GET /dashboard/action-queue - Prioritized tasks requiring attention - GET /dashboard/production-timeline - Today's production schedule - GET /dashboard/insights - Key metrics (savings, inventory, waste, deliveries) ### Enhanced Models - PurchaseOrder: Added reasoning, consequence, reasoning_data fields - ProductionBatch: Added reasoning, reasoning_data fields - Enables transparency into automation decisions ## Frontend Implementation ### API Hooks (NEW) - useBakeryHealthStatus() - Real-time health monitoring - useOrchestrationSummary() - System transparency - useActionQueue() - Prioritized action management - useProductionTimeline() - Production tracking - useInsights() - Glanceable metrics ### Dashboard Components (NEW) - HealthStatusCard: Traffic light indicator with checklist - ActionQueueCard: Prioritized actions with reasoning/consequences - OrchestrationSummaryCard: Narrative of what system did - ProductionTimelineCard: Chronological production view - InsightsGrid: 2x2 grid of key metrics ### Main Dashboard Page (REPLACED) - Complete rewrite with mobile-first design - All sections integrated with error handling - Real-time refresh and quick action links - Old dashboard backed up as DashboardPage.legacy.tsx ## Key Features ### Automation-First - Shows what orchestrator did overnight - Builds trust through transparency - Explains reasoning for all automated decisions ### Action-Oriented - Prioritizes tasks over information display - Clear consequences for each action - Large touch-friendly buttons ### Progressive Disclosure - Shows 20% of info that matters 80% of time - Expandable details when needed - No overwhelming metrics ### Mobile-First - One-handed operation - Large touch targets (min 44px) - Responsive grid layouts ### Trust-Building - Narrative format ("I planned your day") - Reasoning inputs transparency - Clear status indicators ## User Segments Supported 1. Solo Bakery Owner (Primary) - Simple health indicator - Action checklist (max 3-5 items) - Mobile-optimized 2. Multi-Location Owner - Multi-tenant support (existing) - Comparison capabilities - Delegation ready 3. Enterprise/Central Bakery (Future) - Network topology support - Advanced analytics ready ## JTBD Analysis Delivered Main Job: "Help me quickly understand bakery status and know what needs my intervention" Emotional Jobs Addressed: - Feel in control despite automation - Reduce daily anxiety - Feel competent with technology - Trust system as safety net Social Jobs Addressed: - Demonstrate professional management - Avoid being bottleneck - Show sustainability ## Technical Stack Backend: Python, FastAPI, SQLAlchemy, PostgreSQL Frontend: React, TypeScript, TanStack Query, Tailwind CSS Architecture: Microservices with circuit breakers ## Breaking Changes - Complete dashboard page rewrite (old version backed up) - New API endpoints require orchestrator service deployment - Database migrations needed for reasoning fields ## Migration Required Run migrations to add new model fields: - purchase_orders: reasoning, consequence, reasoning_data - production_batches: reasoning, reasoning_data ## Documentation See DASHBOARD_REDESIGN_SUMMARY.md for complete implementation details, JTBD analysis, success metrics, and deployment guide. BREAKING CHANGE: Dashboard page completely redesigned with new data structures
2025-11-07 17:10:17 +00:00
type: str = Field(..., description="Button type: primary, secondary, tertiary")
action: str = Field(..., description="Action identifier")
class ActionItem(BaseModel):
"""Individual action requiring user attention"""
id: str
type: str = Field(..., description="Action type")
urgency: str = Field(..., description="Urgency: critical, important, normal")
2025-11-20 19:14:49 +01:00
title: Optional[str] = Field(None, description="Legacy field for alerts")
title_i18n: Optional[I18nData] = Field(None, description="i18n data for title")
subtitle: Optional[str] = Field(None, description="Legacy field for alerts")
subtitle_i18n: Optional[I18nData] = Field(None, description="i18n data for subtitle")
reasoning: Optional[str] = Field(None, description="Legacy field for alerts")
reasoning_i18n: Optional[I18nData] = Field(None, description="i18n data for reasoning")
consequence_i18n: I18nData = Field(..., description="i18n data for consequence")
reasoning_data: Optional[Dict[str, Any]] = Field(None, description="Structured reasoning data")
feat: Complete JTBD-aligned bakery dashboard redesign Implements comprehensive dashboard redesign based on Jobs To Be Done methodology focused on answering: "What requires my attention right now?" ## Backend Implementation ### Dashboard Service (NEW) - Health status calculation (green/yellow/red traffic light) - Action queue prioritization (critical/important/normal) - Orchestration summary with narrative format - Production timeline transformation - Insights calculation and consequence prediction ### API Endpoints (NEW) - GET /dashboard/health-status - Overall bakery health indicator - GET /dashboard/orchestration-summary - What system did automatically - GET /dashboard/action-queue - Prioritized tasks requiring attention - GET /dashboard/production-timeline - Today's production schedule - GET /dashboard/insights - Key metrics (savings, inventory, waste, deliveries) ### Enhanced Models - PurchaseOrder: Added reasoning, consequence, reasoning_data fields - ProductionBatch: Added reasoning, reasoning_data fields - Enables transparency into automation decisions ## Frontend Implementation ### API Hooks (NEW) - useBakeryHealthStatus() - Real-time health monitoring - useOrchestrationSummary() - System transparency - useActionQueue() - Prioritized action management - useProductionTimeline() - Production tracking - useInsights() - Glanceable metrics ### Dashboard Components (NEW) - HealthStatusCard: Traffic light indicator with checklist - ActionQueueCard: Prioritized actions with reasoning/consequences - OrchestrationSummaryCard: Narrative of what system did - ProductionTimelineCard: Chronological production view - InsightsGrid: 2x2 grid of key metrics ### Main Dashboard Page (REPLACED) - Complete rewrite with mobile-first design - All sections integrated with error handling - Real-time refresh and quick action links - Old dashboard backed up as DashboardPage.legacy.tsx ## Key Features ### Automation-First - Shows what orchestrator did overnight - Builds trust through transparency - Explains reasoning for all automated decisions ### Action-Oriented - Prioritizes tasks over information display - Clear consequences for each action - Large touch-friendly buttons ### Progressive Disclosure - Shows 20% of info that matters 80% of time - Expandable details when needed - No overwhelming metrics ### Mobile-First - One-handed operation - Large touch targets (min 44px) - Responsive grid layouts ### Trust-Building - Narrative format ("I planned your day") - Reasoning inputs transparency - Clear status indicators ## User Segments Supported 1. Solo Bakery Owner (Primary) - Simple health indicator - Action checklist (max 3-5 items) - Mobile-optimized 2. Multi-Location Owner - Multi-tenant support (existing) - Comparison capabilities - Delegation ready 3. Enterprise/Central Bakery (Future) - Network topology support - Advanced analytics ready ## JTBD Analysis Delivered Main Job: "Help me quickly understand bakery status and know what needs my intervention" Emotional Jobs Addressed: - Feel in control despite automation - Reduce daily anxiety - Feel competent with technology - Trust system as safety net Social Jobs Addressed: - Demonstrate professional management - Avoid being bottleneck - Show sustainability ## Technical Stack Backend: Python, FastAPI, SQLAlchemy, PostgreSQL Frontend: React, TypeScript, TanStack Query, Tailwind CSS Architecture: Microservices with circuit breakers ## Breaking Changes - Complete dashboard page rewrite (old version backed up) - New API endpoints require orchestrator service deployment - Database migrations needed for reasoning fields ## Migration Required Run migrations to add new model fields: - purchase_orders: reasoning, consequence, reasoning_data - production_batches: reasoning, reasoning_data ## Documentation See DASHBOARD_REDESIGN_SUMMARY.md for complete implementation details, JTBD analysis, success metrics, and deployment guide. BREAKING CHANGE: Dashboard page completely redesigned with new data structures
2025-11-07 17:10:17 +00:00
amount: Optional[float] = Field(None, description="Amount for financial actions")
currency: Optional[str] = Field(None, description="Currency code")
actions: List[ActionButton]
estimatedTimeMinutes: int
class ActionQueueResponse(BaseModel):
"""Prioritized queue of actions"""
actions: List[ActionItem]
totalActions: int
criticalCount: int
importantCount: int
class ProductionTimelineItem(BaseModel):
"""Individual production batch in timeline"""
id: str
batchNumber: str
productName: str
quantity: float
unit: str
plannedStartTime: Optional[str]
plannedEndTime: Optional[str]
actualStartTime: Optional[str]
status: str
statusIcon: str
statusText: str
progress: int = Field(..., ge=0, le=100, description="Progress percentage")
readyBy: Optional[str]
priority: str
2025-11-20 19:14:49 +01:00
reasoning_data: Optional[Dict[str, Any]] = Field(None, description="Structured reasoning data")
reasoning_i18n: Optional[I18nData] = Field(None, description="i18n data for reasoning")
status_i18n: Optional[I18nData] = Field(None, description="i18n data for status")
feat: Complete JTBD-aligned bakery dashboard redesign Implements comprehensive dashboard redesign based on Jobs To Be Done methodology focused on answering: "What requires my attention right now?" ## Backend Implementation ### Dashboard Service (NEW) - Health status calculation (green/yellow/red traffic light) - Action queue prioritization (critical/important/normal) - Orchestration summary with narrative format - Production timeline transformation - Insights calculation and consequence prediction ### API Endpoints (NEW) - GET /dashboard/health-status - Overall bakery health indicator - GET /dashboard/orchestration-summary - What system did automatically - GET /dashboard/action-queue - Prioritized tasks requiring attention - GET /dashboard/production-timeline - Today's production schedule - GET /dashboard/insights - Key metrics (savings, inventory, waste, deliveries) ### Enhanced Models - PurchaseOrder: Added reasoning, consequence, reasoning_data fields - ProductionBatch: Added reasoning, reasoning_data fields - Enables transparency into automation decisions ## Frontend Implementation ### API Hooks (NEW) - useBakeryHealthStatus() - Real-time health monitoring - useOrchestrationSummary() - System transparency - useActionQueue() - Prioritized action management - useProductionTimeline() - Production tracking - useInsights() - Glanceable metrics ### Dashboard Components (NEW) - HealthStatusCard: Traffic light indicator with checklist - ActionQueueCard: Prioritized actions with reasoning/consequences - OrchestrationSummaryCard: Narrative of what system did - ProductionTimelineCard: Chronological production view - InsightsGrid: 2x2 grid of key metrics ### Main Dashboard Page (REPLACED) - Complete rewrite with mobile-first design - All sections integrated with error handling - Real-time refresh and quick action links - Old dashboard backed up as DashboardPage.legacy.tsx ## Key Features ### Automation-First - Shows what orchestrator did overnight - Builds trust through transparency - Explains reasoning for all automated decisions ### Action-Oriented - Prioritizes tasks over information display - Clear consequences for each action - Large touch-friendly buttons ### Progressive Disclosure - Shows 20% of info that matters 80% of time - Expandable details when needed - No overwhelming metrics ### Mobile-First - One-handed operation - Large touch targets (min 44px) - Responsive grid layouts ### Trust-Building - Narrative format ("I planned your day") - Reasoning inputs transparency - Clear status indicators ## User Segments Supported 1. Solo Bakery Owner (Primary) - Simple health indicator - Action checklist (max 3-5 items) - Mobile-optimized 2. Multi-Location Owner - Multi-tenant support (existing) - Comparison capabilities - Delegation ready 3. Enterprise/Central Bakery (Future) - Network topology support - Advanced analytics ready ## JTBD Analysis Delivered Main Job: "Help me quickly understand bakery status and know what needs my intervention" Emotional Jobs Addressed: - Feel in control despite automation - Reduce daily anxiety - Feel competent with technology - Trust system as safety net Social Jobs Addressed: - Demonstrate professional management - Avoid being bottleneck - Show sustainability ## Technical Stack Backend: Python, FastAPI, SQLAlchemy, PostgreSQL Frontend: React, TypeScript, TanStack Query, Tailwind CSS Architecture: Microservices with circuit breakers ## Breaking Changes - Complete dashboard page rewrite (old version backed up) - New API endpoints require orchestrator service deployment - Database migrations needed for reasoning fields ## Migration Required Run migrations to add new model fields: - purchase_orders: reasoning, consequence, reasoning_data - production_batches: reasoning, reasoning_data ## Documentation See DASHBOARD_REDESIGN_SUMMARY.md for complete implementation details, JTBD analysis, success metrics, and deployment guide. BREAKING CHANGE: Dashboard page completely redesigned with new data structures
2025-11-07 17:10:17 +00:00
class ProductionTimelineResponse(BaseModel):
"""Today's production timeline"""
timeline: List[ProductionTimelineItem]
totalBatches: int
completedBatches: int
inProgressBatches: int
pendingBatches: int
2025-11-20 19:14:49 +01:00
class InsightCardI18n(BaseModel):
"""i18n data for insight card"""
label: I18nData = Field(..., description="i18n data for label")
value: I18nData = Field(..., description="i18n data for value")
detail: Optional[I18nData] = Field(None, description="i18n data for detail")
feat: Complete JTBD-aligned bakery dashboard redesign Implements comprehensive dashboard redesign based on Jobs To Be Done methodology focused on answering: "What requires my attention right now?" ## Backend Implementation ### Dashboard Service (NEW) - Health status calculation (green/yellow/red traffic light) - Action queue prioritization (critical/important/normal) - Orchestration summary with narrative format - Production timeline transformation - Insights calculation and consequence prediction ### API Endpoints (NEW) - GET /dashboard/health-status - Overall bakery health indicator - GET /dashboard/orchestration-summary - What system did automatically - GET /dashboard/action-queue - Prioritized tasks requiring attention - GET /dashboard/production-timeline - Today's production schedule - GET /dashboard/insights - Key metrics (savings, inventory, waste, deliveries) ### Enhanced Models - PurchaseOrder: Added reasoning, consequence, reasoning_data fields - ProductionBatch: Added reasoning, reasoning_data fields - Enables transparency into automation decisions ## Frontend Implementation ### API Hooks (NEW) - useBakeryHealthStatus() - Real-time health monitoring - useOrchestrationSummary() - System transparency - useActionQueue() - Prioritized action management - useProductionTimeline() - Production tracking - useInsights() - Glanceable metrics ### Dashboard Components (NEW) - HealthStatusCard: Traffic light indicator with checklist - ActionQueueCard: Prioritized actions with reasoning/consequences - OrchestrationSummaryCard: Narrative of what system did - ProductionTimelineCard: Chronological production view - InsightsGrid: 2x2 grid of key metrics ### Main Dashboard Page (REPLACED) - Complete rewrite with mobile-first design - All sections integrated with error handling - Real-time refresh and quick action links - Old dashboard backed up as DashboardPage.legacy.tsx ## Key Features ### Automation-First - Shows what orchestrator did overnight - Builds trust through transparency - Explains reasoning for all automated decisions ### Action-Oriented - Prioritizes tasks over information display - Clear consequences for each action - Large touch-friendly buttons ### Progressive Disclosure - Shows 20% of info that matters 80% of time - Expandable details when needed - No overwhelming metrics ### Mobile-First - One-handed operation - Large touch targets (min 44px) - Responsive grid layouts ### Trust-Building - Narrative format ("I planned your day") - Reasoning inputs transparency - Clear status indicators ## User Segments Supported 1. Solo Bakery Owner (Primary) - Simple health indicator - Action checklist (max 3-5 items) - Mobile-optimized 2. Multi-Location Owner - Multi-tenant support (existing) - Comparison capabilities - Delegation ready 3. Enterprise/Central Bakery (Future) - Network topology support - Advanced analytics ready ## JTBD Analysis Delivered Main Job: "Help me quickly understand bakery status and know what needs my intervention" Emotional Jobs Addressed: - Feel in control despite automation - Reduce daily anxiety - Feel competent with technology - Trust system as safety net Social Jobs Addressed: - Demonstrate professional management - Avoid being bottleneck - Show sustainability ## Technical Stack Backend: Python, FastAPI, SQLAlchemy, PostgreSQL Frontend: React, TypeScript, TanStack Query, Tailwind CSS Architecture: Microservices with circuit breakers ## Breaking Changes - Complete dashboard page rewrite (old version backed up) - New API endpoints require orchestrator service deployment - Database migrations needed for reasoning fields ## Migration Required Run migrations to add new model fields: - purchase_orders: reasoning, consequence, reasoning_data - production_batches: reasoning, reasoning_data ## Documentation See DASHBOARD_REDESIGN_SUMMARY.md for complete implementation details, JTBD analysis, success metrics, and deployment guide. BREAKING CHANGE: Dashboard page completely redesigned with new data structures
2025-11-07 17:10:17 +00:00
class InsightCard(BaseModel):
"""Individual insight card"""
color: str = Field(..., description="Color: green, amber, red")
2025-11-20 19:14:49 +01:00
i18n: InsightCardI18n = Field(..., description="i18n translation data")
feat: Complete JTBD-aligned bakery dashboard redesign Implements comprehensive dashboard redesign based on Jobs To Be Done methodology focused on answering: "What requires my attention right now?" ## Backend Implementation ### Dashboard Service (NEW) - Health status calculation (green/yellow/red traffic light) - Action queue prioritization (critical/important/normal) - Orchestration summary with narrative format - Production timeline transformation - Insights calculation and consequence prediction ### API Endpoints (NEW) - GET /dashboard/health-status - Overall bakery health indicator - GET /dashboard/orchestration-summary - What system did automatically - GET /dashboard/action-queue - Prioritized tasks requiring attention - GET /dashboard/production-timeline - Today's production schedule - GET /dashboard/insights - Key metrics (savings, inventory, waste, deliveries) ### Enhanced Models - PurchaseOrder: Added reasoning, consequence, reasoning_data fields - ProductionBatch: Added reasoning, reasoning_data fields - Enables transparency into automation decisions ## Frontend Implementation ### API Hooks (NEW) - useBakeryHealthStatus() - Real-time health monitoring - useOrchestrationSummary() - System transparency - useActionQueue() - Prioritized action management - useProductionTimeline() - Production tracking - useInsights() - Glanceable metrics ### Dashboard Components (NEW) - HealthStatusCard: Traffic light indicator with checklist - ActionQueueCard: Prioritized actions with reasoning/consequences - OrchestrationSummaryCard: Narrative of what system did - ProductionTimelineCard: Chronological production view - InsightsGrid: 2x2 grid of key metrics ### Main Dashboard Page (REPLACED) - Complete rewrite with mobile-first design - All sections integrated with error handling - Real-time refresh and quick action links - Old dashboard backed up as DashboardPage.legacy.tsx ## Key Features ### Automation-First - Shows what orchestrator did overnight - Builds trust through transparency - Explains reasoning for all automated decisions ### Action-Oriented - Prioritizes tasks over information display - Clear consequences for each action - Large touch-friendly buttons ### Progressive Disclosure - Shows 20% of info that matters 80% of time - Expandable details when needed - No overwhelming metrics ### Mobile-First - One-handed operation - Large touch targets (min 44px) - Responsive grid layouts ### Trust-Building - Narrative format ("I planned your day") - Reasoning inputs transparency - Clear status indicators ## User Segments Supported 1. Solo Bakery Owner (Primary) - Simple health indicator - Action checklist (max 3-5 items) - Mobile-optimized 2. Multi-Location Owner - Multi-tenant support (existing) - Comparison capabilities - Delegation ready 3. Enterprise/Central Bakery (Future) - Network topology support - Advanced analytics ready ## JTBD Analysis Delivered Main Job: "Help me quickly understand bakery status and know what needs my intervention" Emotional Jobs Addressed: - Feel in control despite automation - Reduce daily anxiety - Feel competent with technology - Trust system as safety net Social Jobs Addressed: - Demonstrate professional management - Avoid being bottleneck - Show sustainability ## Technical Stack Backend: Python, FastAPI, SQLAlchemy, PostgreSQL Frontend: React, TypeScript, TanStack Query, Tailwind CSS Architecture: Microservices with circuit breakers ## Breaking Changes - Complete dashboard page rewrite (old version backed up) - New API endpoints require orchestrator service deployment - Database migrations needed for reasoning fields ## Migration Required Run migrations to add new model fields: - purchase_orders: reasoning, consequence, reasoning_data - production_batches: reasoning, reasoning_data ## Documentation See DASHBOARD_REDESIGN_SUMMARY.md for complete implementation details, JTBD analysis, success metrics, and deployment guide. BREAKING CHANGE: Dashboard page completely redesigned with new data structures
2025-11-07 17:10:17 +00:00
class InsightsResponse(BaseModel):
"""Key insights grid"""
savings: InsightCard
inventory: InsightCard
waste: InsightCard
deliveries: InsightCard
# ============================================================
# API Endpoints
# ============================================================
@router.get("/health-status", response_model=BakeryHealthStatusResponse)
async def get_bakery_health_status(
tenant_id: str,
db: AsyncSession = Depends(get_db)
) -> BakeryHealthStatusResponse:
"""
Get overall bakery health status with tri-state checklist
feat: Complete JTBD-aligned bakery dashboard redesign Implements comprehensive dashboard redesign based on Jobs To Be Done methodology focused on answering: "What requires my attention right now?" ## Backend Implementation ### Dashboard Service (NEW) - Health status calculation (green/yellow/red traffic light) - Action queue prioritization (critical/important/normal) - Orchestration summary with narrative format - Production timeline transformation - Insights calculation and consequence prediction ### API Endpoints (NEW) - GET /dashboard/health-status - Overall bakery health indicator - GET /dashboard/orchestration-summary - What system did automatically - GET /dashboard/action-queue - Prioritized tasks requiring attention - GET /dashboard/production-timeline - Today's production schedule - GET /dashboard/insights - Key metrics (savings, inventory, waste, deliveries) ### Enhanced Models - PurchaseOrder: Added reasoning, consequence, reasoning_data fields - ProductionBatch: Added reasoning, reasoning_data fields - Enables transparency into automation decisions ## Frontend Implementation ### API Hooks (NEW) - useBakeryHealthStatus() - Real-time health monitoring - useOrchestrationSummary() - System transparency - useActionQueue() - Prioritized action management - useProductionTimeline() - Production tracking - useInsights() - Glanceable metrics ### Dashboard Components (NEW) - HealthStatusCard: Traffic light indicator with checklist - ActionQueueCard: Prioritized actions with reasoning/consequences - OrchestrationSummaryCard: Narrative of what system did - ProductionTimelineCard: Chronological production view - InsightsGrid: 2x2 grid of key metrics ### Main Dashboard Page (REPLACED) - Complete rewrite with mobile-first design - All sections integrated with error handling - Real-time refresh and quick action links - Old dashboard backed up as DashboardPage.legacy.tsx ## Key Features ### Automation-First - Shows what orchestrator did overnight - Builds trust through transparency - Explains reasoning for all automated decisions ### Action-Oriented - Prioritizes tasks over information display - Clear consequences for each action - Large touch-friendly buttons ### Progressive Disclosure - Shows 20% of info that matters 80% of time - Expandable details when needed - No overwhelming metrics ### Mobile-First - One-handed operation - Large touch targets (min 44px) - Responsive grid layouts ### Trust-Building - Narrative format ("I planned your day") - Reasoning inputs transparency - Clear status indicators ## User Segments Supported 1. Solo Bakery Owner (Primary) - Simple health indicator - Action checklist (max 3-5 items) - Mobile-optimized 2. Multi-Location Owner - Multi-tenant support (existing) - Comparison capabilities - Delegation ready 3. Enterprise/Central Bakery (Future) - Network topology support - Advanced analytics ready ## JTBD Analysis Delivered Main Job: "Help me quickly understand bakery status and know what needs my intervention" Emotional Jobs Addressed: - Feel in control despite automation - Reduce daily anxiety - Feel competent with technology - Trust system as safety net Social Jobs Addressed: - Demonstrate professional management - Avoid being bottleneck - Show sustainability ## Technical Stack Backend: Python, FastAPI, SQLAlchemy, PostgreSQL Frontend: React, TypeScript, TanStack Query, Tailwind CSS Architecture: Microservices with circuit breakers ## Breaking Changes - Complete dashboard page rewrite (old version backed up) - New API endpoints require orchestrator service deployment - Database migrations needed for reasoning fields ## Migration Required Run migrations to add new model fields: - purchase_orders: reasoning, consequence, reasoning_data - production_batches: reasoning, reasoning_data ## Documentation See DASHBOARD_REDESIGN_SUMMARY.md for complete implementation details, JTBD analysis, success metrics, and deployment guide. BREAKING CHANGE: Dashboard page completely redesigned with new data structures
2025-11-07 17:10:17 +00:00
This is the top-level indicator showing if the bakery is running smoothly
or if there are issues requiring attention. Includes AI-prevented issues.
feat: Complete JTBD-aligned bakery dashboard redesign Implements comprehensive dashboard redesign based on Jobs To Be Done methodology focused on answering: "What requires my attention right now?" ## Backend Implementation ### Dashboard Service (NEW) - Health status calculation (green/yellow/red traffic light) - Action queue prioritization (critical/important/normal) - Orchestration summary with narrative format - Production timeline transformation - Insights calculation and consequence prediction ### API Endpoints (NEW) - GET /dashboard/health-status - Overall bakery health indicator - GET /dashboard/orchestration-summary - What system did automatically - GET /dashboard/action-queue - Prioritized tasks requiring attention - GET /dashboard/production-timeline - Today's production schedule - GET /dashboard/insights - Key metrics (savings, inventory, waste, deliveries) ### Enhanced Models - PurchaseOrder: Added reasoning, consequence, reasoning_data fields - ProductionBatch: Added reasoning, reasoning_data fields - Enables transparency into automation decisions ## Frontend Implementation ### API Hooks (NEW) - useBakeryHealthStatus() - Real-time health monitoring - useOrchestrationSummary() - System transparency - useActionQueue() - Prioritized action management - useProductionTimeline() - Production tracking - useInsights() - Glanceable metrics ### Dashboard Components (NEW) - HealthStatusCard: Traffic light indicator with checklist - ActionQueueCard: Prioritized actions with reasoning/consequences - OrchestrationSummaryCard: Narrative of what system did - ProductionTimelineCard: Chronological production view - InsightsGrid: 2x2 grid of key metrics ### Main Dashboard Page (REPLACED) - Complete rewrite with mobile-first design - All sections integrated with error handling - Real-time refresh and quick action links - Old dashboard backed up as DashboardPage.legacy.tsx ## Key Features ### Automation-First - Shows what orchestrator did overnight - Builds trust through transparency - Explains reasoning for all automated decisions ### Action-Oriented - Prioritizes tasks over information display - Clear consequences for each action - Large touch-friendly buttons ### Progressive Disclosure - Shows 20% of info that matters 80% of time - Expandable details when needed - No overwhelming metrics ### Mobile-First - One-handed operation - Large touch targets (min 44px) - Responsive grid layouts ### Trust-Building - Narrative format ("I planned your day") - Reasoning inputs transparency - Clear status indicators ## User Segments Supported 1. Solo Bakery Owner (Primary) - Simple health indicator - Action checklist (max 3-5 items) - Mobile-optimized 2. Multi-Location Owner - Multi-tenant support (existing) - Comparison capabilities - Delegation ready 3. Enterprise/Central Bakery (Future) - Network topology support - Advanced analytics ready ## JTBD Analysis Delivered Main Job: "Help me quickly understand bakery status and know what needs my intervention" Emotional Jobs Addressed: - Feel in control despite automation - Reduce daily anxiety - Feel competent with technology - Trust system as safety net Social Jobs Addressed: - Demonstrate professional management - Avoid being bottleneck - Show sustainability ## Technical Stack Backend: Python, FastAPI, SQLAlchemy, PostgreSQL Frontend: React, TypeScript, TanStack Query, Tailwind CSS Architecture: Microservices with circuit breakers ## Breaking Changes - Complete dashboard page rewrite (old version backed up) - New API endpoints require orchestrator service deployment - Database migrations needed for reasoning fields ## Migration Required Run migrations to add new model fields: - purchase_orders: reasoning, consequence, reasoning_data - production_batches: reasoning, reasoning_data ## Documentation See DASHBOARD_REDESIGN_SUMMARY.md for complete implementation details, JTBD analysis, success metrics, and deployment guide. BREAKING CHANGE: Dashboard page completely redesigned with new data structures
2025-11-07 17:10:17 +00:00
"""
try:
2025-11-15 21:21:06 +01:00
# Try to get from cache
if settings.CACHE_ENABLED:
cache_key = f"dashboard:health:{tenant_id}"
cached = await get_cached(cache_key)
if cached:
return BakeryHealthStatusResponse(**cached)
feat: Complete JTBD-aligned bakery dashboard redesign Implements comprehensive dashboard redesign based on Jobs To Be Done methodology focused on answering: "What requires my attention right now?" ## Backend Implementation ### Dashboard Service (NEW) - Health status calculation (green/yellow/red traffic light) - Action queue prioritization (critical/important/normal) - Orchestration summary with narrative format - Production timeline transformation - Insights calculation and consequence prediction ### API Endpoints (NEW) - GET /dashboard/health-status - Overall bakery health indicator - GET /dashboard/orchestration-summary - What system did automatically - GET /dashboard/action-queue - Prioritized tasks requiring attention - GET /dashboard/production-timeline - Today's production schedule - GET /dashboard/insights - Key metrics (savings, inventory, waste, deliveries) ### Enhanced Models - PurchaseOrder: Added reasoning, consequence, reasoning_data fields - ProductionBatch: Added reasoning, reasoning_data fields - Enables transparency into automation decisions ## Frontend Implementation ### API Hooks (NEW) - useBakeryHealthStatus() - Real-time health monitoring - useOrchestrationSummary() - System transparency - useActionQueue() - Prioritized action management - useProductionTimeline() - Production tracking - useInsights() - Glanceable metrics ### Dashboard Components (NEW) - HealthStatusCard: Traffic light indicator with checklist - ActionQueueCard: Prioritized actions with reasoning/consequences - OrchestrationSummaryCard: Narrative of what system did - ProductionTimelineCard: Chronological production view - InsightsGrid: 2x2 grid of key metrics ### Main Dashboard Page (REPLACED) - Complete rewrite with mobile-first design - All sections integrated with error handling - Real-time refresh and quick action links - Old dashboard backed up as DashboardPage.legacy.tsx ## Key Features ### Automation-First - Shows what orchestrator did overnight - Builds trust through transparency - Explains reasoning for all automated decisions ### Action-Oriented - Prioritizes tasks over information display - Clear consequences for each action - Large touch-friendly buttons ### Progressive Disclosure - Shows 20% of info that matters 80% of time - Expandable details when needed - No overwhelming metrics ### Mobile-First - One-handed operation - Large touch targets (min 44px) - Responsive grid layouts ### Trust-Building - Narrative format ("I planned your day") - Reasoning inputs transparency - Clear status indicators ## User Segments Supported 1. Solo Bakery Owner (Primary) - Simple health indicator - Action checklist (max 3-5 items) - Mobile-optimized 2. Multi-Location Owner - Multi-tenant support (existing) - Comparison capabilities - Delegation ready 3. Enterprise/Central Bakery (Future) - Network topology support - Advanced analytics ready ## JTBD Analysis Delivered Main Job: "Help me quickly understand bakery status and know what needs my intervention" Emotional Jobs Addressed: - Feel in control despite automation - Reduce daily anxiety - Feel competent with technology - Trust system as safety net Social Jobs Addressed: - Demonstrate professional management - Avoid being bottleneck - Show sustainability ## Technical Stack Backend: Python, FastAPI, SQLAlchemy, PostgreSQL Frontend: React, TypeScript, TanStack Query, Tailwind CSS Architecture: Microservices with circuit breakers ## Breaking Changes - Complete dashboard page rewrite (old version backed up) - New API endpoints require orchestrator service deployment - Database migrations needed for reasoning fields ## Migration Required Run migrations to add new model fields: - purchase_orders: reasoning, consequence, reasoning_data - production_batches: reasoning, reasoning_data ## Documentation See DASHBOARD_REDESIGN_SUMMARY.md for complete implementation details, JTBD analysis, success metrics, and deployment guide. BREAKING CHANGE: Dashboard page completely redesigned with new data structures
2025-11-07 17:10:17 +00:00
dashboard_service = DashboardService(db)
2025-11-15 21:21:06 +01:00
# Gather metrics from various services in parallel
# Use asyncio.gather to make all HTTP calls concurrently
feat: Complete JTBD-aligned bakery dashboard redesign Implements comprehensive dashboard redesign based on Jobs To Be Done methodology focused on answering: "What requires my attention right now?" ## Backend Implementation ### Dashboard Service (NEW) - Health status calculation (green/yellow/red traffic light) - Action queue prioritization (critical/important/normal) - Orchestration summary with narrative format - Production timeline transformation - Insights calculation and consequence prediction ### API Endpoints (NEW) - GET /dashboard/health-status - Overall bakery health indicator - GET /dashboard/orchestration-summary - What system did automatically - GET /dashboard/action-queue - Prioritized tasks requiring attention - GET /dashboard/production-timeline - Today's production schedule - GET /dashboard/insights - Key metrics (savings, inventory, waste, deliveries) ### Enhanced Models - PurchaseOrder: Added reasoning, consequence, reasoning_data fields - ProductionBatch: Added reasoning, reasoning_data fields - Enables transparency into automation decisions ## Frontend Implementation ### API Hooks (NEW) - useBakeryHealthStatus() - Real-time health monitoring - useOrchestrationSummary() - System transparency - useActionQueue() - Prioritized action management - useProductionTimeline() - Production tracking - useInsights() - Glanceable metrics ### Dashboard Components (NEW) - HealthStatusCard: Traffic light indicator with checklist - ActionQueueCard: Prioritized actions with reasoning/consequences - OrchestrationSummaryCard: Narrative of what system did - ProductionTimelineCard: Chronological production view - InsightsGrid: 2x2 grid of key metrics ### Main Dashboard Page (REPLACED) - Complete rewrite with mobile-first design - All sections integrated with error handling - Real-time refresh and quick action links - Old dashboard backed up as DashboardPage.legacy.tsx ## Key Features ### Automation-First - Shows what orchestrator did overnight - Builds trust through transparency - Explains reasoning for all automated decisions ### Action-Oriented - Prioritizes tasks over information display - Clear consequences for each action - Large touch-friendly buttons ### Progressive Disclosure - Shows 20% of info that matters 80% of time - Expandable details when needed - No overwhelming metrics ### Mobile-First - One-handed operation - Large touch targets (min 44px) - Responsive grid layouts ### Trust-Building - Narrative format ("I planned your day") - Reasoning inputs transparency - Clear status indicators ## User Segments Supported 1. Solo Bakery Owner (Primary) - Simple health indicator - Action checklist (max 3-5 items) - Mobile-optimized 2. Multi-Location Owner - Multi-tenant support (existing) - Comparison capabilities - Delegation ready 3. Enterprise/Central Bakery (Future) - Network topology support - Advanced analytics ready ## JTBD Analysis Delivered Main Job: "Help me quickly understand bakery status and know what needs my intervention" Emotional Jobs Addressed: - Feel in control despite automation - Reduce daily anxiety - Feel competent with technology - Trust system as safety net Social Jobs Addressed: - Demonstrate professional management - Avoid being bottleneck - Show sustainability ## Technical Stack Backend: Python, FastAPI, SQLAlchemy, PostgreSQL Frontend: React, TypeScript, TanStack Query, Tailwind CSS Architecture: Microservices with circuit breakers ## Breaking Changes - Complete dashboard page rewrite (old version backed up) - New API endpoints require orchestrator service deployment - Database migrations needed for reasoning fields ## Migration Required Run migrations to add new model fields: - purchase_orders: reasoning, consequence, reasoning_data - production_batches: reasoning, reasoning_data ## Documentation See DASHBOARD_REDESIGN_SUMMARY.md for complete implementation details, JTBD analysis, success metrics, and deployment guide. BREAKING CHANGE: Dashboard page completely redesigned with new data structures
2025-11-07 17:10:17 +00:00
2025-11-15 21:21:06 +01:00
async def fetch_alerts():
try:
alerts_data = await alerts_client.get_alerts(tenant_id, limit=100) or {}
alerts_list = alerts_data.get("alerts", [])
# Count critical alerts
critical_count = sum(1 for a in alerts_list if a.get('priority_level') == 'CRITICAL')
# Count AI prevented issues
prevented_count = sum(1 for a in alerts_list if a.get('type_class') == 'prevented_issue')
return critical_count, prevented_count, alerts_list
2025-11-15 21:21:06 +01:00
except Exception as e:
logger.warning(f"Failed to fetch alerts: {e}")
return 0, 0, []
2025-11-15 21:21:06 +01:00
async def fetch_pending_pos():
try:
po_data = await procurement_client.get_pending_purchase_orders(tenant_id, limit=100) or []
return len(po_data) if isinstance(po_data, list) else 0
except Exception as e:
logger.warning(f"Failed to fetch POs: {e}")
return 0
2025-11-15 21:21:06 +01:00
async def fetch_production_delays():
try:
prod_data = await production_client.get_production_batches_by_status(
tenant_id, status="ON_HOLD", limit=100
) or {}
return len(prod_data.get("batches", []))
except Exception as e:
logger.warning(f"Failed to fetch production batches: {e}")
return 0
2025-11-15 21:21:06 +01:00
async def fetch_inventory():
try:
inv_data = await inventory_client.get_inventory_dashboard(tenant_id) or {}
return inv_data.get("out_of_stock_count", 0)
except Exception as e:
logger.warning(f"Failed to fetch inventory: {e}")
return 0
# Execute all fetches in parallel
alerts_result, pending_approvals, production_delays, out_of_stock_count = await asyncio.gather(
2025-11-15 21:21:06 +01:00
fetch_alerts(),
fetch_pending_pos(),
fetch_production_delays(),
fetch_inventory()
)
feat: Complete JTBD-aligned bakery dashboard redesign Implements comprehensive dashboard redesign based on Jobs To Be Done methodology focused on answering: "What requires my attention right now?" ## Backend Implementation ### Dashboard Service (NEW) - Health status calculation (green/yellow/red traffic light) - Action queue prioritization (critical/important/normal) - Orchestration summary with narrative format - Production timeline transformation - Insights calculation and consequence prediction ### API Endpoints (NEW) - GET /dashboard/health-status - Overall bakery health indicator - GET /dashboard/orchestration-summary - What system did automatically - GET /dashboard/action-queue - Prioritized tasks requiring attention - GET /dashboard/production-timeline - Today's production schedule - GET /dashboard/insights - Key metrics (savings, inventory, waste, deliveries) ### Enhanced Models - PurchaseOrder: Added reasoning, consequence, reasoning_data fields - ProductionBatch: Added reasoning, reasoning_data fields - Enables transparency into automation decisions ## Frontend Implementation ### API Hooks (NEW) - useBakeryHealthStatus() - Real-time health monitoring - useOrchestrationSummary() - System transparency - useActionQueue() - Prioritized action management - useProductionTimeline() - Production tracking - useInsights() - Glanceable metrics ### Dashboard Components (NEW) - HealthStatusCard: Traffic light indicator with checklist - ActionQueueCard: Prioritized actions with reasoning/consequences - OrchestrationSummaryCard: Narrative of what system did - ProductionTimelineCard: Chronological production view - InsightsGrid: 2x2 grid of key metrics ### Main Dashboard Page (REPLACED) - Complete rewrite with mobile-first design - All sections integrated with error handling - Real-time refresh and quick action links - Old dashboard backed up as DashboardPage.legacy.tsx ## Key Features ### Automation-First - Shows what orchestrator did overnight - Builds trust through transparency - Explains reasoning for all automated decisions ### Action-Oriented - Prioritizes tasks over information display - Clear consequences for each action - Large touch-friendly buttons ### Progressive Disclosure - Shows 20% of info that matters 80% of time - Expandable details when needed - No overwhelming metrics ### Mobile-First - One-handed operation - Large touch targets (min 44px) - Responsive grid layouts ### Trust-Building - Narrative format ("I planned your day") - Reasoning inputs transparency - Clear status indicators ## User Segments Supported 1. Solo Bakery Owner (Primary) - Simple health indicator - Action checklist (max 3-5 items) - Mobile-optimized 2. Multi-Location Owner - Multi-tenant support (existing) - Comparison capabilities - Delegation ready 3. Enterprise/Central Bakery (Future) - Network topology support - Advanced analytics ready ## JTBD Analysis Delivered Main Job: "Help me quickly understand bakery status and know what needs my intervention" Emotional Jobs Addressed: - Feel in control despite automation - Reduce daily anxiety - Feel competent with technology - Trust system as safety net Social Jobs Addressed: - Demonstrate professional management - Avoid being bottleneck - Show sustainability ## Technical Stack Backend: Python, FastAPI, SQLAlchemy, PostgreSQL Frontend: React, TypeScript, TanStack Query, Tailwind CSS Architecture: Microservices with circuit breakers ## Breaking Changes - Complete dashboard page rewrite (old version backed up) - New API endpoints require orchestrator service deployment - Database migrations needed for reasoning fields ## Migration Required Run migrations to add new model fields: - purchase_orders: reasoning, consequence, reasoning_data - production_batches: reasoning, reasoning_data ## Documentation See DASHBOARD_REDESIGN_SUMMARY.md for complete implementation details, JTBD analysis, success metrics, and deployment guide. BREAKING CHANGE: Dashboard page completely redesigned with new data structures
2025-11-07 17:10:17 +00:00
critical_alerts, ai_prevented_count, all_alerts = alerts_result
feat: Complete JTBD-aligned bakery dashboard redesign Implements comprehensive dashboard redesign based on Jobs To Be Done methodology focused on answering: "What requires my attention right now?" ## Backend Implementation ### Dashboard Service (NEW) - Health status calculation (green/yellow/red traffic light) - Action queue prioritization (critical/important/normal) - Orchestration summary with narrative format - Production timeline transformation - Insights calculation and consequence prediction ### API Endpoints (NEW) - GET /dashboard/health-status - Overall bakery health indicator - GET /dashboard/orchestration-summary - What system did automatically - GET /dashboard/action-queue - Prioritized tasks requiring attention - GET /dashboard/production-timeline - Today's production schedule - GET /dashboard/insights - Key metrics (savings, inventory, waste, deliveries) ### Enhanced Models - PurchaseOrder: Added reasoning, consequence, reasoning_data fields - ProductionBatch: Added reasoning, reasoning_data fields - Enables transparency into automation decisions ## Frontend Implementation ### API Hooks (NEW) - useBakeryHealthStatus() - Real-time health monitoring - useOrchestrationSummary() - System transparency - useActionQueue() - Prioritized action management - useProductionTimeline() - Production tracking - useInsights() - Glanceable metrics ### Dashboard Components (NEW) - HealthStatusCard: Traffic light indicator with checklist - ActionQueueCard: Prioritized actions with reasoning/consequences - OrchestrationSummaryCard: Narrative of what system did - ProductionTimelineCard: Chronological production view - InsightsGrid: 2x2 grid of key metrics ### Main Dashboard Page (REPLACED) - Complete rewrite with mobile-first design - All sections integrated with error handling - Real-time refresh and quick action links - Old dashboard backed up as DashboardPage.legacy.tsx ## Key Features ### Automation-First - Shows what orchestrator did overnight - Builds trust through transparency - Explains reasoning for all automated decisions ### Action-Oriented - Prioritizes tasks over information display - Clear consequences for each action - Large touch-friendly buttons ### Progressive Disclosure - Shows 20% of info that matters 80% of time - Expandable details when needed - No overwhelming metrics ### Mobile-First - One-handed operation - Large touch targets (min 44px) - Responsive grid layouts ### Trust-Building - Narrative format ("I planned your day") - Reasoning inputs transparency - Clear status indicators ## User Segments Supported 1. Solo Bakery Owner (Primary) - Simple health indicator - Action checklist (max 3-5 items) - Mobile-optimized 2. Multi-Location Owner - Multi-tenant support (existing) - Comparison capabilities - Delegation ready 3. Enterprise/Central Bakery (Future) - Network topology support - Advanced analytics ready ## JTBD Analysis Delivered Main Job: "Help me quickly understand bakery status and know what needs my intervention" Emotional Jobs Addressed: - Feel in control despite automation - Reduce daily anxiety - Feel competent with technology - Trust system as safety net Social Jobs Addressed: - Demonstrate professional management - Avoid being bottleneck - Show sustainability ## Technical Stack Backend: Python, FastAPI, SQLAlchemy, PostgreSQL Frontend: React, TypeScript, TanStack Query, Tailwind CSS Architecture: Microservices with circuit breakers ## Breaking Changes - Complete dashboard page rewrite (old version backed up) - New API endpoints require orchestrator service deployment - Database migrations needed for reasoning fields ## Migration Required Run migrations to add new model fields: - purchase_orders: reasoning, consequence, reasoning_data - production_batches: reasoning, reasoning_data ## Documentation See DASHBOARD_REDESIGN_SUMMARY.md for complete implementation details, JTBD analysis, success metrics, and deployment guide. BREAKING CHANGE: Dashboard page completely redesigned with new data structures
2025-11-07 17:10:17 +00:00
# System errors (would come from monitoring system)
system_errors = 0
# Calculate health status with tri-state checklist
feat: Complete JTBD-aligned bakery dashboard redesign Implements comprehensive dashboard redesign based on Jobs To Be Done methodology focused on answering: "What requires my attention right now?" ## Backend Implementation ### Dashboard Service (NEW) - Health status calculation (green/yellow/red traffic light) - Action queue prioritization (critical/important/normal) - Orchestration summary with narrative format - Production timeline transformation - Insights calculation and consequence prediction ### API Endpoints (NEW) - GET /dashboard/health-status - Overall bakery health indicator - GET /dashboard/orchestration-summary - What system did automatically - GET /dashboard/action-queue - Prioritized tasks requiring attention - GET /dashboard/production-timeline - Today's production schedule - GET /dashboard/insights - Key metrics (savings, inventory, waste, deliveries) ### Enhanced Models - PurchaseOrder: Added reasoning, consequence, reasoning_data fields - ProductionBatch: Added reasoning, reasoning_data fields - Enables transparency into automation decisions ## Frontend Implementation ### API Hooks (NEW) - useBakeryHealthStatus() - Real-time health monitoring - useOrchestrationSummary() - System transparency - useActionQueue() - Prioritized action management - useProductionTimeline() - Production tracking - useInsights() - Glanceable metrics ### Dashboard Components (NEW) - HealthStatusCard: Traffic light indicator with checklist - ActionQueueCard: Prioritized actions with reasoning/consequences - OrchestrationSummaryCard: Narrative of what system did - ProductionTimelineCard: Chronological production view - InsightsGrid: 2x2 grid of key metrics ### Main Dashboard Page (REPLACED) - Complete rewrite with mobile-first design - All sections integrated with error handling - Real-time refresh and quick action links - Old dashboard backed up as DashboardPage.legacy.tsx ## Key Features ### Automation-First - Shows what orchestrator did overnight - Builds trust through transparency - Explains reasoning for all automated decisions ### Action-Oriented - Prioritizes tasks over information display - Clear consequences for each action - Large touch-friendly buttons ### Progressive Disclosure - Shows 20% of info that matters 80% of time - Expandable details when needed - No overwhelming metrics ### Mobile-First - One-handed operation - Large touch targets (min 44px) - Responsive grid layouts ### Trust-Building - Narrative format ("I planned your day") - Reasoning inputs transparency - Clear status indicators ## User Segments Supported 1. Solo Bakery Owner (Primary) - Simple health indicator - Action checklist (max 3-5 items) - Mobile-optimized 2. Multi-Location Owner - Multi-tenant support (existing) - Comparison capabilities - Delegation ready 3. Enterprise/Central Bakery (Future) - Network topology support - Advanced analytics ready ## JTBD Analysis Delivered Main Job: "Help me quickly understand bakery status and know what needs my intervention" Emotional Jobs Addressed: - Feel in control despite automation - Reduce daily anxiety - Feel competent with technology - Trust system as safety net Social Jobs Addressed: - Demonstrate professional management - Avoid being bottleneck - Show sustainability ## Technical Stack Backend: Python, FastAPI, SQLAlchemy, PostgreSQL Frontend: React, TypeScript, TanStack Query, Tailwind CSS Architecture: Microservices with circuit breakers ## Breaking Changes - Complete dashboard page rewrite (old version backed up) - New API endpoints require orchestrator service deployment - Database migrations needed for reasoning fields ## Migration Required Run migrations to add new model fields: - purchase_orders: reasoning, consequence, reasoning_data - production_batches: reasoning, reasoning_data ## Documentation See DASHBOARD_REDESIGN_SUMMARY.md for complete implementation details, JTBD analysis, success metrics, and deployment guide. BREAKING CHANGE: Dashboard page completely redesigned with new data structures
2025-11-07 17:10:17 +00:00
health_status = await dashboard_service.get_bakery_health_status(
tenant_id=tenant_id,
critical_alerts=critical_alerts,
pending_approvals=pending_approvals,
production_delays=production_delays,
out_of_stock_count=out_of_stock_count,
system_errors=system_errors,
ai_prevented_count=ai_prevented_count,
action_needed_alerts=all_alerts
feat: Complete JTBD-aligned bakery dashboard redesign Implements comprehensive dashboard redesign based on Jobs To Be Done methodology focused on answering: "What requires my attention right now?" ## Backend Implementation ### Dashboard Service (NEW) - Health status calculation (green/yellow/red traffic light) - Action queue prioritization (critical/important/normal) - Orchestration summary with narrative format - Production timeline transformation - Insights calculation and consequence prediction ### API Endpoints (NEW) - GET /dashboard/health-status - Overall bakery health indicator - GET /dashboard/orchestration-summary - What system did automatically - GET /dashboard/action-queue - Prioritized tasks requiring attention - GET /dashboard/production-timeline - Today's production schedule - GET /dashboard/insights - Key metrics (savings, inventory, waste, deliveries) ### Enhanced Models - PurchaseOrder: Added reasoning, consequence, reasoning_data fields - ProductionBatch: Added reasoning, reasoning_data fields - Enables transparency into automation decisions ## Frontend Implementation ### API Hooks (NEW) - useBakeryHealthStatus() - Real-time health monitoring - useOrchestrationSummary() - System transparency - useActionQueue() - Prioritized action management - useProductionTimeline() - Production tracking - useInsights() - Glanceable metrics ### Dashboard Components (NEW) - HealthStatusCard: Traffic light indicator with checklist - ActionQueueCard: Prioritized actions with reasoning/consequences - OrchestrationSummaryCard: Narrative of what system did - ProductionTimelineCard: Chronological production view - InsightsGrid: 2x2 grid of key metrics ### Main Dashboard Page (REPLACED) - Complete rewrite with mobile-first design - All sections integrated with error handling - Real-time refresh and quick action links - Old dashboard backed up as DashboardPage.legacy.tsx ## Key Features ### Automation-First - Shows what orchestrator did overnight - Builds trust through transparency - Explains reasoning for all automated decisions ### Action-Oriented - Prioritizes tasks over information display - Clear consequences for each action - Large touch-friendly buttons ### Progressive Disclosure - Shows 20% of info that matters 80% of time - Expandable details when needed - No overwhelming metrics ### Mobile-First - One-handed operation - Large touch targets (min 44px) - Responsive grid layouts ### Trust-Building - Narrative format ("I planned your day") - Reasoning inputs transparency - Clear status indicators ## User Segments Supported 1. Solo Bakery Owner (Primary) - Simple health indicator - Action checklist (max 3-5 items) - Mobile-optimized 2. Multi-Location Owner - Multi-tenant support (existing) - Comparison capabilities - Delegation ready 3. Enterprise/Central Bakery (Future) - Network topology support - Advanced analytics ready ## JTBD Analysis Delivered Main Job: "Help me quickly understand bakery status and know what needs my intervention" Emotional Jobs Addressed: - Feel in control despite automation - Reduce daily anxiety - Feel competent with technology - Trust system as safety net Social Jobs Addressed: - Demonstrate professional management - Avoid being bottleneck - Show sustainability ## Technical Stack Backend: Python, FastAPI, SQLAlchemy, PostgreSQL Frontend: React, TypeScript, TanStack Query, Tailwind CSS Architecture: Microservices with circuit breakers ## Breaking Changes - Complete dashboard page rewrite (old version backed up) - New API endpoints require orchestrator service deployment - Database migrations needed for reasoning fields ## Migration Required Run migrations to add new model fields: - purchase_orders: reasoning, consequence, reasoning_data - production_batches: reasoning, reasoning_data ## Documentation See DASHBOARD_REDESIGN_SUMMARY.md for complete implementation details, JTBD analysis, success metrics, and deployment guide. BREAKING CHANGE: Dashboard page completely redesigned with new data structures
2025-11-07 17:10:17 +00:00
)
2025-11-15 21:21:06 +01:00
# Cache the result
if settings.CACHE_ENABLED:
cache_key = f"dashboard:health:{tenant_id}"
await set_cached(cache_key, health_status, ttl=settings.CACHE_TTL_HEALTH)
feat: Complete JTBD-aligned bakery dashboard redesign Implements comprehensive dashboard redesign based on Jobs To Be Done methodology focused on answering: "What requires my attention right now?" ## Backend Implementation ### Dashboard Service (NEW) - Health status calculation (green/yellow/red traffic light) - Action queue prioritization (critical/important/normal) - Orchestration summary with narrative format - Production timeline transformation - Insights calculation and consequence prediction ### API Endpoints (NEW) - GET /dashboard/health-status - Overall bakery health indicator - GET /dashboard/orchestration-summary - What system did automatically - GET /dashboard/action-queue - Prioritized tasks requiring attention - GET /dashboard/production-timeline - Today's production schedule - GET /dashboard/insights - Key metrics (savings, inventory, waste, deliveries) ### Enhanced Models - PurchaseOrder: Added reasoning, consequence, reasoning_data fields - ProductionBatch: Added reasoning, reasoning_data fields - Enables transparency into automation decisions ## Frontend Implementation ### API Hooks (NEW) - useBakeryHealthStatus() - Real-time health monitoring - useOrchestrationSummary() - System transparency - useActionQueue() - Prioritized action management - useProductionTimeline() - Production tracking - useInsights() - Glanceable metrics ### Dashboard Components (NEW) - HealthStatusCard: Traffic light indicator with checklist - ActionQueueCard: Prioritized actions with reasoning/consequences - OrchestrationSummaryCard: Narrative of what system did - ProductionTimelineCard: Chronological production view - InsightsGrid: 2x2 grid of key metrics ### Main Dashboard Page (REPLACED) - Complete rewrite with mobile-first design - All sections integrated with error handling - Real-time refresh and quick action links - Old dashboard backed up as DashboardPage.legacy.tsx ## Key Features ### Automation-First - Shows what orchestrator did overnight - Builds trust through transparency - Explains reasoning for all automated decisions ### Action-Oriented - Prioritizes tasks over information display - Clear consequences for each action - Large touch-friendly buttons ### Progressive Disclosure - Shows 20% of info that matters 80% of time - Expandable details when needed - No overwhelming metrics ### Mobile-First - One-handed operation - Large touch targets (min 44px) - Responsive grid layouts ### Trust-Building - Narrative format ("I planned your day") - Reasoning inputs transparency - Clear status indicators ## User Segments Supported 1. Solo Bakery Owner (Primary) - Simple health indicator - Action checklist (max 3-5 items) - Mobile-optimized 2. Multi-Location Owner - Multi-tenant support (existing) - Comparison capabilities - Delegation ready 3. Enterprise/Central Bakery (Future) - Network topology support - Advanced analytics ready ## JTBD Analysis Delivered Main Job: "Help me quickly understand bakery status and know what needs my intervention" Emotional Jobs Addressed: - Feel in control despite automation - Reduce daily anxiety - Feel competent with technology - Trust system as safety net Social Jobs Addressed: - Demonstrate professional management - Avoid being bottleneck - Show sustainability ## Technical Stack Backend: Python, FastAPI, SQLAlchemy, PostgreSQL Frontend: React, TypeScript, TanStack Query, Tailwind CSS Architecture: Microservices with circuit breakers ## Breaking Changes - Complete dashboard page rewrite (old version backed up) - New API endpoints require orchestrator service deployment - Database migrations needed for reasoning fields ## Migration Required Run migrations to add new model fields: - purchase_orders: reasoning, consequence, reasoning_data - production_batches: reasoning, reasoning_data ## Documentation See DASHBOARD_REDESIGN_SUMMARY.md for complete implementation details, JTBD analysis, success metrics, and deployment guide. BREAKING CHANGE: Dashboard page completely redesigned with new data structures
2025-11-07 17:10:17 +00:00
return BakeryHealthStatusResponse(**health_status)
except Exception as e:
logger.error(f"Error getting health status: {e}", exc_info=True)
raise HTTPException(status_code=500, detail=str(e))
@router.get("/orchestration-summary", response_model=OrchestrationSummaryResponse)
async def get_orchestration_summary(
tenant_id: str,
run_id: Optional[str] = Query(None, description="Specific run ID, or latest if not provided"),
db: AsyncSession = Depends(get_db)
) -> OrchestrationSummaryResponse:
"""
Get narrative summary of what the orchestrator did
This provides transparency into the automation, showing what was planned
and why, helping build user trust in the system.
"""
try:
2025-11-15 21:21:06 +01:00
# Try to get from cache (only if no specific run_id is provided)
if settings.CACHE_ENABLED and run_id is None:
cache_key = f"dashboard:summary:{tenant_id}"
cached = await get_cached(cache_key)
if cached:
return OrchestrationSummaryResponse(**cached)
feat: Complete JTBD-aligned bakery dashboard redesign Implements comprehensive dashboard redesign based on Jobs To Be Done methodology focused on answering: "What requires my attention right now?" ## Backend Implementation ### Dashboard Service (NEW) - Health status calculation (green/yellow/red traffic light) - Action queue prioritization (critical/important/normal) - Orchestration summary with narrative format - Production timeline transformation - Insights calculation and consequence prediction ### API Endpoints (NEW) - GET /dashboard/health-status - Overall bakery health indicator - GET /dashboard/orchestration-summary - What system did automatically - GET /dashboard/action-queue - Prioritized tasks requiring attention - GET /dashboard/production-timeline - Today's production schedule - GET /dashboard/insights - Key metrics (savings, inventory, waste, deliveries) ### Enhanced Models - PurchaseOrder: Added reasoning, consequence, reasoning_data fields - ProductionBatch: Added reasoning, reasoning_data fields - Enables transparency into automation decisions ## Frontend Implementation ### API Hooks (NEW) - useBakeryHealthStatus() - Real-time health monitoring - useOrchestrationSummary() - System transparency - useActionQueue() - Prioritized action management - useProductionTimeline() - Production tracking - useInsights() - Glanceable metrics ### Dashboard Components (NEW) - HealthStatusCard: Traffic light indicator with checklist - ActionQueueCard: Prioritized actions with reasoning/consequences - OrchestrationSummaryCard: Narrative of what system did - ProductionTimelineCard: Chronological production view - InsightsGrid: 2x2 grid of key metrics ### Main Dashboard Page (REPLACED) - Complete rewrite with mobile-first design - All sections integrated with error handling - Real-time refresh and quick action links - Old dashboard backed up as DashboardPage.legacy.tsx ## Key Features ### Automation-First - Shows what orchestrator did overnight - Builds trust through transparency - Explains reasoning for all automated decisions ### Action-Oriented - Prioritizes tasks over information display - Clear consequences for each action - Large touch-friendly buttons ### Progressive Disclosure - Shows 20% of info that matters 80% of time - Expandable details when needed - No overwhelming metrics ### Mobile-First - One-handed operation - Large touch targets (min 44px) - Responsive grid layouts ### Trust-Building - Narrative format ("I planned your day") - Reasoning inputs transparency - Clear status indicators ## User Segments Supported 1. Solo Bakery Owner (Primary) - Simple health indicator - Action checklist (max 3-5 items) - Mobile-optimized 2. Multi-Location Owner - Multi-tenant support (existing) - Comparison capabilities - Delegation ready 3. Enterprise/Central Bakery (Future) - Network topology support - Advanced analytics ready ## JTBD Analysis Delivered Main Job: "Help me quickly understand bakery status and know what needs my intervention" Emotional Jobs Addressed: - Feel in control despite automation - Reduce daily anxiety - Feel competent with technology - Trust system as safety net Social Jobs Addressed: - Demonstrate professional management - Avoid being bottleneck - Show sustainability ## Technical Stack Backend: Python, FastAPI, SQLAlchemy, PostgreSQL Frontend: React, TypeScript, TanStack Query, Tailwind CSS Architecture: Microservices with circuit breakers ## Breaking Changes - Complete dashboard page rewrite (old version backed up) - New API endpoints require orchestrator service deployment - Database migrations needed for reasoning fields ## Migration Required Run migrations to add new model fields: - purchase_orders: reasoning, consequence, reasoning_data - production_batches: reasoning, reasoning_data ## Documentation See DASHBOARD_REDESIGN_SUMMARY.md for complete implementation details, JTBD analysis, success metrics, and deployment guide. BREAKING CHANGE: Dashboard page completely redesigned with new data structures
2025-11-07 17:10:17 +00:00
dashboard_service = DashboardService(db)
# Get orchestration summary
summary = await dashboard_service.get_orchestration_summary(
tenant_id=tenant_id,
last_run_id=run_id
)
# Enhance with detailed PO and batch summaries
if summary["purchaseOrdersCreated"] > 0:
try:
po_data = await procurement_client.get_pending_purchase_orders(tenant_id, limit=10)
fix: Align dashboard API calls with actual procurement and production service endpoints CRITICAL FIX: Dashboard was calling non-existent API endpoints The Problem: ------------ The orchestrator dashboard service was calling API endpoints that don't exist: 1. Procurement: Expected dict {items: [...]} but API returns array [...] 2. Production: Called /production/production-batches/today - doesn't exist 3. Production: Called /production/production-batches - doesn't exist Root Cause: ----------- Created client methods without verifying actual backend API structure. Made assumptions about response formats that didn't match reality. The Fix: -------- **1. Procurement Client (shared/clients/procurement_client.py)** - Fixed get_pending_purchase_orders return type: Dict → List - Procurement API returns: List[PurchaseOrderResponse] directly - Changed: "Dict with {items: [...], total: n}" → "List of purchase order dicts" **2. Production Client (shared/clients/production_client.py)** - Fixed get_todays_batches endpoint: OLD: "/production/production-batches/today" (doesn't exist) NEW: "/production/batches?start_date=today&end_date=today" - Fixed get_production_batches_by_status endpoint: OLD: "/production/production-batches?status=X" NEW: "/production/batches?status=X" - Updated return type docs: {"items": [...]} → {"batches": [...], "total_count": n} - Response structure: ProductionBatchListResponse (batches, total_count, page, page_size) **3. Orchestrator Dashboard API (services/orchestrator/app/api/dashboard.py)** - Fixed all po_data access patterns: OLD: po_data.get("items", []) NEW: direct list access or po_data if isinstance(po_data, list) - Fixed production batch access: OLD: prod_data.get("items", []) NEW: prod_data.get("batches", []) - Updated 6 locations: * Line 206: health-status pending POs count * Line 216: health-status production delays count * Line 274-281: orchestration-summary PO summaries * Line 328-329: action-queue pending POs * Line 472-487: insights deliveries calculation * Line 499-519: insights savings calculation Verified Against: ----------------- Frontend successfully calls these exact APIs: - /tenants/{id}/procurement/purchase-orders (ProcurementPage.tsx) - /tenants/{id}/production/batches (production hooks) Both return arrays/objects as documented in their respective API files: - services/procurement/app/api/purchase_orders.py: returns List[PurchaseOrderResponse] - services/production/app/api/production_batches.py: returns ProductionBatchListResponse Now dashboard calls match actual backend APIs! ✅
2025-11-08 06:56:30 +00:00
if po_data and isinstance(po_data, list):
2025-11-21 16:15:09 +01:00
# Override stale orchestration count with actual real-time PO count
summary["purchaseOrdersCreated"] = len(po_data)
summary["userActionsRequired"] = len(po_data) # Update actions required to match actual pending POs
summary["purchaseOrdersSummary"] = [
PurchaseOrderSummary(
supplierName=po.get("supplier_name", "Unknown"),
itemCategories=[item.get("ingredient_name", "Item") for item in po.get("items", [])[:3]],
totalAmount=float(po.get("total_amount", 0))
)
fix: Align dashboard API calls with actual procurement and production service endpoints CRITICAL FIX: Dashboard was calling non-existent API endpoints The Problem: ------------ The orchestrator dashboard service was calling API endpoints that don't exist: 1. Procurement: Expected dict {items: [...]} but API returns array [...] 2. Production: Called /production/production-batches/today - doesn't exist 3. Production: Called /production/production-batches - doesn't exist Root Cause: ----------- Created client methods without verifying actual backend API structure. Made assumptions about response formats that didn't match reality. The Fix: -------- **1. Procurement Client (shared/clients/procurement_client.py)** - Fixed get_pending_purchase_orders return type: Dict → List - Procurement API returns: List[PurchaseOrderResponse] directly - Changed: "Dict with {items: [...], total: n}" → "List of purchase order dicts" **2. Production Client (shared/clients/production_client.py)** - Fixed get_todays_batches endpoint: OLD: "/production/production-batches/today" (doesn't exist) NEW: "/production/batches?start_date=today&end_date=today" - Fixed get_production_batches_by_status endpoint: OLD: "/production/production-batches?status=X" NEW: "/production/batches?status=X" - Updated return type docs: {"items": [...]} → {"batches": [...], "total_count": n} - Response structure: ProductionBatchListResponse (batches, total_count, page, page_size) **3. Orchestrator Dashboard API (services/orchestrator/app/api/dashboard.py)** - Fixed all po_data access patterns: OLD: po_data.get("items", []) NEW: direct list access or po_data if isinstance(po_data, list) - Fixed production batch access: OLD: prod_data.get("items", []) NEW: prod_data.get("batches", []) - Updated 6 locations: * Line 206: health-status pending POs count * Line 216: health-status production delays count * Line 274-281: orchestration-summary PO summaries * Line 328-329: action-queue pending POs * Line 472-487: insights deliveries calculation * Line 499-519: insights savings calculation Verified Against: ----------------- Frontend successfully calls these exact APIs: - /tenants/{id}/procurement/purchase-orders (ProcurementPage.tsx) - /tenants/{id}/production/batches (production hooks) Both return arrays/objects as documented in their respective API files: - services/procurement/app/api/purchase_orders.py: returns List[PurchaseOrderResponse] - services/production/app/api/production_batches.py: returns ProductionBatchListResponse Now dashboard calls match actual backend APIs! ✅
2025-11-08 06:56:30 +00:00
for po in po_data[:5] # Show top 5
]
except Exception as e:
logger.warning(f"Failed to fetch PO details: {e}")
feat: Complete JTBD-aligned bakery dashboard redesign Implements comprehensive dashboard redesign based on Jobs To Be Done methodology focused on answering: "What requires my attention right now?" ## Backend Implementation ### Dashboard Service (NEW) - Health status calculation (green/yellow/red traffic light) - Action queue prioritization (critical/important/normal) - Orchestration summary with narrative format - Production timeline transformation - Insights calculation and consequence prediction ### API Endpoints (NEW) - GET /dashboard/health-status - Overall bakery health indicator - GET /dashboard/orchestration-summary - What system did automatically - GET /dashboard/action-queue - Prioritized tasks requiring attention - GET /dashboard/production-timeline - Today's production schedule - GET /dashboard/insights - Key metrics (savings, inventory, waste, deliveries) ### Enhanced Models - PurchaseOrder: Added reasoning, consequence, reasoning_data fields - ProductionBatch: Added reasoning, reasoning_data fields - Enables transparency into automation decisions ## Frontend Implementation ### API Hooks (NEW) - useBakeryHealthStatus() - Real-time health monitoring - useOrchestrationSummary() - System transparency - useActionQueue() - Prioritized action management - useProductionTimeline() - Production tracking - useInsights() - Glanceable metrics ### Dashboard Components (NEW) - HealthStatusCard: Traffic light indicator with checklist - ActionQueueCard: Prioritized actions with reasoning/consequences - OrchestrationSummaryCard: Narrative of what system did - ProductionTimelineCard: Chronological production view - InsightsGrid: 2x2 grid of key metrics ### Main Dashboard Page (REPLACED) - Complete rewrite with mobile-first design - All sections integrated with error handling - Real-time refresh and quick action links - Old dashboard backed up as DashboardPage.legacy.tsx ## Key Features ### Automation-First - Shows what orchestrator did overnight - Builds trust through transparency - Explains reasoning for all automated decisions ### Action-Oriented - Prioritizes tasks over information display - Clear consequences for each action - Large touch-friendly buttons ### Progressive Disclosure - Shows 20% of info that matters 80% of time - Expandable details when needed - No overwhelming metrics ### Mobile-First - One-handed operation - Large touch targets (min 44px) - Responsive grid layouts ### Trust-Building - Narrative format ("I planned your day") - Reasoning inputs transparency - Clear status indicators ## User Segments Supported 1. Solo Bakery Owner (Primary) - Simple health indicator - Action checklist (max 3-5 items) - Mobile-optimized 2. Multi-Location Owner - Multi-tenant support (existing) - Comparison capabilities - Delegation ready 3. Enterprise/Central Bakery (Future) - Network topology support - Advanced analytics ready ## JTBD Analysis Delivered Main Job: "Help me quickly understand bakery status and know what needs my intervention" Emotional Jobs Addressed: - Feel in control despite automation - Reduce daily anxiety - Feel competent with technology - Trust system as safety net Social Jobs Addressed: - Demonstrate professional management - Avoid being bottleneck - Show sustainability ## Technical Stack Backend: Python, FastAPI, SQLAlchemy, PostgreSQL Frontend: React, TypeScript, TanStack Query, Tailwind CSS Architecture: Microservices with circuit breakers ## Breaking Changes - Complete dashboard page rewrite (old version backed up) - New API endpoints require orchestrator service deployment - Database migrations needed for reasoning fields ## Migration Required Run migrations to add new model fields: - purchase_orders: reasoning, consequence, reasoning_data - production_batches: reasoning, reasoning_data ## Documentation See DASHBOARD_REDESIGN_SUMMARY.md for complete implementation details, JTBD analysis, success metrics, and deployment guide. BREAKING CHANGE: Dashboard page completely redesigned with new data structures
2025-11-07 17:10:17 +00:00
if summary["productionBatchesCreated"] > 0:
try:
batch_data = await production_client.get_todays_batches(tenant_id)
if batch_data:
batches = batch_data.get("batches", [])
2025-11-21 16:15:09 +01:00
# Override stale orchestration count with actual real-time batch count
summary["productionBatchesCreated"] = len(batches)
summary["productionBatchesSummary"] = [
ProductionBatchSummary(
productName=batch.get("product_name", "Unknown"),
quantity=batch.get("planned_quantity", 0),
readyByTime=batch.get("planned_end_time", "")
)
for batch in batches[:5] # Show top 5
]
except Exception as e:
logger.warning(f"Failed to fetch batch details: {e}")
feat: Complete JTBD-aligned bakery dashboard redesign Implements comprehensive dashboard redesign based on Jobs To Be Done methodology focused on answering: "What requires my attention right now?" ## Backend Implementation ### Dashboard Service (NEW) - Health status calculation (green/yellow/red traffic light) - Action queue prioritization (critical/important/normal) - Orchestration summary with narrative format - Production timeline transformation - Insights calculation and consequence prediction ### API Endpoints (NEW) - GET /dashboard/health-status - Overall bakery health indicator - GET /dashboard/orchestration-summary - What system did automatically - GET /dashboard/action-queue - Prioritized tasks requiring attention - GET /dashboard/production-timeline - Today's production schedule - GET /dashboard/insights - Key metrics (savings, inventory, waste, deliveries) ### Enhanced Models - PurchaseOrder: Added reasoning, consequence, reasoning_data fields - ProductionBatch: Added reasoning, reasoning_data fields - Enables transparency into automation decisions ## Frontend Implementation ### API Hooks (NEW) - useBakeryHealthStatus() - Real-time health monitoring - useOrchestrationSummary() - System transparency - useActionQueue() - Prioritized action management - useProductionTimeline() - Production tracking - useInsights() - Glanceable metrics ### Dashboard Components (NEW) - HealthStatusCard: Traffic light indicator with checklist - ActionQueueCard: Prioritized actions with reasoning/consequences - OrchestrationSummaryCard: Narrative of what system did - ProductionTimelineCard: Chronological production view - InsightsGrid: 2x2 grid of key metrics ### Main Dashboard Page (REPLACED) - Complete rewrite with mobile-first design - All sections integrated with error handling - Real-time refresh and quick action links - Old dashboard backed up as DashboardPage.legacy.tsx ## Key Features ### Automation-First - Shows what orchestrator did overnight - Builds trust through transparency - Explains reasoning for all automated decisions ### Action-Oriented - Prioritizes tasks over information display - Clear consequences for each action - Large touch-friendly buttons ### Progressive Disclosure - Shows 20% of info that matters 80% of time - Expandable details when needed - No overwhelming metrics ### Mobile-First - One-handed operation - Large touch targets (min 44px) - Responsive grid layouts ### Trust-Building - Narrative format ("I planned your day") - Reasoning inputs transparency - Clear status indicators ## User Segments Supported 1. Solo Bakery Owner (Primary) - Simple health indicator - Action checklist (max 3-5 items) - Mobile-optimized 2. Multi-Location Owner - Multi-tenant support (existing) - Comparison capabilities - Delegation ready 3. Enterprise/Central Bakery (Future) - Network topology support - Advanced analytics ready ## JTBD Analysis Delivered Main Job: "Help me quickly understand bakery status and know what needs my intervention" Emotional Jobs Addressed: - Feel in control despite automation - Reduce daily anxiety - Feel competent with technology - Trust system as safety net Social Jobs Addressed: - Demonstrate professional management - Avoid being bottleneck - Show sustainability ## Technical Stack Backend: Python, FastAPI, SQLAlchemy, PostgreSQL Frontend: React, TypeScript, TanStack Query, Tailwind CSS Architecture: Microservices with circuit breakers ## Breaking Changes - Complete dashboard page rewrite (old version backed up) - New API endpoints require orchestrator service deployment - Database migrations needed for reasoning fields ## Migration Required Run migrations to add new model fields: - purchase_orders: reasoning, consequence, reasoning_data - production_batches: reasoning, reasoning_data ## Documentation See DASHBOARD_REDESIGN_SUMMARY.md for complete implementation details, JTBD analysis, success metrics, and deployment guide. BREAKING CHANGE: Dashboard page completely redesigned with new data structures
2025-11-07 17:10:17 +00:00
2025-11-15 21:21:06 +01:00
# Cache the result (only if no specific run_id)
if settings.CACHE_ENABLED and run_id is None:
cache_key = f"dashboard:summary:{tenant_id}"
await set_cached(cache_key, summary, ttl=settings.CACHE_TTL_SUMMARY)
feat: Complete JTBD-aligned bakery dashboard redesign Implements comprehensive dashboard redesign based on Jobs To Be Done methodology focused on answering: "What requires my attention right now?" ## Backend Implementation ### Dashboard Service (NEW) - Health status calculation (green/yellow/red traffic light) - Action queue prioritization (critical/important/normal) - Orchestration summary with narrative format - Production timeline transformation - Insights calculation and consequence prediction ### API Endpoints (NEW) - GET /dashboard/health-status - Overall bakery health indicator - GET /dashboard/orchestration-summary - What system did automatically - GET /dashboard/action-queue - Prioritized tasks requiring attention - GET /dashboard/production-timeline - Today's production schedule - GET /dashboard/insights - Key metrics (savings, inventory, waste, deliveries) ### Enhanced Models - PurchaseOrder: Added reasoning, consequence, reasoning_data fields - ProductionBatch: Added reasoning, reasoning_data fields - Enables transparency into automation decisions ## Frontend Implementation ### API Hooks (NEW) - useBakeryHealthStatus() - Real-time health monitoring - useOrchestrationSummary() - System transparency - useActionQueue() - Prioritized action management - useProductionTimeline() - Production tracking - useInsights() - Glanceable metrics ### Dashboard Components (NEW) - HealthStatusCard: Traffic light indicator with checklist - ActionQueueCard: Prioritized actions with reasoning/consequences - OrchestrationSummaryCard: Narrative of what system did - ProductionTimelineCard: Chronological production view - InsightsGrid: 2x2 grid of key metrics ### Main Dashboard Page (REPLACED) - Complete rewrite with mobile-first design - All sections integrated with error handling - Real-time refresh and quick action links - Old dashboard backed up as DashboardPage.legacy.tsx ## Key Features ### Automation-First - Shows what orchestrator did overnight - Builds trust through transparency - Explains reasoning for all automated decisions ### Action-Oriented - Prioritizes tasks over information display - Clear consequences for each action - Large touch-friendly buttons ### Progressive Disclosure - Shows 20% of info that matters 80% of time - Expandable details when needed - No overwhelming metrics ### Mobile-First - One-handed operation - Large touch targets (min 44px) - Responsive grid layouts ### Trust-Building - Narrative format ("I planned your day") - Reasoning inputs transparency - Clear status indicators ## User Segments Supported 1. Solo Bakery Owner (Primary) - Simple health indicator - Action checklist (max 3-5 items) - Mobile-optimized 2. Multi-Location Owner - Multi-tenant support (existing) - Comparison capabilities - Delegation ready 3. Enterprise/Central Bakery (Future) - Network topology support - Advanced analytics ready ## JTBD Analysis Delivered Main Job: "Help me quickly understand bakery status and know what needs my intervention" Emotional Jobs Addressed: - Feel in control despite automation - Reduce daily anxiety - Feel competent with technology - Trust system as safety net Social Jobs Addressed: - Demonstrate professional management - Avoid being bottleneck - Show sustainability ## Technical Stack Backend: Python, FastAPI, SQLAlchemy, PostgreSQL Frontend: React, TypeScript, TanStack Query, Tailwind CSS Architecture: Microservices with circuit breakers ## Breaking Changes - Complete dashboard page rewrite (old version backed up) - New API endpoints require orchestrator service deployment - Database migrations needed for reasoning fields ## Migration Required Run migrations to add new model fields: - purchase_orders: reasoning, consequence, reasoning_data - production_batches: reasoning, reasoning_data ## Documentation See DASHBOARD_REDESIGN_SUMMARY.md for complete implementation details, JTBD analysis, success metrics, and deployment guide. BREAKING CHANGE: Dashboard page completely redesigned with new data structures
2025-11-07 17:10:17 +00:00
return OrchestrationSummaryResponse(**summary)
except Exception as e:
logger.error(f"Error getting orchestration summary: {e}", exc_info=True)
raise HTTPException(status_code=500, detail=str(e))
@router.get("/action-queue", response_model=ActionQueueResponse)
async def get_action_queue(
tenant_id: str,
db: AsyncSession = Depends(get_db)
) -> ActionQueueResponse:
"""
Get prioritized queue of actions requiring user attention
This is the core of the JTBD dashboard - showing exactly what the user
needs to do right now, prioritized by urgency and impact.
"""
try:
dashboard_service = DashboardService(db)
2025-11-15 21:21:06 +01:00
# Fetch data from various services in parallel
async def fetch_pending_pos():
try:
po_data = await procurement_client.get_pending_purchase_orders(tenant_id, limit=20)
if po_data and isinstance(po_data, list):
return po_data
return []
except Exception as e:
logger.warning(f"Failed to fetch pending POs: {e}")
return []
2025-11-15 21:21:06 +01:00
async def fetch_critical_alerts():
try:
alerts_data = await alerts_client.get_critical_alerts(tenant_id, limit=20)
if alerts_data:
return alerts_data.get("alerts", [])
return []
except Exception as e:
logger.warning(f"Failed to fetch alerts: {e}")
return []
2025-11-15 21:21:06 +01:00
async def fetch_onboarding():
try:
onboarding_data = await procurement_client.get(
"/procurement/auth/onboarding-progress",
tenant_id=tenant_id
)
if onboarding_data:
return {
"incomplete": not onboarding_data.get("completed", True),
"steps": onboarding_data.get("steps", [])
}
return {"incomplete": False, "steps": []}
except Exception as e:
logger.warning(f"Failed to fetch onboarding status: {e}")
return {"incomplete": False, "steps": []}
# Execute all fetches in parallel
pending_pos, critical_alerts, onboarding = await asyncio.gather(
fetch_pending_pos(),
fetch_critical_alerts(),
fetch_onboarding()
)
onboarding_incomplete = onboarding["incomplete"]
onboarding_steps = onboarding["steps"]
feat: Complete JTBD-aligned bakery dashboard redesign Implements comprehensive dashboard redesign based on Jobs To Be Done methodology focused on answering: "What requires my attention right now?" ## Backend Implementation ### Dashboard Service (NEW) - Health status calculation (green/yellow/red traffic light) - Action queue prioritization (critical/important/normal) - Orchestration summary with narrative format - Production timeline transformation - Insights calculation and consequence prediction ### API Endpoints (NEW) - GET /dashboard/health-status - Overall bakery health indicator - GET /dashboard/orchestration-summary - What system did automatically - GET /dashboard/action-queue - Prioritized tasks requiring attention - GET /dashboard/production-timeline - Today's production schedule - GET /dashboard/insights - Key metrics (savings, inventory, waste, deliveries) ### Enhanced Models - PurchaseOrder: Added reasoning, consequence, reasoning_data fields - ProductionBatch: Added reasoning, reasoning_data fields - Enables transparency into automation decisions ## Frontend Implementation ### API Hooks (NEW) - useBakeryHealthStatus() - Real-time health monitoring - useOrchestrationSummary() - System transparency - useActionQueue() - Prioritized action management - useProductionTimeline() - Production tracking - useInsights() - Glanceable metrics ### Dashboard Components (NEW) - HealthStatusCard: Traffic light indicator with checklist - ActionQueueCard: Prioritized actions with reasoning/consequences - OrchestrationSummaryCard: Narrative of what system did - ProductionTimelineCard: Chronological production view - InsightsGrid: 2x2 grid of key metrics ### Main Dashboard Page (REPLACED) - Complete rewrite with mobile-first design - All sections integrated with error handling - Real-time refresh and quick action links - Old dashboard backed up as DashboardPage.legacy.tsx ## Key Features ### Automation-First - Shows what orchestrator did overnight - Builds trust through transparency - Explains reasoning for all automated decisions ### Action-Oriented - Prioritizes tasks over information display - Clear consequences for each action - Large touch-friendly buttons ### Progressive Disclosure - Shows 20% of info that matters 80% of time - Expandable details when needed - No overwhelming metrics ### Mobile-First - One-handed operation - Large touch targets (min 44px) - Responsive grid layouts ### Trust-Building - Narrative format ("I planned your day") - Reasoning inputs transparency - Clear status indicators ## User Segments Supported 1. Solo Bakery Owner (Primary) - Simple health indicator - Action checklist (max 3-5 items) - Mobile-optimized 2. Multi-Location Owner - Multi-tenant support (existing) - Comparison capabilities - Delegation ready 3. Enterprise/Central Bakery (Future) - Network topology support - Advanced analytics ready ## JTBD Analysis Delivered Main Job: "Help me quickly understand bakery status and know what needs my intervention" Emotional Jobs Addressed: - Feel in control despite automation - Reduce daily anxiety - Feel competent with technology - Trust system as safety net Social Jobs Addressed: - Demonstrate professional management - Avoid being bottleneck - Show sustainability ## Technical Stack Backend: Python, FastAPI, SQLAlchemy, PostgreSQL Frontend: React, TypeScript, TanStack Query, Tailwind CSS Architecture: Microservices with circuit breakers ## Breaking Changes - Complete dashboard page rewrite (old version backed up) - New API endpoints require orchestrator service deployment - Database migrations needed for reasoning fields ## Migration Required Run migrations to add new model fields: - purchase_orders: reasoning, consequence, reasoning_data - production_batches: reasoning, reasoning_data ## Documentation See DASHBOARD_REDESIGN_SUMMARY.md for complete implementation details, JTBD analysis, success metrics, and deployment guide. BREAKING CHANGE: Dashboard page completely redesigned with new data structures
2025-11-07 17:10:17 +00:00
# Build action queue
actions = await dashboard_service.get_action_queue(
tenant_id=tenant_id,
pending_pos=pending_pos,
critical_alerts=critical_alerts,
onboarding_incomplete=onboarding_incomplete,
onboarding_steps=onboarding_steps
)
# Count by urgency
critical_count = sum(1 for a in actions if a["urgency"] == "critical")
important_count = sum(1 for a in actions if a["urgency"] == "important")
return ActionQueueResponse(
actions=[ActionItem(**action) for action in actions[:10]], # Show top 10
totalActions=len(actions),
criticalCount=critical_count,
importantCount=important_count
)
except Exception as e:
logger.error(f"Error getting action queue: {e}", exc_info=True)
raise HTTPException(status_code=500, detail=str(e))
@router.get("/production-timeline", response_model=ProductionTimelineResponse)
async def get_production_timeline(
tenant_id: str,
db: AsyncSession = Depends(get_db)
) -> ProductionTimelineResponse:
"""
Get today's production timeline
Shows what's being made today in chronological order with status and progress.
"""
try:
dashboard_service = DashboardService(db)
# Fetch today's production batches
batches = []
try:
batch_data = await production_client.get_todays_batches(tenant_id)
if batch_data:
batches = batch_data.get("batches", [])
except Exception as e:
logger.warning(f"Failed to fetch production batches: {e}")
feat: Complete JTBD-aligned bakery dashboard redesign Implements comprehensive dashboard redesign based on Jobs To Be Done methodology focused on answering: "What requires my attention right now?" ## Backend Implementation ### Dashboard Service (NEW) - Health status calculation (green/yellow/red traffic light) - Action queue prioritization (critical/important/normal) - Orchestration summary with narrative format - Production timeline transformation - Insights calculation and consequence prediction ### API Endpoints (NEW) - GET /dashboard/health-status - Overall bakery health indicator - GET /dashboard/orchestration-summary - What system did automatically - GET /dashboard/action-queue - Prioritized tasks requiring attention - GET /dashboard/production-timeline - Today's production schedule - GET /dashboard/insights - Key metrics (savings, inventory, waste, deliveries) ### Enhanced Models - PurchaseOrder: Added reasoning, consequence, reasoning_data fields - ProductionBatch: Added reasoning, reasoning_data fields - Enables transparency into automation decisions ## Frontend Implementation ### API Hooks (NEW) - useBakeryHealthStatus() - Real-time health monitoring - useOrchestrationSummary() - System transparency - useActionQueue() - Prioritized action management - useProductionTimeline() - Production tracking - useInsights() - Glanceable metrics ### Dashboard Components (NEW) - HealthStatusCard: Traffic light indicator with checklist - ActionQueueCard: Prioritized actions with reasoning/consequences - OrchestrationSummaryCard: Narrative of what system did - ProductionTimelineCard: Chronological production view - InsightsGrid: 2x2 grid of key metrics ### Main Dashboard Page (REPLACED) - Complete rewrite with mobile-first design - All sections integrated with error handling - Real-time refresh and quick action links - Old dashboard backed up as DashboardPage.legacy.tsx ## Key Features ### Automation-First - Shows what orchestrator did overnight - Builds trust through transparency - Explains reasoning for all automated decisions ### Action-Oriented - Prioritizes tasks over information display - Clear consequences for each action - Large touch-friendly buttons ### Progressive Disclosure - Shows 20% of info that matters 80% of time - Expandable details when needed - No overwhelming metrics ### Mobile-First - One-handed operation - Large touch targets (min 44px) - Responsive grid layouts ### Trust-Building - Narrative format ("I planned your day") - Reasoning inputs transparency - Clear status indicators ## User Segments Supported 1. Solo Bakery Owner (Primary) - Simple health indicator - Action checklist (max 3-5 items) - Mobile-optimized 2. Multi-Location Owner - Multi-tenant support (existing) - Comparison capabilities - Delegation ready 3. Enterprise/Central Bakery (Future) - Network topology support - Advanced analytics ready ## JTBD Analysis Delivered Main Job: "Help me quickly understand bakery status and know what needs my intervention" Emotional Jobs Addressed: - Feel in control despite automation - Reduce daily anxiety - Feel competent with technology - Trust system as safety net Social Jobs Addressed: - Demonstrate professional management - Avoid being bottleneck - Show sustainability ## Technical Stack Backend: Python, FastAPI, SQLAlchemy, PostgreSQL Frontend: React, TypeScript, TanStack Query, Tailwind CSS Architecture: Microservices with circuit breakers ## Breaking Changes - Complete dashboard page rewrite (old version backed up) - New API endpoints require orchestrator service deployment - Database migrations needed for reasoning fields ## Migration Required Run migrations to add new model fields: - purchase_orders: reasoning, consequence, reasoning_data - production_batches: reasoning, reasoning_data ## Documentation See DASHBOARD_REDESIGN_SUMMARY.md for complete implementation details, JTBD analysis, success metrics, and deployment guide. BREAKING CHANGE: Dashboard page completely redesigned with new data structures
2025-11-07 17:10:17 +00:00
# Transform to timeline format
timeline = await dashboard_service.get_production_timeline(
tenant_id=tenant_id,
batches=batches
)
# Count by status
completed = sum(1 for item in timeline if item["status"] == "COMPLETED")
in_progress = sum(1 for item in timeline if item["status"] == "IN_PROGRESS")
pending = sum(1 for item in timeline if item["status"] == "PENDING")
return ProductionTimelineResponse(
timeline=[ProductionTimelineItem(**item) for item in timeline],
totalBatches=len(timeline),
completedBatches=completed,
inProgressBatches=in_progress,
pendingBatches=pending
)
except Exception as e:
logger.error(f"Error getting production timeline: {e}", exc_info=True)
raise HTTPException(status_code=500, detail=str(e))
@router.get("/unified-action-queue")
async def get_unified_action_queue(
tenant_id: str,
db: AsyncSession = Depends(get_db)
) -> Dict[str, Any]:
"""
Get unified action queue with time-based grouping
Combines all alerts (PO approvals, delivery tracking, production, etc.)
into URGENT (<6h), TODAY (<24h), and THIS WEEK (<7d) sections.
"""
try:
dashboard_service = DashboardService(db)
# Fetch all alerts from alert processor
alerts_data = await alerts_client.get_alerts(tenant_id, limit=100) or {}
alerts = alerts_data.get("alerts", [])
# Build unified queue
action_queue = await dashboard_service.get_unified_action_queue(
tenant_id=tenant_id,
alerts=alerts
)
return action_queue
except Exception as e:
logger.error(f"Error getting unified action queue: {e}", exc_info=True)
raise HTTPException(status_code=500, detail=str(e))
@router.get("/execution-progress")
async def get_execution_progress(
tenant_id: str,
db: AsyncSession = Depends(get_db)
) -> Dict[str, Any]:
"""
Get execution progress for today's plan
Shows plan vs actual for production batches, deliveries, and approvals
"""
try:
dashboard_service = DashboardService(db)
# Fetch today's data in parallel
async def fetch_todays_batches():
try:
batch_data = await production_client.get_todays_batches(tenant_id)
if batch_data:
return batch_data.get("batches", [])
return []
except Exception as e:
logger.warning(f"Failed to fetch today's batches: {e}")
return []
async def fetch_expected_deliveries():
try:
# Get POs with expected deliveries today
from datetime import datetime, timedelta, timezone
pos_result = await procurement_client.get_pending_purchase_orders(tenant_id, limit=100)
if pos_result and isinstance(pos_result, list):
today_start = datetime.now(timezone.utc).replace(hour=0, minute=0, second=0, microsecond=0)
today_end = today_start.replace(hour=23, minute=59, second=59)
deliveries_today = []
for po in pos_result:
expected_date = po.get("expected_delivery_date")
if expected_date:
if isinstance(expected_date, str):
expected_date = datetime.fromisoformat(expected_date.replace('Z', '+00:00'))
if today_start <= expected_date <= today_end:
deliveries_today.append(po)
return deliveries_today
return []
except Exception as e:
logger.warning(f"Failed to fetch expected deliveries: {e}")
return []
async def fetch_pending_approvals():
try:
po_data = await procurement_client.get_pending_purchase_orders(tenant_id, limit=100) or []
return len(po_data) if isinstance(po_data, list) else 0
except Exception as e:
logger.warning(f"Failed to fetch pending approvals: {e}")
return 0
# Execute in parallel
todays_batches, expected_deliveries, pending_approvals = await asyncio.gather(
fetch_todays_batches(),
fetch_expected_deliveries(),
fetch_pending_approvals()
)
# Calculate progress
progress = await dashboard_service.get_execution_progress(
tenant_id=tenant_id,
todays_batches=todays_batches,
expected_deliveries=expected_deliveries,
pending_approvals=pending_approvals
)
return progress
except Exception as e:
logger.error(f"Error getting execution progress: {e}", exc_info=True)
raise HTTPException(status_code=500, detail=str(e))
feat: Complete JTBD-aligned bakery dashboard redesign Implements comprehensive dashboard redesign based on Jobs To Be Done methodology focused on answering: "What requires my attention right now?" ## Backend Implementation ### Dashboard Service (NEW) - Health status calculation (green/yellow/red traffic light) - Action queue prioritization (critical/important/normal) - Orchestration summary with narrative format - Production timeline transformation - Insights calculation and consequence prediction ### API Endpoints (NEW) - GET /dashboard/health-status - Overall bakery health indicator - GET /dashboard/orchestration-summary - What system did automatically - GET /dashboard/action-queue - Prioritized tasks requiring attention - GET /dashboard/production-timeline - Today's production schedule - GET /dashboard/insights - Key metrics (savings, inventory, waste, deliveries) ### Enhanced Models - PurchaseOrder: Added reasoning, consequence, reasoning_data fields - ProductionBatch: Added reasoning, reasoning_data fields - Enables transparency into automation decisions ## Frontend Implementation ### API Hooks (NEW) - useBakeryHealthStatus() - Real-time health monitoring - useOrchestrationSummary() - System transparency - useActionQueue() - Prioritized action management - useProductionTimeline() - Production tracking - useInsights() - Glanceable metrics ### Dashboard Components (NEW) - HealthStatusCard: Traffic light indicator with checklist - ActionQueueCard: Prioritized actions with reasoning/consequences - OrchestrationSummaryCard: Narrative of what system did - ProductionTimelineCard: Chronological production view - InsightsGrid: 2x2 grid of key metrics ### Main Dashboard Page (REPLACED) - Complete rewrite with mobile-first design - All sections integrated with error handling - Real-time refresh and quick action links - Old dashboard backed up as DashboardPage.legacy.tsx ## Key Features ### Automation-First - Shows what orchestrator did overnight - Builds trust through transparency - Explains reasoning for all automated decisions ### Action-Oriented - Prioritizes tasks over information display - Clear consequences for each action - Large touch-friendly buttons ### Progressive Disclosure - Shows 20% of info that matters 80% of time - Expandable details when needed - No overwhelming metrics ### Mobile-First - One-handed operation - Large touch targets (min 44px) - Responsive grid layouts ### Trust-Building - Narrative format ("I planned your day") - Reasoning inputs transparency - Clear status indicators ## User Segments Supported 1. Solo Bakery Owner (Primary) - Simple health indicator - Action checklist (max 3-5 items) - Mobile-optimized 2. Multi-Location Owner - Multi-tenant support (existing) - Comparison capabilities - Delegation ready 3. Enterprise/Central Bakery (Future) - Network topology support - Advanced analytics ready ## JTBD Analysis Delivered Main Job: "Help me quickly understand bakery status and know what needs my intervention" Emotional Jobs Addressed: - Feel in control despite automation - Reduce daily anxiety - Feel competent with technology - Trust system as safety net Social Jobs Addressed: - Demonstrate professional management - Avoid being bottleneck - Show sustainability ## Technical Stack Backend: Python, FastAPI, SQLAlchemy, PostgreSQL Frontend: React, TypeScript, TanStack Query, Tailwind CSS Architecture: Microservices with circuit breakers ## Breaking Changes - Complete dashboard page rewrite (old version backed up) - New API endpoints require orchestrator service deployment - Database migrations needed for reasoning fields ## Migration Required Run migrations to add new model fields: - purchase_orders: reasoning, consequence, reasoning_data - production_batches: reasoning, reasoning_data ## Documentation See DASHBOARD_REDESIGN_SUMMARY.md for complete implementation details, JTBD analysis, success metrics, and deployment guide. BREAKING CHANGE: Dashboard page completely redesigned with new data structures
2025-11-07 17:10:17 +00:00
@router.get("/insights", response_model=InsightsResponse)
async def get_insights(
tenant_id: str,
db: AsyncSession = Depends(get_db)
) -> InsightsResponse:
"""
Get key insights for dashboard grid
Provides glanceable metrics on savings, inventory, waste, and deliveries.
"""
try:
2025-11-15 21:21:06 +01:00
# Try to get from cache
if settings.CACHE_ENABLED:
cache_key = f"dashboard:insights:{tenant_id}"
cached = await get_cached(cache_key)
if cached:
return InsightsResponse(**cached)
feat: Complete JTBD-aligned bakery dashboard redesign Implements comprehensive dashboard redesign based on Jobs To Be Done methodology focused on answering: "What requires my attention right now?" ## Backend Implementation ### Dashboard Service (NEW) - Health status calculation (green/yellow/red traffic light) - Action queue prioritization (critical/important/normal) - Orchestration summary with narrative format - Production timeline transformation - Insights calculation and consequence prediction ### API Endpoints (NEW) - GET /dashboard/health-status - Overall bakery health indicator - GET /dashboard/orchestration-summary - What system did automatically - GET /dashboard/action-queue - Prioritized tasks requiring attention - GET /dashboard/production-timeline - Today's production schedule - GET /dashboard/insights - Key metrics (savings, inventory, waste, deliveries) ### Enhanced Models - PurchaseOrder: Added reasoning, consequence, reasoning_data fields - ProductionBatch: Added reasoning, reasoning_data fields - Enables transparency into automation decisions ## Frontend Implementation ### API Hooks (NEW) - useBakeryHealthStatus() - Real-time health monitoring - useOrchestrationSummary() - System transparency - useActionQueue() - Prioritized action management - useProductionTimeline() - Production tracking - useInsights() - Glanceable metrics ### Dashboard Components (NEW) - HealthStatusCard: Traffic light indicator with checklist - ActionQueueCard: Prioritized actions with reasoning/consequences - OrchestrationSummaryCard: Narrative of what system did - ProductionTimelineCard: Chronological production view - InsightsGrid: 2x2 grid of key metrics ### Main Dashboard Page (REPLACED) - Complete rewrite with mobile-first design - All sections integrated with error handling - Real-time refresh and quick action links - Old dashboard backed up as DashboardPage.legacy.tsx ## Key Features ### Automation-First - Shows what orchestrator did overnight - Builds trust through transparency - Explains reasoning for all automated decisions ### Action-Oriented - Prioritizes tasks over information display - Clear consequences for each action - Large touch-friendly buttons ### Progressive Disclosure - Shows 20% of info that matters 80% of time - Expandable details when needed - No overwhelming metrics ### Mobile-First - One-handed operation - Large touch targets (min 44px) - Responsive grid layouts ### Trust-Building - Narrative format ("I planned your day") - Reasoning inputs transparency - Clear status indicators ## User Segments Supported 1. Solo Bakery Owner (Primary) - Simple health indicator - Action checklist (max 3-5 items) - Mobile-optimized 2. Multi-Location Owner - Multi-tenant support (existing) - Comparison capabilities - Delegation ready 3. Enterprise/Central Bakery (Future) - Network topology support - Advanced analytics ready ## JTBD Analysis Delivered Main Job: "Help me quickly understand bakery status and know what needs my intervention" Emotional Jobs Addressed: - Feel in control despite automation - Reduce daily anxiety - Feel competent with technology - Trust system as safety net Social Jobs Addressed: - Demonstrate professional management - Avoid being bottleneck - Show sustainability ## Technical Stack Backend: Python, FastAPI, SQLAlchemy, PostgreSQL Frontend: React, TypeScript, TanStack Query, Tailwind CSS Architecture: Microservices with circuit breakers ## Breaking Changes - Complete dashboard page rewrite (old version backed up) - New API endpoints require orchestrator service deployment - Database migrations needed for reasoning fields ## Migration Required Run migrations to add new model fields: - purchase_orders: reasoning, consequence, reasoning_data - production_batches: reasoning, reasoning_data ## Documentation See DASHBOARD_REDESIGN_SUMMARY.md for complete implementation details, JTBD analysis, success metrics, and deployment guide. BREAKING CHANGE: Dashboard page completely redesigned with new data structures
2025-11-07 17:10:17 +00:00
dashboard_service = DashboardService(db)
2025-11-15 21:21:06 +01:00
# Fetch data from various services in parallel
from datetime import datetime, timedelta, timezone
2025-11-15 21:21:06 +01:00
async def fetch_sustainability():
try:
return await inventory_client.get_sustainability_widget(tenant_id) or {}
except Exception as e:
logger.warning(f"Failed to fetch sustainability data: {e}")
return {}
2025-11-15 21:21:06 +01:00
async def fetch_inventory():
try:
raw_inventory_data = await inventory_client.get_stock_status(tenant_id)
# Handle case where API returns a list instead of dict
if isinstance(raw_inventory_data, dict):
return raw_inventory_data
elif isinstance(raw_inventory_data, list):
# If it's a list, aggregate the data
return {
"low_stock_count": sum(1 for item in raw_inventory_data if item.get("status") == "low_stock"),
"out_of_stock_count": sum(1 for item in raw_inventory_data if item.get("status") == "out_of_stock"),
"total_items": len(raw_inventory_data)
}
return {}
except Exception as e:
logger.warning(f"Failed to fetch inventory data: {e}")
return {}
feat: Replace hardcoded dashboard insights with real data from services MAJOR FIX: Dashboard now shows actual business data instead of mock values The Bug: -------- Dashboard insights were displaying hardcoded values: - Savings: Always showed "€124 this week" - Deliveries: Always showed "0 arriving today" - Not reflecting actual business activity Root Cause: ----------- Line 468-472 in dashboard.py had hardcoded mock savings data: ```python savings_data = { "weekly_savings": 124, "trend_percentage": 12 } ``` Deliveries data wasn't being fetched from any service. The Fix: -------- 1. **Real Savings Calculation:** - Fetches last 7 days of purchase orders - Sums up actual savings from price optimization - Uses po.optimization_data.savings field - Calculates: weekly_savings from PO optimization savings - Result: Shows €X based on actual cost optimizations 2. **Real Deliveries Data:** - Fetches pending purchase orders from procurement service - Counts POs with expected_delivery_date == today - Result: Shows actual number of deliveries arriving today 3. **Data Flow:** ``` procurement_client.get_pending_purchase_orders() → Filter by created_at (last 7 days) for savings → Filter by expected_delivery_date (today) for deliveries → Calculate totals → Pass to dashboard_service.calculate_insights() ``` Benefits: --------- ✅ Savings widget shows real optimization results ✅ Deliveries widget shows actual incoming deliveries ✅ Inventory widget already uses real stock data ✅ Waste widget already uses real sustainability data ✅ Dashboard reflects actual business activity Note: Trend percentage for savings still defaults to 12% as it requires historical comparison data (future enhancement).
2025-11-07 23:03:05 +00:00
2025-11-15 21:21:06 +01:00
async def fetch_deliveries():
try:
# Get recent POs with pending deliveries
pos_result = await procurement_client.get_pending_purchase_orders(tenant_id, limit=100)
if pos_result and isinstance(pos_result, list):
# Count deliveries expected today
today_start = datetime.now(timezone.utc).replace(hour=0, minute=0, second=0, microsecond=0)
today_end = today_start.replace(hour=23, minute=59, second=59)
deliveries_today = 0
for po in pos_result:
expected_date = po.get("expected_delivery_date")
if expected_date:
if isinstance(expected_date, str):
expected_date = datetime.fromisoformat(expected_date.replace('Z', '+00:00'))
if today_start <= expected_date <= today_end:
deliveries_today += 1
return {"deliveries_today": deliveries_today}
return {}
except Exception as e:
logger.warning(f"Failed to fetch delivery data: {e}")
return {}
async def fetch_savings():
try:
# Get prevented issue savings from alert analytics
analytics = await alerts_client.get_dashboard_analytics(tenant_id, days=7)
if analytics:
weekly_savings = analytics.get('estimated_savings_eur', 0)
prevented_count = analytics.get('prevented_issues_count', 0)
# Calculate trend from period comparison
period_comparison = analytics.get('period_comparison', {})
current_prevented = period_comparison.get('current_prevented', 0)
previous_prevented = period_comparison.get('previous_prevented', 0)
trend_percentage = 0
if previous_prevented > 0:
trend_percentage = ((current_prevented - previous_prevented) / previous_prevented) * 100
2025-11-15 21:21:06 +01:00
return {
"weekly_savings": round(weekly_savings, 2),
"trend_percentage": round(trend_percentage, 1),
"prevented_count": prevented_count
2025-11-15 21:21:06 +01:00
}
return {"weekly_savings": 0, "trend_percentage": 0, "prevented_count": 0}
2025-11-15 21:21:06 +01:00
except Exception as e:
logger.warning(f"Failed to calculate savings data: {e}")
return {"weekly_savings": 0, "trend_percentage": 0, "prevented_count": 0}
2025-11-15 21:21:06 +01:00
# Execute all fetches in parallel
sustainability_data, inventory_data, delivery_data, savings_data = await asyncio.gather(
fetch_sustainability(),
fetch_inventory(),
fetch_deliveries(),
fetch_savings()
)
feat: Replace hardcoded dashboard insights with real data from services MAJOR FIX: Dashboard now shows actual business data instead of mock values The Bug: -------- Dashboard insights were displaying hardcoded values: - Savings: Always showed "€124 this week" - Deliveries: Always showed "0 arriving today" - Not reflecting actual business activity Root Cause: ----------- Line 468-472 in dashboard.py had hardcoded mock savings data: ```python savings_data = { "weekly_savings": 124, "trend_percentage": 12 } ``` Deliveries data wasn't being fetched from any service. The Fix: -------- 1. **Real Savings Calculation:** - Fetches last 7 days of purchase orders - Sums up actual savings from price optimization - Uses po.optimization_data.savings field - Calculates: weekly_savings from PO optimization savings - Result: Shows €X based on actual cost optimizations 2. **Real Deliveries Data:** - Fetches pending purchase orders from procurement service - Counts POs with expected_delivery_date == today - Result: Shows actual number of deliveries arriving today 3. **Data Flow:** ``` procurement_client.get_pending_purchase_orders() → Filter by created_at (last 7 days) for savings → Filter by expected_delivery_date (today) for deliveries → Calculate totals → Pass to dashboard_service.calculate_insights() ``` Benefits: --------- ✅ Savings widget shows real optimization results ✅ Deliveries widget shows actual incoming deliveries ✅ Inventory widget already uses real stock data ✅ Waste widget already uses real sustainability data ✅ Dashboard reflects actual business activity Note: Trend percentage for savings still defaults to 12% as it requires historical comparison data (future enhancement).
2025-11-07 23:03:05 +00:00
# Merge delivery data into inventory data
inventory_data.update(delivery_data)
feat: Complete JTBD-aligned bakery dashboard redesign Implements comprehensive dashboard redesign based on Jobs To Be Done methodology focused on answering: "What requires my attention right now?" ## Backend Implementation ### Dashboard Service (NEW) - Health status calculation (green/yellow/red traffic light) - Action queue prioritization (critical/important/normal) - Orchestration summary with narrative format - Production timeline transformation - Insights calculation and consequence prediction ### API Endpoints (NEW) - GET /dashboard/health-status - Overall bakery health indicator - GET /dashboard/orchestration-summary - What system did automatically - GET /dashboard/action-queue - Prioritized tasks requiring attention - GET /dashboard/production-timeline - Today's production schedule - GET /dashboard/insights - Key metrics (savings, inventory, waste, deliveries) ### Enhanced Models - PurchaseOrder: Added reasoning, consequence, reasoning_data fields - ProductionBatch: Added reasoning, reasoning_data fields - Enables transparency into automation decisions ## Frontend Implementation ### API Hooks (NEW) - useBakeryHealthStatus() - Real-time health monitoring - useOrchestrationSummary() - System transparency - useActionQueue() - Prioritized action management - useProductionTimeline() - Production tracking - useInsights() - Glanceable metrics ### Dashboard Components (NEW) - HealthStatusCard: Traffic light indicator with checklist - ActionQueueCard: Prioritized actions with reasoning/consequences - OrchestrationSummaryCard: Narrative of what system did - ProductionTimelineCard: Chronological production view - InsightsGrid: 2x2 grid of key metrics ### Main Dashboard Page (REPLACED) - Complete rewrite with mobile-first design - All sections integrated with error handling - Real-time refresh and quick action links - Old dashboard backed up as DashboardPage.legacy.tsx ## Key Features ### Automation-First - Shows what orchestrator did overnight - Builds trust through transparency - Explains reasoning for all automated decisions ### Action-Oriented - Prioritizes tasks over information display - Clear consequences for each action - Large touch-friendly buttons ### Progressive Disclosure - Shows 20% of info that matters 80% of time - Expandable details when needed - No overwhelming metrics ### Mobile-First - One-handed operation - Large touch targets (min 44px) - Responsive grid layouts ### Trust-Building - Narrative format ("I planned your day") - Reasoning inputs transparency - Clear status indicators ## User Segments Supported 1. Solo Bakery Owner (Primary) - Simple health indicator - Action checklist (max 3-5 items) - Mobile-optimized 2. Multi-Location Owner - Multi-tenant support (existing) - Comparison capabilities - Delegation ready 3. Enterprise/Central Bakery (Future) - Network topology support - Advanced analytics ready ## JTBD Analysis Delivered Main Job: "Help me quickly understand bakery status and know what needs my intervention" Emotional Jobs Addressed: - Feel in control despite automation - Reduce daily anxiety - Feel competent with technology - Trust system as safety net Social Jobs Addressed: - Demonstrate professional management - Avoid being bottleneck - Show sustainability ## Technical Stack Backend: Python, FastAPI, SQLAlchemy, PostgreSQL Frontend: React, TypeScript, TanStack Query, Tailwind CSS Architecture: Microservices with circuit breakers ## Breaking Changes - Complete dashboard page rewrite (old version backed up) - New API endpoints require orchestrator service deployment - Database migrations needed for reasoning fields ## Migration Required Run migrations to add new model fields: - purchase_orders: reasoning, consequence, reasoning_data - production_batches: reasoning, reasoning_data ## Documentation See DASHBOARD_REDESIGN_SUMMARY.md for complete implementation details, JTBD analysis, success metrics, and deployment guide. BREAKING CHANGE: Dashboard page completely redesigned with new data structures
2025-11-07 17:10:17 +00:00
# Calculate insights
insights = await dashboard_service.calculate_insights(
tenant_id=tenant_id,
sustainability_data=sustainability_data,
inventory_data=inventory_data,
savings_data=savings_data
)
2025-11-15 21:21:06 +01:00
# Prepare response
response_data = {
"savings": insights["savings"],
"inventory": insights["inventory"],
"waste": insights["waste"],
"deliveries": insights["deliveries"]
}
# Cache the result
if settings.CACHE_ENABLED:
cache_key = f"dashboard:insights:{tenant_id}"
await set_cached(cache_key, response_data, ttl=settings.CACHE_TTL_INSIGHTS)
feat: Complete JTBD-aligned bakery dashboard redesign Implements comprehensive dashboard redesign based on Jobs To Be Done methodology focused on answering: "What requires my attention right now?" ## Backend Implementation ### Dashboard Service (NEW) - Health status calculation (green/yellow/red traffic light) - Action queue prioritization (critical/important/normal) - Orchestration summary with narrative format - Production timeline transformation - Insights calculation and consequence prediction ### API Endpoints (NEW) - GET /dashboard/health-status - Overall bakery health indicator - GET /dashboard/orchestration-summary - What system did automatically - GET /dashboard/action-queue - Prioritized tasks requiring attention - GET /dashboard/production-timeline - Today's production schedule - GET /dashboard/insights - Key metrics (savings, inventory, waste, deliveries) ### Enhanced Models - PurchaseOrder: Added reasoning, consequence, reasoning_data fields - ProductionBatch: Added reasoning, reasoning_data fields - Enables transparency into automation decisions ## Frontend Implementation ### API Hooks (NEW) - useBakeryHealthStatus() - Real-time health monitoring - useOrchestrationSummary() - System transparency - useActionQueue() - Prioritized action management - useProductionTimeline() - Production tracking - useInsights() - Glanceable metrics ### Dashboard Components (NEW) - HealthStatusCard: Traffic light indicator with checklist - ActionQueueCard: Prioritized actions with reasoning/consequences - OrchestrationSummaryCard: Narrative of what system did - ProductionTimelineCard: Chronological production view - InsightsGrid: 2x2 grid of key metrics ### Main Dashboard Page (REPLACED) - Complete rewrite with mobile-first design - All sections integrated with error handling - Real-time refresh and quick action links - Old dashboard backed up as DashboardPage.legacy.tsx ## Key Features ### Automation-First - Shows what orchestrator did overnight - Builds trust through transparency - Explains reasoning for all automated decisions ### Action-Oriented - Prioritizes tasks over information display - Clear consequences for each action - Large touch-friendly buttons ### Progressive Disclosure - Shows 20% of info that matters 80% of time - Expandable details when needed - No overwhelming metrics ### Mobile-First - One-handed operation - Large touch targets (min 44px) - Responsive grid layouts ### Trust-Building - Narrative format ("I planned your day") - Reasoning inputs transparency - Clear status indicators ## User Segments Supported 1. Solo Bakery Owner (Primary) - Simple health indicator - Action checklist (max 3-5 items) - Mobile-optimized 2. Multi-Location Owner - Multi-tenant support (existing) - Comparison capabilities - Delegation ready 3. Enterprise/Central Bakery (Future) - Network topology support - Advanced analytics ready ## JTBD Analysis Delivered Main Job: "Help me quickly understand bakery status and know what needs my intervention" Emotional Jobs Addressed: - Feel in control despite automation - Reduce daily anxiety - Feel competent with technology - Trust system as safety net Social Jobs Addressed: - Demonstrate professional management - Avoid being bottleneck - Show sustainability ## Technical Stack Backend: Python, FastAPI, SQLAlchemy, PostgreSQL Frontend: React, TypeScript, TanStack Query, Tailwind CSS Architecture: Microservices with circuit breakers ## Breaking Changes - Complete dashboard page rewrite (old version backed up) - New API endpoints require orchestrator service deployment - Database migrations needed for reasoning fields ## Migration Required Run migrations to add new model fields: - purchase_orders: reasoning, consequence, reasoning_data - production_batches: reasoning, reasoning_data ## Documentation See DASHBOARD_REDESIGN_SUMMARY.md for complete implementation details, JTBD analysis, success metrics, and deployment guide. BREAKING CHANGE: Dashboard page completely redesigned with new data structures
2025-11-07 17:10:17 +00:00
return InsightsResponse(
savings=InsightCard(**insights["savings"]),
inventory=InsightCard(**insights["inventory"]),
waste=InsightCard(**insights["waste"]),
deliveries=InsightCard(**insights["deliveries"])
)
except Exception as e:
logger.error(f"Error getting insights: {e}", exc_info=True)
raise HTTPException(status_code=500, detail=str(e))