Contributors Forks Stargazers Issues


Logo

Pantry Wizard

An application that allows a user to create meal plans based on their Dietary Restrictions, Intolerances, and Cusine Preferences.
This is the backend service of the application.
Report Bug · Request Feature · Front End Repo

Table of Contents
  1. About The Project
  2. Getting Started
  3. Available Endpoints
  4. Goals

About The Project


At Pantry Wizard, we believe that everyone deserves access to healthy, delicious food. We're on a mission to reduce food waste and alleviate food insecurity by providing personalized meal planning that simplifies the decision-making process and empowers individuals to take control of their nutrition. Our app is designed to meet the needs of neurodivergent individuals, picky eaters, and anyone facing time or resource constraints, so they can focus on what really matters in their lives. Join us in making a positive impact on our communities, one meal at a time.

(back to top)

Built With:

  • Ruby 3.1.1
  • Rails 7.0.4
  • Postgresql
  • Heroku

(back to top)

Getting Started

This is a Ruby on Rails application which establishes API endpoints to be called in the pantry_wizard_fe repository. To run the application locally, both front-end and back-end repositories will need to be cloned and set up fully with required gems and environment variables.


Installation

  1. Clone the repo:

    git clone git@github.com:pantry-wizard/pantry_wizard_be.git
  2. Install gems:

    bundle install
  3. To establish the database, run:

    rails db:create
  4. Since this is the back-end repository, a database migration is also necessary, run:

    rails db:migrate

Inspect the /db/schema.rb and compare to the 'Schema' section below to ensure this migration has been done successfully.

(back to top)


Testing with RSpec

Once pantry_wizard_be is correctly installed, run tests locally to ensure the repository works as intended.


To test the entire RSpec suite, run:

bundle exec rspec

All tests should be passing if the installation was successful.

If any tests are not passing, please report which tests are not passing Here. We will issue an update/fix as soon as possible!

(back to top)


Available Endpoints

  • This API can be called locally using a program like Postman.

  • Note: Necessary parameters marked with {}


User Endpoints


### 1. Create a New User

Note: pass name, google_id, & email in request body

POST '/api/v1/users'

Response:

{
  "data":
  {
    "id":"USER_ID",
    "type":"user",
    "attributes":
    {
      "name":"USER_NAME",
      "email":"USER_EMAIL",
      "google_id":"USER_GOOGLE_ID"
    }
  }
}

2. Return All Users


GET '/api/v1/users'

Response:

{
    "data": [
        {
            "id": "USER_ID",
            "type": "user",
            "attributes": {
                "email": "EMAIL",
                "name": "NAME",
                "google_id": "GOOGLE_ID",
                "id": "USER_ID",
                "intolerances": "INTOLERANCES",
                "likes": "LIKES",
                "dislikes": "DISLIKES",
                "dietary_restrictions": "DIETARY RESTRICTIONS"
            }
        }
    ]
}

3. Return a Specific User


GET 'api/v1/users/{google_id}

Response:

{
    "data": [
        {
            "id": "USER_ID",
            "type": "user",
            "attributes": {
                "email": "EMAIL",
                "name": "NAME",
                "google_id": "GOOGLE_ID",
                "id": "USER_ID",
                "intolerances": "INTOLERANCES",
                "likes": "LIKES",
                "dislikes": "DISLIKES",
                "dietary_restrictions": "DIETARY RESTRICTIONS"
            }
        }
    ]
}

4. Update a User


Note: pass updated attributes in request body

PATCH 'api/v1/users/{google_id}

Response:

{
    "data": [
        {
            "id": "USER_ID",
            "type": "user",
            "attributes": {
                "email": "EMAIL",
                "name": "NAME",
                "google_id": "GOOGLE_ID",
                "id": "USER_ID",
                "intolerances": "INTOLERANCES",
                "likes": "LIKES",
                "dislikes": "DISLIKES",
                "dietary_restrictions": "DIETARY RESTRICTIONS"
            }
        }
    ]
}

5. Delete a User


DELETE 'api/v1/users/{google_id}'


Day Plan Endpoints


### 1. Get Day Plans for a User
GET 'api/vi/users/{google_id}/day_plans

Response:

{
    "data": [
        {
            "id": "ID",
            "type": "day_plan",
            "attributes": {
                "user_id": "USER_ID",
                "date": "DATE",
                "recipes": [
                    {
                        "id": "RECIPE_ID",
                        "spoonacular_id": "SPOONACULAR_ID",
                        "name": "RECIPE_NAME",
                        "ingredients": "RECIPE INGREDIENTS",
                        "instructions": "RECIPE INSTRUCTIONS",
                        "image": "RECIPE IMAGE",
                        "created_at": "CREATED_AT",
                        "updated_at": "UPDATED_AT"
                    }
                ]
            }
        }
    ]
}

2. Get a Specific Day Plan for a User


GET 'api/v1/users/{user_id}/day_plans/{day_plan_id}'

Response:

{
    "data": [
        {
            "id": "ID",
            "type": "day_plan",
            "attributes": {
                "user_id": "USER_ID",
                "date": "DATE",
                "recipes": [
                    {
                        "id": "RECIPE_ID",
                        "spoonacular_id": "SPOONACULAR_ID",
                        "name": "RECIPE_NAME",
                        "ingredients": "RECIPE INGREDIENTS",
                        "instructions": "RECIPE INSTRUCTIONS",
                        "image": "RECIPE IMAGE",
                        "created_at": "CREATED_AT",
                        "updated_at": "UPDATED_AT"
                    }
                ]
            }
        }
    ]
}

3. Create a Day Plan for a User


Post '/api/v1/users/{user_id}/day_plans

Response:

{
    "data": [
        {
            "id": "ID",
            "type": "day_plan",
            "attributes": {
                "user_id": "USER_ID",
                "date": "DATE",
                "recipes": [
                    {
                        "id": "RECIPE_ID",
                        "spoonacular_id": "SPOONACULAR_ID",
                        "name": "RECIPE_NAME",
                        "ingredients": "RECIPE INGREDIENTS",
                        "instructions": "RECIPE INSTRUCTIONS",
                        "image": "RECIPE IMAGE",
                        "created_at": "CREATED_AT",
                        "updated_at": "UPDATED_AT"
                    }
                ]
            }
        }
    ]
}

4. Update a Day Plan for a User


Note: pass updated attributes in request body

PATCH '/api/v1/users/{user_id}/day_plans/{day_plan_id}'

Response:

{
    "data": [
        {
            "id": "ID",
            "type": "day_plan",
            "attributes": {
                "user_id": "USER_ID",
                "date": "DATE",
                "recipes": [
                    {
                        "id": "RECIPE_ID",
                        "spoonacular_id": "SPOONACULAR_ID",
                        "name": "RECIPE_NAME",
                        "ingredients": "RECIPE INGREDIENTS",
                        "instructions": "RECIPE INSTRUCTIONS",
                        "image": "RECIPE IMAGE",
                        "created_at": "CREATED_AT",
                        "updated_at": "UPDATED_AT"
                    }
                ]
            }
        }
    ]
}

5. Delete a Day Plan for a User


DELETE '/api/v1/users/{user_id}/day_plans/{day_plan_id}


Recipe End Points


1. Get All Recipes


GET '/api/v1/recipes

Response:

{
    "data": [
        {
            "id": "1",
            "type": "recipe",
            "attributes": {
                "spoonacular_id": "SPOONACULAR_ID",
                "name": "RECIPE_NAME",
                "ingredients": "RECIPE_INGREDIENTS",
                "instructions": "RECIPE_INSTRUCTIONS",
                "image": "RECIPE_IMAGE"
        }
    ]
}

2. Create a Recipe


Post '/api/v1/recipes'

Response:

{
    "data": [
        {
            "id": "1",
            "type": "recipe",
            "attributes": {
                "spoonacular_id": "SPOONACULAR_ID",
                "name": "RECIPE_NAME",
                "ingredients": "RECIPE_INGREDIENTS",
                "instructions": "RECIPE_INSTRUCTIONS",
                "image": "RECIPE_IMAGE"
        }
    ]
}

3. Add a Recipe to a Day Plan


Note: You must pass in a day plan id and recipe id as params(params: { day_plan_id: @day_plan.id, recipe_id: @recipe_1.id })

Post '/api/v1/day_plan_recipes

Response:

{
    "data": {
        "id": "6",
        "type": "day_plan_recipe",
        "attributes": {
            "day_plan_id": "DAY_PLAN_ID"
            "recipe_id": "RECIPE_ID"
        }
    }
}

(back to top)

Goals

Pantry Wizard was crafted to satisfy the requirements for The Turing Back-End Mod 3 group project, Consultancy.

See the official project requirements here.


Learning Goals

  • Impliment Google OAuth so users can log in easily.
  • Impliment CircleCI for continuous integration.
  • Utilize Service Oriented Architecture by creating an API with Rails.
  • Interact with two unique external API's.
  • Deploy both the frontend and backend on Heroku.

(back to top)

Future Goals

  • Add google calendar so meals can be scheduled in advance.
  • Integrating Swagger.
  • Integrating HoneyBadger for observability of backend queries.
  • Integrating Swagger to make endpoint testing easier.

(back to top)


Database Schema


Contributors

Chris Crane Conner Van Loan Caleb Thomas Brian Hayes Dawson Timmons
GitHub
LinkedIn
GitHub
LinkedIn
GitHub
LinkedIn
GitHub
LinkedIn
GitHub
LinkedIn