• Townie
    AI
  • Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
connnolly

connnolly

cardamom

Unlisted
Like
2
cardamom
Home
Code
13
.claude
1
.cursor
1
backend
4
frontend
3
shared
2
.vtignore
CLAUDE.md
README.md
claude-fixes.md
deno.json
meal-planning-implementation-plan.md
test-normalization-cache.ts
todo.md
Branches
2
Pull requests
Remixes
History
Environment variables
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.
Sign up now
Code
/
meal-planning-implementation-plan.md
Code
/
meal-planning-implementation-plan.md
Search
9/13/2025
Viewing readonly version of main branch: v371
View latest version
meal-planning-implementation-plan.md

Calendar View for Meal Planning - Implementation Plan

Overview

Add a calendar view that allows users to plan meals by placing recipes on specific days, then generate shopping lists from selected calendar days. This will be an optional entry point into the shopping list creation process.

Architecture Approach

1. Database Schema Changes

Create new tables for meal planning:

  • meal_plans_v1 table:
    • id (INTEGER PRIMARY KEY)
    • recipe_id (INTEGER FK to recipes_v1)
    • date (DATE)
    • meal_type (TEXT: 'breakfast', 'lunch', 'dinner', 'snack')
    • notes (TEXT)
    • created_at (DATETIME)
    • updated_at (DATETIME)
    • Note: NO unique constraint - allows multiple recipes per meal type per day

2. Backend API Endpoints

New routes in /backend/routes/meal-plans.ts:

  • GET /api/meal-plans - Get meal plans for date range
    • Query params: startDate, endDate
    • Returns array of meal plans with populated recipe data
  • POST /api/meal-plans - Add recipe to calendar
    • Body: { recipeId, date, mealType, notes? }
    • Allows multiple recipes for same meal type
  • DELETE /api/meal-plans/:id - Remove specific recipe from calendar
  • PUT /api/meal-plans/:id - Update meal plan (change date/meal type)
  • POST /api/meal-plans/shopping-list - Create shopping list from date range
    • Body: { startDate, endDate } or { dates: [...] }
    • Collects all recipes from selected dates

3. Frontend Components

New Components:

  • MealPlanCalendar.tsx - Main calendar view component

    • Month view with week rows
    • Each day shows meal slots with recipe count badges
    • Support multiple recipes per meal type
    • Click to view/edit day's meals
    • Mobile-responsive grid layout
  • DayMealPlan.tsx - Single day's meal plan

    • Shows all recipes for each meal type (as a list)
    • Add/remove individual recipes
    • Quick view of total ingredients needed
    • Collapsible sections for each meal type
  • MealPlanSidebar.tsx - Recipe selector sidebar

    • Searchable list of recipes
    • Click to add to selected day/meal
    • Filter by tags, prep time, etc.
    • Mobile: slides in as overlay

Modified Components:

  • App.tsx - Add 'meal-calendar' view type and navigation
  • ShoppingListCreator.tsx - Add option to create from calendar selection

4. User Interface Design

Calendar Layout (Desktop):

┌─────────────────────────────────────────────────┐
│  < November 2025 >            [Create List] [⚙️] │
├─────────────────────────────────────────────────┤
│ Sun │ Mon │ Tue │ Wed │ Thu │ Fri │ Sat │       │
├─────┼─────┼─────┼─────┼─────┼─────┼─────┤       │
│  1  │  2  │  3  │  4  │  5  │  6  │  7  │  [R]  │
│ B:2 │ B:- │ B:1 │ B:3 │ B:- │ B:- │ B:1 │  [e]  │
│ L:1 │ L:2 │ L:- │ L:2 │ L:1 │ L:- │ L:3 │  [c]  │
│ D:3 │ D:1 │ D:2 │ D:- │ D:2 │ D:1 │ D:2 │  [i]  │
├─────┼─────┼─────┼─────┼─────┼─────┼─────┤  [p]  │
│  8  │  9  │ ... │                         │  [e]  │
│     │     │     │                         │  [s]  │
└─────┴─────┴─────┴─────────────────────────┴───────┘

Legend: B=Breakfast, L=Lunch, D=Dinner
Numbers = Recipe count, - = No recipes

Mobile Layout:

  • Stack days vertically
  • Swipeable week view
  • Collapsible meal sections
  • Bottom sheet for recipe selection
  • Floating action button for quick add

5. Implementation Steps

Phase 1: Database & Backend

  1. Create database migration for meal_plans_v1 table
  2. Add database queries in /backend/database/queries.ts
    • Support batch operations for multiple recipes
  3. Create /backend/routes/meal-plans.ts with CRUD operations
  4. Add route to main backend index

Phase 2: Calendar Components

  1. Create MealPlanCalendar.tsx with basic month view
  2. Implement day selection and navigation
  3. Add meal slot display with recipe counts
  4. Mobile-responsive CSS Grid layout

Phase 3: Recipe Assignment

  1. Create MealPlanSidebar.tsx for recipe selection
  2. Implement click-to-add functionality
  3. Add DayMealPlan.tsx for detailed day view
  4. Support adding multiple recipes to same meal

Phase 4: Shopping List Integration

  1. Add calendar selection mode (multi-select days)
  2. Create "Generate Shopping List from Calendar" flow
  3. Integrate with existing ShoppingListCreator
  4. Show which recipes come from which days
  5. Handle duplicate recipes across days

Phase 5: Mobile Responsive Design

  • Use CSS Grid with grid-template-columns: repeat(auto-fit, minmax(...))
  • Implement touch gestures for mobile navigation
  • Create responsive breakpoints (mobile < 768px, tablet < 1024px)
  • Bottom sheet pattern for recipe selection on mobile
  • Ensure all interactions work with touch (no hover-only features)

Types to Add (shared/types.ts)

export interface MealPlan { id?: number; recipeId: number; recipe?: Recipe; // Populated on fetch date: string; // YYYY-MM-DD mealType: 'breakfast' | 'lunch' | 'dinner' | 'snack'; notes?: string; createdAt?: string; updatedAt?: string; } export interface CalendarDay { date: string; meals: { breakfast: MealPlan[]; // Array to support multiple recipes lunch: MealPlan[]; dinner: MealPlan[]; snack: MealPlan[]; }; isSelected?: boolean; totalRecipeCount: number; } export interface MealPlanDateRange { startDate: string; endDate: string; }

Navigation Flow

  1. Main nav: Add "Meal Calendar" option
  2. From Calendar: "Create Shopping List" → Select days → Generate list
  3. From Shopping List Creator: Tab for "From Calendar" vs "From Recipes"
  4. Quick actions: "Plan this recipe" button on recipe view

Mobile-First Considerations

  • Touch targets: Minimum 44x44px for all interactive elements
  • Swipe navigation: Between months and weeks
  • Responsive grid: Days stack on small screens
  • Progressive disclosure: Expand/collapse meal details
  • Offline support: Cache meal plans locally
  • Performance: Lazy load recipes, virtualize long lists

Benefits

  • Visual meal planning interface
  • Support for meal prep (multiple recipes per meal)
  • Efficient shopping for multiple days
  • Flexibility for varying meal sizes/occasions
  • Mobile-friendly for grocery shopping
FeaturesVersion controlCode intelligenceCLI
Use cases
TeamsAI agentsSlackGTM
ExploreDocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.