Skip to content

Minbeeus/CookingNotebookWebApp

Repository files navigation

Cooking Notebook WebApp

A comprehensive meal planning web application built with ASP.NET Core that helps users plan meals, manage recipes, and generate shopping lists.

Quick Start

Requirements

  • .NET 9.0+ SDK
  • SQL Server
  • Visual Studio 2022 or VS Code

Setup

# Clone the repository
git clone <repository-url>
cd CookingNotebookWebApp

# Build the project
dotnet build

# Update the database
dotnet ef database update

# Run the application
dotnet run

The app will be available at http://localhost:5000

Features

🧑‍🍳 Meal Planning System

  • Generate meal plans for 1-30 days
  • Select meal times (breakfast, lunch, dinner, snacks)
  • Add dietary restrictions and preferences
  • Intelligent recipe selection based on:
    • User favorites
    • Recipe ratings
    • Review count
    • Random variation

🛒 Shopping List Generation

  • Automatic ingredient aggregation
  • Ingredient quantities scaled to number of people
  • Grouped by ingredient category
  • Interactive checklist
  • Print and email options

📚 Recipe Management

  • Browse and search recipes
  • View detailed recipe information
  • Rate and review recipes
  • Save favorites
  • Filter by cuisine type, cooking method, and time

👥 User Management

  • User registration and login
  • Personal profile management
  • Change password
  • Favorites management

Project Structure

CookingNotebookWebApp/
├── Controllers/           # API and view controllers
├── Services/             # Business logic
├── Models/               # Data models
├── Views/                # Razor views
├── Data/                 # Database context and migrations
├── wwwroot/              # Static files (CSS, JS, images)
├── Helpers/              # Utility functions
└── Program.cs            # Application startup

Meal Planning Algorithm

The algorithm uses a 6-step process:

  1. Initialize: Load user favorites and prepare tracking list
  2. Loop: Iterate through each day and meal time
  3. Build Candidate Pool: Filter recipes by meal time and restrictions
  4. Score Candidates:
    • Favorite: +10 points
    • Rating 4.5+: +5 points; 4.0+: +3 points
    • 20+ reviews: +2 points
    • Random: 0-2 points
  5. Select: Choose recipe with highest score
  6. Generate Shopping List: Calculate ingredient quantities based on number of people

API Endpoints

Health Check

GET /api/mealplanning/health

Get Meal Times

GET /api/mealplanning/mealtimes

Generate Meal Plan

POST /api/mealplanning/generate
Content-Type: application/json

{
  "userId": 1,
  "numDays": 7,
  "numPeople": 2,
  "mealTimeIds": [1, 2, 3],
  "restrictions": ["Vegetarian"]
}

Run Tests

POST /api/mealplanning/test

Configuration

Database Connection

Edit appsettings.json:

{
  "ConnectionStrings": {
    "DefaultConnection": "Server=YOUR_SERVER;Database=CookingNotebook;Trusted_Connection=true;TrustServerCertificate=true;"
  }
}

User ID

In Views/MealPlanning/Index.cshtml, update the USER_ID constant (currently hardcoded as 1).

Database Schema

Required tables:

  • Users - User accounts
  • Recipe - Recipe information
  • MealTime - Meal types (breakfast, lunch, dinner, snacks)
  • RecipeIngredient - Ingredients in recipes
  • Ingredient - Ingredient catalog
  • Favorites - User favorites
  • Review - Recipe reviews

Testing

Run the included test file:

dotnet test

Or test via API:

curl -X POST http://localhost:5000/api/mealplanning/test

Performance

  • Page load: < 2 seconds
  • API response: 2-5 seconds
  • Total time from request to result: 4-7 seconds

Security

  • ✓ Server-side input validation
  • ✓ Parameterized queries (no SQL injection)
  • ✓ Read-only operations
  • ✓ Cookie-based authentication
  • ✓ CORS policy configured

Design System

Colors

  • Primary: #f28c38 (Orange)
  • Text: #5a3210 (Dark Brown)
  • Background: #fff8f3 (Light Cream)
  • Borders: #e3b289 (Light Orange)

Typography

  • Font: Segoe UI
  • H1: 2.2rem, weight 700
  • Body: 1em, weight 400

Responsive Breakpoints

  • Mobile: < 768px
  • Tablet: 768-1024px
  • Desktop: > 1024px

Troubleshooting

Database Issues

-- Check data
SELECT COUNT(*) FROM MealTimes;
SELECT COUNT(*) FROM Recipe;
SELECT COUNT(*) FROM RecipeIngredient;

-- Reset database
-- dotnet ef database drop
-- dotnet ef database update

Common Problems

Issue Solution
500 Server Error Check database connection string
CSS not loading Clear browser cache (Ctrl+Shift+R)
No recipes found Verify database has recipe data
CORS error Check CORS policy in Program.cs

Development

Technologies

  • Framework: ASP.NET Core 9.0
  • Database: Entity Framework Core with SQL Server
  • Frontend: Razor Views, HTML, CSS, JavaScript
  • Authentication: Cookie-based with Google OAuth support

Key Dependencies

  • BCrypt.Net-Next (password hashing)
  • Google.Apis.Auth (OAuth)
  • Entity Framework Core

Status

🚀 Production Ready

  • ✅ Meal planning algorithm
  • ✅ API endpoints
  • ✅ Responsive UI
  • ✅ Database integration
  • ✅ Form validation
  • ✅ Error handling

Future Enhancements

  • Change recipe option in meal plan
  • Save favorite meal plans
  • Export to PDF / Email
  • Nutrition tracking
  • Allergen filtering
  • Cost optimization
  • Dark theme support

License

Academic Project - CookingNotebookWebApp


Last Updated: November 26, 2025
Version: 1.0.0
Framework: ASP.NET Core 9.0

About

Sổ tay nấu ăn - Đồ án liên ngành

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published