a140df35c5b7de388dfed12e427ffc793bf15dbb
Meal Planner for Elderly Care Homes
A digital meal ordering system for elderly care homes, built with Payload CMS 3.x and Next.js 15. This application digitizes the paper-based workflow where caregivers collect meal preferences from residents and kitchen staff prepare meals.
Features
- Multi-tenant architecture: Each care home operates as a separate tenant with isolated data
- Role-based access control: Super-admin, tenant admin, caregiver, and kitchen staff roles
- Meal order management: Support for breakfast, lunch, and dinner with customizable options
- Kitchen dashboard: Aggregated ingredient reports for meal preparation
- Tablet-friendly caregiver interface: Touch-optimized UI for creating meal orders
- Resident management: Track dietary requirements, aversions, and special notes
Tech Stack
- Next.js 15 - React framework with App Router
- Payload CMS 3.65 - Headless CMS with admin panel
- SQLite - Database (easily upgradeable to PostgreSQL)
- TypeScript - Type safety
- SCSS - Styling
Quick Start
Prerequisites
- Node.js 18+
- pnpm (recommended) or npm
Installation
# Clone the repository
git clone <repository-url>
cd meal-planner
# Install dependencies
pnpm install
# Copy environment variables
cp .env.example .env
# Start development server with seeding
SEED_DB=true pnpm dev
The application will be available at http://localhost:3000.
Default Users
The seed script creates the following users:
| Password | Role | Access | |
|---|---|---|---|
| admin@example.com | test | Super Admin | Full system access |
| caregiver@example.com | test | Caregiver | Create/view meal orders |
| kitchen@example.com | test | Kitchen | View orders, update status, reports |
Application Structure
URLs
/admin- Payload CMS admin panel/admin/kitchen-dashboard- Kitchen ingredient report dashboard/caregiver/login- Caregiver login page/caregiver/dashboard- Caregiver main dashboard/caregiver/orders/new- Create new meal order/caregiver/orders- View meal orders/caregiver/residents- View residents list
Data Model
Collections
Tenants (Care Homes)
name- Care home nameslug- URL-friendly identifierdomain- Optional custom domainaddress- Physical addressphone- Contact phone
Users
Global roles:
super-admin- Full system accessuser- Standard user (access based on tenant roles)
Tenant roles:
admin- Full access within tenantcaregiver- Create and manage meal orderskitchen- View orders, update status, generate reports
Residents
name- Full nameroom- Room numbertable- Table assignmentstation- Ward/stationhighCaloric- High caloric diet flagaversions- Food aversionsnotes- Additional notesactive- Active status
Meal Orders
Core fields:
resident- Reference to residentdate- Order datemealType- breakfast, lunch, or dinnerstatus- pending, preparing, or preparedcreatedBy- User who created the order
Conditional meal options (based on mealType):
- Breakfast: Bread types, spreads, beverages, additions
- Lunch: Portion size, soup, dessert, special preparations
- Dinner: Bread, spreads, soup, beverages, additions
Access Control Matrix
| Operation | Super Admin | Tenant Admin | Caregiver | Kitchen |
|---|---|---|---|---|
| Manage users | All | Own tenant | No | No |
| Manage tenants | All | Own tenant | No | No |
| View residents | All | Own tenant | Own tenant | Own tenant |
| Manage residents | All | Own tenant | No | No |
| Create orders | All | Own tenant | Own tenant | No |
| View orders | All | Own tenant | Own tenant | Own tenant |
| Update orders | All | Own tenant | Own pending only | Status only |
| Delete orders | All | Own tenant | No | No |
| Kitchen reports | All | Own tenant | No | Own tenant |
Kitchen Dashboard
The kitchen dashboard (/admin/kitchen-dashboard) provides:
- Date and meal type selection
- Aggregated ingredient counts for all orders
- Portion size breakdown (for lunch)
- Total order count
API Endpoint
GET /api/meal-orders/kitchen-report?date=YYYY-MM-DD&mealType=breakfast|lunch|dinner
Response:
{
"date": "2024-01-15",
"mealType": "breakfast",
"totalOrders": 45,
"ingredients": {
"breadRoll": 32,
"butter": 40,
"coffee": 38
},
"labels": {
"breadRoll": "Bread Roll (Brötchen)",
"butter": "Butter",
"coffee": "Coffee (Kaffee)"
}
}
Caregiver Interface
The tablet-optimized caregiver interface provides:
- Dashboard: Today's order statistics and quick actions
- New Order Flow:
- Step 1: Select date and meal type
- Step 2: Select resident
- Step 3: Configure meal options
- Step 4: Review and submit
- Orders List: Filter by date and meal type
- Residents List: Search and view dietary requirements
Development
Scripts
pnpm dev # Start development server
pnpm build # Build for production
pnpm start # Start production server
pnpm seed # Run database seed
pnpm generate:types # Generate TypeScript types
Database
The application uses SQLite by default (meal-planner.db). To migrate to PostgreSQL:
- Install the PostgreSQL adapter:
pnpm add @payloadcms/db-postgres - Update
payload.config.ts:import { postgresAdapter } from '@payloadcms/db-postgres' db: postgresAdapter({ pool: { connectionString: process.env.DATABASE_URI } }), - Set
DATABASE_URIin.env
Environment Variables
PAYLOAD_SECRET=your-secret-key-here
SEED_DB=true # Set to seed database on startup
Domain-Based Tenant Selection
For domain-based tenant routing, add entries to /etc/hosts:
127.0.0.1 sunny-meadows.localhost
Project Structure
src/
├── access/ # Access control utilities
├── app/
│ ├── (app)/ # Caregiver frontend
│ │ ├── caregiver/
│ │ │ ├── login/ # Login page
│ │ │ ├── dashboard/ # Dashboard
│ │ │ ├── orders/ # Orders list and create
│ │ │ └── residents/ # Residents list
│ │ └── index.scss # Frontend styles
│ └── (payload)/ # Payload admin
│ └── admin/views/ # Custom admin views
├── collections/
│ ├── Tenants/ # Care homes
│ ├── Users/ # Users with roles
│ ├── Residents/ # Resident information
│ └── MealOrders/ # Meal orders
├── utilities/ # Helper functions
├── payload.config.ts # Payload configuration
└── seed.ts # Database seeding
Seed Data
The seed script creates:
- 1 care home (Sunny Meadows Care Home)
- 3 users (admin, caregiver, kitchen)
- 8 residents with varied dietary requirements
- 24 meal orders across different dates and meal types
License
MIT
Description
Languages
TypeScript
95.7%
SCSS
1.7%
CSS
1.4%
JavaScript
0.6%
Dockerfile
0.4%
Other
0.2%