diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md new file mode 100644 index 00000000..158e9ee6 --- /dev/null +++ b/docs/ROADMAP.md @@ -0,0 +1,172 @@ +⏺ Based on my analysis of your bakery project, here's a clear divide + and conquer strategy to transition from mock/demo data to real API + connections: + + Current State Analysis + + ✅ What's Already Done: + - Complete backend microservices architecture (17+ services) + - Full API client setup with authentication & tenant management + - Comprehensive service layer (auth, inventory, sales, forecasting, + etc.) + - Real-time SSE & WebSocket infrastructure + + 🔍 What Needs Connection: + - Mock data in auth store (mockLogin, mockRefreshToken) + - Mock alerts in alerts store (mockAlerts, mockRules) + - Various hardcoded arrays across hooks and utilities + + Divide & Conquer Strategy + + Phase 1: Authentication Foundation (Week 1) + + Priority: CRITICAL - Everything depends on this + + // IMMEDIATE ACTION: Replace mock auth + 1. Update auth.store.ts → Connect to real auth service + 2. Replace mockLogin() with authService.login() + 3. Replace mockRefreshToken() with authService.refreshToken() + 4. Test tenant switching and permission system + + Files to modify: + - frontend/src/stores/auth.store.ts:46-88 (replace mock functions) + - frontend/src/services/api/auth.service.ts (already done) + + Phase 2: Core Operations (Week 2) + + Priority: HIGH - Daily operations + + // Connect inventory management first (most used) + 1. Inventory Service → Real API calls + - Replace mock data in components + - Connect to /api/v1/inventory/* endpoints + + 2. Production Service → Real API calls + - Connect batch management + - Link to /api/v1/production/* endpoints + + 3. Sales Service → Real API calls + - Connect POS integration + - Link to /api/v1/sales/* endpoints + + Files to modify: + - All inventory components using mock data + - Production scheduling hooks + - Sales tracking components + + Phase 3: Analytics & Intelligence (Week 3) + + Priority: MEDIUM - Business insights + + // Connect AI-powered features + 1. Forecasting Service → Real ML predictions + - Connect to /api/v1/forecasts/* endpoints + - Enable real demand forecasting + + 2. Training Service → Real model training + - Connect WebSocket training progress + - Enable /api/v1/training/* endpoints + + 3. Analytics Service → Real business data + - Connect charts and reports + - Enable trend analysis + + Phase 4: Communication & Automation (Week 4) + + Priority: LOW - Enhancements + + // Replace mock alerts with real-time system + 1. Alerts Store → Real SSE connection + - Connect to /api/v1/sse/alerts/stream/{tenant_id} + - Replace mockAlerts with live data + + 2. Notification Service → Real messaging + - WhatsApp & Email integration + - Connect to /api/v1/notifications/* endpoints + + 3. External Data → Live feeds + - Weather API (AEMET) + - Traffic patterns + - Market events + + Specific Next Steps + + STEP 1: Start with Authentication (Today) + + // 1. Replace frontend/src/stores/auth.store.ts + // Remove lines 46-88 and replace with: + + const performLogin = async (email: string, password: string) => { + const response = await authService.login({ email, password }); + if (!response.success) throw new Error(response.error || 'Login + failed'); + return response.data; + }; + + const performRefresh = async (refreshToken: string) => { + const response = await authService.refreshToken(refreshToken); + if (!response.success) throw new Error('Token refresh failed'); + return response.data; + }; + + STEP 2: Connect Inventory (Next) + + // 2. Update inventory components to use real API + // Replace mock data arrays with: + + const { data: ingredients, isLoading } = useQuery({ + queryKey: ['ingredients', tenantId], + queryFn: () => inventoryService.getIngredients(), + }); + + STEP 3: Enable Real-time Alerts (After) + + // 3. Connect SSE for real alerts + // Replace alerts store mock data with: + + useEffect(() => { + const eventSource = new + EventSource(`/api/v1/sse/alerts/stream/${tenantId}`); + + eventSource.onmessage = (event) => { + const alert = JSON.parse(event.data); + createAlert(alert); + }; + + return () => eventSource.close(); + }, [tenantId]); + + Migration Checklist + + Immediate (This Week) + + - Replace auth mock functions with real API calls + - Test login/logout/refresh flows + - Verify tenant switching works + - Test permission-based UI rendering + + Short-term (Next 2 Weeks) + + - Connect inventory service to real API + - Enable production planning with real data + - Connect sales tracking to POS systems + - Test data consistency across services + + Medium-term (Next Month) + + - Enable ML forecasting with real models + - Connect real-time alert system + - Integrate external data sources (weather, traffic) + - Test full end-to-end workflows + + Risk Mitigation + + 1. Gradual Migration: Keep mock fallbacks during transition + 2. Environment Switching: Use env variables to toggle mock/real APIs + 3. Error Handling: Robust error handling for API failures + 4. Data Validation: Verify API responses match expected schemas + 5. User Testing: Test with real bakery workflows + + Ready to start? I recommend beginning with Step 1 (Authentication) + today. The infrastructure is already there - you just need to connect + the pipes! \ No newline at end of file diff --git a/frontend/src/components/domain/auth/index.ts b/frontend/src/components/domain/auth/index.ts index 7ed34712..ec659ec5 100644 --- a/frontend/src/components/domain/auth/index.ts +++ b/frontend/src/components/domain/auth/index.ts @@ -4,12 +4,6 @@ export { default as RegisterForm } from './RegisterForm'; export { default as PasswordResetForm } from './PasswordResetForm'; export { default as ProfileSettings } from './ProfileSettings'; -// Export named exports as well -export { LoginForm } from './LoginForm'; -export { RegisterForm } from './RegisterForm'; -export { PasswordResetForm } from './PasswordResetForm'; -export { ProfileSettings } from './ProfileSettings'; - // Re-export types for convenience export type { LoginFormProps, diff --git a/frontend/src/components/layout/AppShell/AppShell.tsx b/frontend/src/components/layout/AppShell/AppShell.tsx index ead7e819..fb06c545 100644 --- a/frontend/src/components/layout/AppShell/AppShell.tsx +++ b/frontend/src/components/layout/AppShell/AppShell.tsx @@ -124,7 +124,7 @@ export const AppShell = forwardRef(({ isSidebarCollapsed, }), [toggleSidebar, collapseSidebar, expandSidebar, isSidebarOpen, isSidebarCollapsed]); - // Handle responsive sidebar state + // Handle responsive sidebar state and prevent body scroll on mobile React.useEffect(() => { const handleResize = () => { if (window.innerWidth >= 1024) { @@ -133,9 +133,26 @@ export const AppShell = forwardRef(({ } }; + // Prevent body scroll when mobile sidebar is open + if (isSidebarOpen && window.innerWidth < 1024) { + document.body.style.overflow = 'hidden'; + document.body.style.position = 'fixed'; + document.body.style.width = '100%'; + } else { + document.body.style.overflow = ''; + document.body.style.position = ''; + document.body.style.width = ''; + } + window.addEventListener('resize', handleResize); - return () => window.removeEventListener('resize', handleResize); - }, []); + return () => { + window.removeEventListener('resize', handleResize); + // Cleanup on unmount + document.body.style.overflow = ''; + document.body.style.position = ''; + document.body.style.width = ''; + }; + }, [isSidebarOpen]); // Error boundary handling React.useEffect(() => { @@ -212,8 +229,9 @@ export const AppShell = forwardRef(({ {/* Mobile overlay */} {isSidebarOpen && (