Skip to content

Mat-26-dot/Portfolio-Project

Repository files navigation

๐Ÿณ Chaos Cooking

A food wastage reduction app that helps users transform leftover ingredients into delicious recipes.

Chaos Cooking empowers users to reduce food waste by discovering creative recipes using ingredients they already have, before they go bad. Perfect for students, busy professionals, and content creators who want to save money, reduce waste, and gamify their cooking experience.


๐Ÿ“‹ Table of Contents


โœจ Features

Core Functionality

  • Recipe Discovery: Browse community-uploaded recipes designed to use up leftover ingredients
  • Smart Ingredient Matching: Search recipes based on what you have in your fridge
  • Upload Your Own Recipes: Share your leftover-rescue recipes with the community
  • Duplicate Prevention: Smart validation ensures users don't accidentally upload the same recipe twice
  • Recipe History Tracking: Track which recipes you've viewed, cooked, favorited, or rated

User Personas

Our app is designed for:

  • ๐Ÿ‘ฉโ€๐ŸŽจ Content Creators (like Chloe) - Create aesthetic cooking content while reducing waste
  • ๐Ÿ’ผ Busy Professionals (like Marcus) - Quick 15-minute meals using leftovers after long workdays
  • ๐ŸŽ“ Students (like Emma) - Budget-friendly recipes that save money and reduce dorm food waste
image

System Architecture - Upload Recipe Flow

Our application follows a three-tier architecture ensuring clean separation of concerns:

Screenshot 2025-10-01 103200

๐ŸŽฏ How the UML Sequence Diagram Works ๐ŸŽจ Presentation Layer (Frontend)

User clicks "Upload Recipe" button Recipe form displays input fields User fills in recipe details (title, description, instructions, ingredients) Form submits data to Business Logic Layer


This design choice makes sense because:

  • Recipe sharing - Multiple users can contribute their unique takes on popular dishes
  • Prevents accidents - Users won't accidentally duplicate their own submissions
  • Community diversity - Encourages variety in the recipe database
  • Data integrity - Maintains clean user-specific recipe collections
Screenshot 2025-10-02 101408

This separation means:

  • Frontend developers can work independently from backend
  • Business logic can be tested without UI or database
  • Each layer can be updated without affecting others
  • System is scalable and maintainable

๐Ÿ›  Tech Stack

Frontend

  • HTML5, CSS3, JavaScript, React, Node.js
  • Responsive design for a we-based app MVP fit for demo day

Backend

  • Python Flask - Lightweight web framework
  • PostgreSQL - Relational database for recipes, ingredients, and user data
  • psycopg2 - PostgreSQL adapter for Python
  • Flask-CORS - Cross-Origin Resource Sharing support

Database

  • PostgreSQL 14+
  • Pre-populated with sample recipes and ingredients

๐Ÿ—„ Database Schema

Tables

users

  • Stores user account information (username, email, password_hash, name)
  • Tracks account creation and updates

ingredients

  • Library of common leftover ingredients categorized by type
  • Includes nutritional information (calories per unit)
  • Categories: leftover_protein, leftover_vegetable, leftover_fruit, leftover_starch, pantry

recipes

  • User-created recipes with instructions, prep/cook time, and difficulty
  • Each recipe linked to its creator via created_by foreign key
  • Includes metadata like servings, prep time, cook time

recipe_ingredients (Junction Table)

  • Links recipes to their required ingredients
  • Stores quantity, unit, and optional notes for each ingredient

recipe_history

  • Tracks user interactions with recipes
  • Actions: 'viewed', 'cooked', 'favorited', 'rated'
  • Enables popularity tracking and personalized recommendations

Key Database Features

  • User-Specific Duplicate Prevention: Users cannot upload multiple recipes with the same title
  • Shared Recipe Library: Multiple users can save and interact with the same community recipes
  • Cascade Deletion: Removing a recipe automatically removes its ingredient associations

๐Ÿ“ Project Structure

Chaos_cooking_backend/
โ”œโ”€โ”€ app.py                    # Main Flask application
โ”œโ”€โ”€ db.py                     # Database connection configuration
โ”œโ”€โ”€ .env                      # Environment variables (not in git)
โ”œโ”€โ”€ requirements.txt          # Python dependencies
โ”œโ”€โ”€ routes/
โ”‚   โ”œโ”€โ”€ recipes.py           # Recipe-related endpoints
โ”‚   โ””โ”€โ”€ ingredients.py       # Ingredient-related endpoints
โ”œโ”€โ”€ Recipes_with_sample_data.sql  # Database schema and sample data
โ””โ”€โ”€ README.md                # This file

๐Ÿš€ Getting Started

Prerequisites

  • Python 3.8+
  • PostgreSQL 14+
  • pip (Python package manager)

Installation

  1. Clone the repository
git clone <repository-url>
cd Chaos_cooking_backend
  1. Set up Python virtual environment (recommended)
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies
pip install -r requirements.txt
  1. Set up PostgreSQL database
# Create database
createdb chaos_cooking

# Run SQL script to create tables and insert sample data
psql -d chaos_cooking -f Recipes_with_sample_data.sql
  1. Configure environment variables

Create a .env file in the root directory:

DB_USER=your_postgres_username
DB_HOST=localhost
DB_NAME=chaos_cooking
DB_PASSWORD=your_postgres_password
DB_PORT=5432
PORT=5000
  1. Run the application
python app.py

The server will start on http://localhost:5000

Testing the API

Visit these endpoints in your browser:

  • http://localhost:5000/ - Health check
  • http://localhost:5000/api/recipes - Get all recipes
  • http://localhost:5000/api/ingredients - Get all ingredients

๐Ÿ“ก API Endpoints

Recipes

Method Endpoint Description
GET /api/recipes Get all recipes
GET /api/recipes/<id> Get single recipe with ingredients
POST /api/recipes Upload new recipe (with duplicate check)

Ingredients

Method Endpoint Description
GET /api/ingredients Get all ingredients
GET /api/ingredients/category/<category> Get ingredients by category
GET /api/ingredients/categories Get all available categories

Recipe History

Method Endpoint Description
POST /api/ingredients/recipe-history Record user action (viewed, cooked, favorited, rated)
GET /api/ingredients/recipe-history/user/<user_id> Get user's recipe history

Example API Request

Create a new recipe:

POST /api/recipes
Content-Type: application/json

{
  "title": "Leftover Pasta Bake",
  "description": "Transform yesterday's pasta into cheesy goodness",
  "instructions": "1. Preheat oven to 350ยฐF...",
  "prep_time": 10,
  "cook_time": 20,
  "servings": 4,
  "difficulty_level": "easy",
  "created_by": 1,
  "ingredients": [
    {"ingredient_id": 22, "quantity": 200, "unit": "gram"},
    {"ingredient_id": 28, "quantity": 100, "unit": "gram"}
  ]
}

๐ŸŽฏ Key Features Implementation

Upload Recipe with Duplicate Check (UML Flow)

Our recipe upload follows a three-tier architecture:

  1. Presentation Layer: User submits recipe form
  2. Business Logic Layer:
    • Validates required fields
    • Checks if user already has a recipe with the same title
    • If duplicate exists โ†’ returns 409 error
    • If valid โ†’ proceeds to save
  3. Persistence Layer: Saves recipe and ingredient associations to database

This ensures users don't accidentally submit the same recipe multiple times while allowing different users to share recipes with the same name.


๐Ÿ‘ฅ Team

Backend Team

  • Mathijs: Recipe endpoints and business logic
  • Isaac: Ingredient endpoints and recipe history tracking

Frontend Team

  • Alex: User interface and recipe display
  • Andrew: Search functionality and user interactions

๐Ÿ”ฎ Future Enhancements

  • User authentication and authorization
  • Recipe rating and review system
  • Advanced search with multiple ingredient filters
  • Expiration date tracking for ingredients
  • Meal planning calendar
  • Nutritional information calculator
  • Social sharing features
  • Mobile app version

๐Ÿ“ License

This project is part of the Holberton school, Australia curriculum.


๐Ÿค Contributing

This is a student project. If you're part of the team:

  1. Create a feature branch
  2. Make your changes
  3. Test thoroughly
  4. Submit a pull request

Happy Cooking! Let's reduce food waste together! ๐ŸŒฑ

Your developers:

  • Mathijs
  • Alex
  • Isaac
  • Andrew

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors