Skip to content

calforcal/be_zero_waste_kitchen

Repository files navigation

zero_waste_kitchen

Welcome!

At Zero Waste Kitchen we're here to combat the growing problem of food waste in the United States. American households generate an estimated 42 billion pounds of food waste each year. This is enough food to feed 21 million people each year.

The consequences of this waste not only has a direct impact on people but far reaching effects for the planet. 96% of this waste ends up in the landfill - resulting in roughly 12 Million Tons of CO2 emissions. That amount of emissions is equivalent to powering 1.5 million homes for a year, or driving a car 2.6 million miles.

Our app is aimed at helping people eliminate food waste in their homes by providing recipes based on ingredients that will soon spoil and contribute to food waste. We hope to inspire users to waste less, save more and have an increased awareness around their personal impact and ability to contribute by having a Zero Waste Kitchen.

Project Repos and Links

Repos

  1. Frontend Repository
  2. Backend Repository

Production Deployment

  1. Frontend Production
  2. Backend Production

Contributors

Repo Installation

In your terminal run the following commands to clone the repositories:

Frontend

 git clone [email protected]:calforcal/fe_zero_waste_kitchen.git

Backend

 git clone [email protected]:calforcal/be_zero_waste_kitchen.git

Installing the Gems Locally

 bundle install

Front API Keys Needed

Both of these keys will need to be requested from an Admin (see above)

  • GOOGLE_OAUTH_CLIENT_ID
  • GOOGLE_OAUTH_CLIENT_SECRET
  • ZWK_API_KEY

Backend API Keys Needed

Installing Figaro

Figaro Gem Docs

In your terminal run:

 bundle exec figaro install

In the new file config/application.yml

Post your keys as they are listed above in this file, for both frontend and backend.

Testing the Repositories

Start up BOTH Servers (Frontend / Backend) by running the following command in each terminal:

 rails s

To run the full test suite:

 bundle exec rspec

Databse Schema

Link to Virtual Design

Ingredients

t.string "name"
t.float "units"
t.string "unit_type"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false

Recipe Ingredients

t.bigint "recipe_id", null: false
t.bigint "ingredient_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["ingredient_id"], name: "index_recipe_ingredients_on_ingredient_id"
t.index ["recipe_id"], name: "index_recipe_ingredients_on_recipe_id"

Recipes

t.string "name"
t.string "instructions", default: [], array: true
t.string "image_url"
t.integer "cook_time"
t.boolean "public_status", default: true
t.string "source_name"
t.string "source_url"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.boolean "user_submitted"
t.string "api_id"

Saved Ingredients

t.bigint "user_id", null: false
t.string "ingredient_name"
t.string "unit_type"
t.float "units"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["user_id"], name: "index_saved_ingredients_on_user_id"

User Recipes

t.bigint "user_id", null: false
t.bigint "recipe_id", null: false
t.integer "num_stars"
t.boolean "cook_status"
t.boolean "saved_status"
t.boolean "is_owner"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["recipe_id"], name: "index_user_recipes_on_recipe_id"
t.index ["user_id"], name: "index_user_recipes_on_user_id"

Users

t.string "uid"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false

Foreign Keys

add_foreign_key "recipe_ingredients", "ingredients"
add_foreign_key "recipe_ingredients", "recipes"
add_foreign_key "saved_ingredients", "users"
add_foreign_key "user_recipes", "recipes"
add_foreign_key "user_recipes", "users"

ZWK JSON Contract

Fetch One User

GET '/api/v1/users/:id’

Example response of the User resource

{
  "data": {
    "id": "integer",
    "type": "string",
    "attributes": {
      "uid": "string",
      "name": "string",
      "email": "string",
      "stats": {
        "lions_saved": "integer",
        "recipes_cooked": "integer",
        "recipes_created": "integer"
      }
      "cooked_recipes": [
        {
          "name": "string",
          "api_id": "string",
          "id": "integer"
        }
      ]
      "created_recipes": [
        {
          "name": "string",
          "api_id": "string",
          "id": "integer"
        }
      ]
      "saved_recipes": [
        {
          "name": "string",
          "api_id": "string",
          "id": "integer"
        }
      ]
      "num_cooked_recipes": "integer",
      "num_created_recipes": "integer",
      "num_saved_recipes": "integer"
    }
  }
}

Create One User

POST '/api/v1/users’

Example of the body details to be provided when creating a user

{
  "uid": "string"
}

Create a Recipe

POST ‘/api/v1/user/:user_id/recipes’

Example of the body details to be provided when creating a recipe

{
  "name": "string",
  "instructions": "array",
  "image_url": "string",
  "cook_time": "string",
  "public_status": "boolean",
  "source_name": "string",
  "source_url": "string",
  "user_submitted": "boolean",
  "api_id": "string",
  "uid": "string",
  "ingredients": [
    {
      "name": "string",
      "units": "float",
      "unit_type": "string" 
    },
    {
      "name": "string",
      "units": "float",
      "unit_type": "string" 
    }
  ]
}

Create a Cooked Recipe (user_recipes)

POST ‘/api/v1/user/:user_id/recipes/:recipe_id’

Example of the body details to be provided when creating a cooked recipe

{
  "uid": "string",
  "recipe_id": "integer",
  "api_id": "string",
  "cook_status": "boolean"
}

Create Saved Ingredients (user_ingredients)

POST ‘/api/v1/user/:user_id/ingredients’

Example of the body details to be provided when creating a saved recipe

{
  "uid": "string",
  "ingredients: [
    {
      "ingredient_name": "string",
      "units": "float",
      "unit_type": "string" 
    }
  ]
}

Create a Saved Recipe (user_recipes)

POST ‘/api/v1/user/:user_id/recipes/:recipe_id’

Example of the body details to be provided when creating a saved recipe

{
  "uid": "integer",
  "recipe_id": "integer",
  "api_id": "string",
  "saved_status": "boolean"
}

Rate a Recipe (user_recipes)

POST ‘/api/v1/user/:user_id/recipes/:recipe_id’

Example of the body details to be provided when creating a saved recipe. (Ratings are 1-5)

{
  "uid": "string",
  "recipe_id": "integer",
  "api_id": "string",
  "num_stars": "integer"
}

Update a Cooked Recipe (user_recipes)

PATCH ‘/api/v1/user/:user_id/recipes/:recipe_id’

Example of the body details to be provided when updating (rating) a cooked recipe

{
  "uid": "string",
  "recipe_id": "integer",
  "api_id": "string",
  "cook_status": "boolean",
  "num_stars": "integer"
}

Update One User

PATCH '/api/v1/users/:id’

Example of the body details to be provided when updating a user

{
  "uid": "string",
  "name": "string",
  "email": "string"
}

Fetch One Saved Recipes

GET '/api/v1/recipes/:id'

Example response of a Recipes resource

{
  "id": "integer",
  "type": "string",
  "attributes": {
    "image_url": "string",
    "name": "string",
    "rating_from_api": "float",
    "cook_time": "integer",
    "public_status": "boolean",
    "ingredients": [
      {
        "name": "string",
        "units": "float",
        "unit_type": "string"
      },
      {
        "name": "string",
        "units": "float",
        "unit_type": "string"
      }
    ],
    "source_name": "string",
    "source_url": "string",
    "instructions": ["string", "string", ...]
  }
}

Update One Recipe

PATCH '/api/v1/user/:user_id/recipes/:recipe_id’

Example of the body details to be provided when updating a recipe

{
  "user_id": "integer",
  "recipe_id": "integer",
  "name": "string",
  "cook_time": "integer",
  "source_name": "string"
}

Delete One Recipe

DELETE '/api/v1/user/:user_id/recipes/:recipe_id’

Example of the body details to be provided when deleting a recipe

{
  "uid": "string",
  "recipe_id": "integer"
}

Fetch One Users Friends (chefs)

GET '/api/v1/users/:id/chefs’

Example response of the Users Chefs resource

{
  "data": [
  {
    "id": "string",
    "type": "string",
    "attributes": {
      "name": "string",
      "username": "string"
    },
  },
  {
    "id": "string",
    "type": "string",
    "attributes": {
      "name": "string",
      "username": "string"
    }
  }]
}

Fetch all ingredients

GET '/api/v1/ingredients'

Example response of the Ingredients resource

{
  "data": [
    {
      "name": "string"
    },
    {
      "name": "string"
    },
    {
      "name": "string"
    }
  ]
}

Fetch searched recipes --> by Name

GET ‘/api/v1/recipes/search?search=query%string’

Example of a response from the Search (by name) resource

{
  "data": [
    {
      "id": "string",
      "type": "string",
      "attributes": {
        "name": "string",
      }
    },
    {
      "id": "string",
      "type": "string",
      "attributes": {
        "name": "string",
      }
    }
  ]
}

Fetch searched recipes --> by Ingredients

GET ‘/api/v1/recipes/search?ingredients=query%string,+query’

Example of a response from the Search (by ingredients(s) ) resource

{
  "data": [
    {
      "id": "string",
      "type": "string",
      "attributes": {
        "name": "string",
      }
    },
    {
      "id": "string",
      "type": "string",
      "attributes": {
        "name": "string",
      }
    }
  ]
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •