cardamom
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Viewing readonly version of main branch: v388View latest version
IMPLEMENTED: Dual-view meal planning system with scrollable daily list (default) and monthly calendar view. Users can plan meals by assigning recipes to specific days and meal types, then generate shopping lists from selected days.
meal_plans_v2
table created with:id
(INTEGER PRIMARY KEY)recipe_id
(INTEGER FK to recipes_v1)date
(DATE)meal_type
(TEXT: 'breakfast-lunch', 'dinner')notes
(TEXT)created_at
(DATETIME)updated_at
(DATETIME)- UPDATED: Simplified to 2 meal types, allows multiple recipes per meal type
- Smart Data Migration: Automatically migrates from v1 to v2, combines breakfast/lunch, skips snacks
- Proper Constraints: Database-level validation for meal types
Complete REST API in /backend/routes/meal-plans.ts
:
- ✅
GET /api/meal-plans
- Get meal plans for date range- Query params:
startDate
,endDate
- Returns meal plans with LEFT JOIN for deleted recipe handling
- Efficient date range filtering
- Query params:
- ✅
POST /api/meal-plans
- Create meal plan- Validates recipe exists before creation
- Input validation for meal types and date formats
- Transaction-safe atomic operations
- ✅
DELETE /api/meal-plans/:id
- Remove meal plan - ✅
PUT /api/meal-plans/:id
- Update meal plan- Change date/meal type with validation
- ✅
POST /api/meal-plans/shopping-list
- Generate shopping list from calendar- Supports date ranges or specific date arrays
- Filters out deleted recipes automatically
- Reuses existing shopping list creation logic
-
MealPlanCalendar.tsx
- Dual-view meal planning interface- ✅ Default List View: Scrollable daily cards showing planned meals
- ✅ Calendar View: Full monthly grid with day selection
- ✅ View Switcher: Toggle between "📝 List" and "📅 Calendar"
- ✅ Shopping List Integration: Multi-day selection for list creation
- ✅ Mobile-responsive: Adaptive layouts for both views
-
DayMealPlan.tsx
- Detailed day meal editor- ✅ Modal Interface: Full-screen day planning modal
- ✅ Meal Type Sections: "Breakfast & Lunch" and "Dinner"
- ✅ Multiple Recipes: Support for multiple recipes per meal type
- ✅ Recipe Management: Add/remove individual recipes
- ✅ Deleted Recipe Handling: Warning display for deleted recipes
- ✅ Ingredient Count: Total ingredients calculation
-
MealPlanSidebar.tsx
- Recipe selection interface- ✅ Smart Filtering: Search, tags, difficulty, prep time filters
- ✅ Recipe Metadata: Prep time, difficulty, tags display
- ✅ Simple Success Feedback: Auto-close on successful add
- ✅ Error Handling: Clear error messages and validation
- ✅ Mobile Overlay: Full-screen sidebar on mobile
App.tsx
- Added 'meal-calendar' view and navigation button- Type System - Updated
shared/types.ts
with meal planning interfaces
- Daily Cards: Clean cards for each day with meal plans
- Color Coding: Orange for "Breakfast & Lunch", Purple for "Dinner"
- Today Highlighting: Blue accent for current day
- Recipe Details: Prep time, difficulty badges, deleted recipe warnings
- Empty States: Engaging empty state with call-to-action
┌─────────────────────────────────────────────────┐
│ 📝 List | 📅 Calendar [Create List] │
├─────────────────────────────────────────────────┤
│ Sun │ Mon │ Tue │ Wed │ Thu │ Fri │ Sat │ │
├─────┼─────┼─────┼─────┼─────┼─────┼─────┤ │
│ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ │
│B&L:2│B&L:-│B&L:1│B&L:3│B&L:-│B&L:-│B&L:1│ │
│ D:3 │ D:1 │ D:2 │ D:- │ D:2 │ D:1 │ D:2 │ │
├─────┼─────┼─────┼─────┼─────┼─────┼─────┤ │
│ 8 │ 9 │ ... │ │ │
└─────┴─────┴─────┴─────────────────────────┘
Legend: B&L=Breakfast & Lunch, D=Dinner
- Responsive Grids: CSS Grid adapts to screen size
- Touch-Friendly: 44px minimum touch targets
- Modal Interfaces: Full-screen modals for editing
- Stackable Views: List view naturally stacks on mobile
- ✅ Database Migration: Created
meal_plans_v2
with smart v1→v2 migration - ✅ Database Queries: All CRUD operations with transaction safety
- ✅ API Routes: Complete REST API with validation and error handling
- ✅ Backend Integration: Added to main app routes
- ✅ MealPlanCalendar: Dual-view interface with list/calendar toggle
- ✅ Day Navigation: Month navigation and day selection
- ✅ Meal Display: Recipe counts and meal type indicators
- ✅ Responsive Design: Mobile-first CSS Grid layouts
- ✅ MealPlanSidebar: Advanced recipe selection with filtering
- ✅ Success Feedback: Auto-close sidebar on successful add
- ✅ DayMealPlan: Detailed day editing with meal type sections
- ✅ Multiple Recipes: Full support for multiple recipes per meal type
- ✅ Selection Mode: Multi-day selection in both list and calendar views
- ✅ Shopping List Generation: Direct integration with existing system
- ✅ Transaction Safety: Atomic operations with deleted recipe filtering
- ✅ User Experience: Seamless flow from planning to shopping
- ✅ Mobile Optimization: Touch-friendly interactions and responsive design
- ✅ User Feedback: Simplified success indication and error handling
- ✅ Data Integrity: Comprehensive deleted recipe handling
- ✅ Performance: Efficient data loading for both view types
The core meal planning system is COMPLETE and fully functional. Potential future enhancements:
- 📅 Meal Plan Templates: Save and reuse weekly meal plans
- 🍽️ Serving Size Adjustments: Modify recipe servings when adding to meal plans
- 📝 Meal Notes: Add custom notes to individual meal plans
- 🔄 Copy Previous Week: Quickly duplicate successful meal plans
- 📊 Nutritional Overview: Daily/weekly nutritional summaries
- ⭐ Recipe Suggestions: AI-powered meal recommendations based on preferences
- 🏷️ Meal Plan Tags: Organize meal plans with custom tags (e.g., "Date Night", "Meal Prep")
- 📱 Progressive Web App: Offline support for grocery shopping
- 🔔 Meal Prep Reminders: Notifications for prep and cooking times
- 📸 Meal Photos: Add photos of completed meals
- 🛒 Advanced Shopping Lists: Group by store sections, estimated costs
- 📊 Recipe Analytics: Track most-used recipes, cooking frequency
- 👥 Family Profiles: Multiple meal preferences and dietary restrictions
- 📱 Mobile App: Native mobile apps for iOS/Android
MEAL PLANNING IS FULLY IMPLEMENTED with:
- ✅ Complete Backend: Database, API, migrations, transaction safety
- ✅ Dual-View Interface: List view (default) + Calendar view
- ✅ Full CRUD Operations: Add, edit, delete meal plans
- ✅ Shopping List Integration: Generate lists from selected days
- ✅ Mobile Responsive: Touch-friendly, adaptive layouts
- ✅ Data Integrity: Handles deleted recipes gracefully
- ✅ User-Friendly: Simple success feedback, clear navigation
The system is production-ready and provides a comprehensive meal planning experience that integrates seamlessly with the existing recipe management and shopping list features. 🎉