Skip to content

josephhilby/lunch_and_learn

Repository files navigation

README


Table of Contents
  1. About The Project
  2. Getting Started
  3. API Endpoints
  4. Roadmap
  5. Built With
  6. Contact
  7. Contributing
  8. Acknowledgments
  9. License

About The Project

Board with your recipe book? Want to step out of your comfort zone and taste something new? This is for you.

Lunch and Learn is an app that will let you find your new favorite recipe by country of origin. After you are done cooking Lunch and Learn will look up some edutainment to watch while you enjoy your new dish.

Sign up and get started!

(back to top)

Getting Started

Web Usage [Work In Progress]

This is a Ruby on Rails web application that was made for the chrome browser and for use with Google OAuth. You will need the following:

  • Google Chrome
  • Google account

To get started, follow the link below and register with your Google account. Once you are registered you will be able to:

  • Search for recipes by country OR have Lunch and Learn select a country for you
  • Play an educational video on that select county.
  • Enjoy a photo album of life in that country.

Local Installation

This application was made with the following:1

  • ruby 2.7.4
  • rails 5.2.8

To install and run on your personal computer you will need to do the following:

  1. Get a free API Key for EDAMAM Recipe at https://developer.edamam.com/edamam-recipe-api.

  2. Get a free API Key for YouTube at https://developers.google.com/youtube/v3/getting-started.

  3. Get a free API Key for Pexels at https://www.pexels.com/api/.

  4. Fork and clone the repo to your local machine.

  5. Install gems and create database.

    $ bundle install
    $ rails db:{drop,create,migrate}
    $ bundle exec figaro install

`schema.rb` DB Diagram
ActiveRecord::Schema.define(version: 2023_01_15_233149) do
  enable_extension "plpgsql"

  create_table "favorites", force: :cascade do |t|
    t.string "country"
    t.string "recipe_link"
    t.string "recipe_title"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
  end

  create_table "users", force: :cascade do |t|
    t.string "name"
    t.string "email"
    t.string "api_key"
    t.string "password_digest"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
  end

  create_table "users_favorites", force: :cascade do |t|
    t.bigint "user_id"
    t.bigint "favorite_id"
    t.index ["favorite_id"], name: "index_users_favorites_...
    t.index ["user_id"], name: "index_users_favorites_on_us...
  end

  add_foreign_key "users_favorites", "favorites"
  add_foreign_key "users_favorites", "users"
end
Database
  1. Enter your API in the config/application.yml file.

    edam_app_id: <YOUR APP ID HERE>
    edam_app_key: <YOUR KEY HERE>
    yt_key: <YOUR KEY HERE>
    pexels_token: <YOUR TOKEN HERE>
  2. Start your rails server in the root directory.

    $ rails s
  3. Now all you need to do is make a request to one of the endpoints.2 Documentation for all API Endpoints can be found below. OR if you prefer to run the simple front-end for this API service, follow this_link.

(back to top)

API Endpoints

GET3

localhost:5001/api/v1/recipes

GET /api/v1/recipes?country=thai

Get a list of recipes from a random country (if no params are passed) OR by selected country, through params.

Parameters

Name Required Type Description
country no string The country you want to get recipes from.

Response

{
    "data": [
        {
            "id": null,
            "type": "recipe",
            "attributes": {
                "title": "Andy Ricker's Naam Cheuam Naam Taan Piip (Palm Sugar Simple Syrup)",
                "url": "https://www.seriouseats.com/recipes/2013/11/andy-rickers-naam-cheuam-naam-taan-piip-palm-sugar-simple-syrup.html",
                "country": "Thailand",
                "image": "https://edamam-product-images.s3.amazonaws.com..."
            }
        },
        {
            "id": null,
            "type": "recipe",
            "attributes": {
                "title": "Sriracha",
                "url": "http://www.jamieoliver.com/recipes/vegetables-recipes/sriracha/",
                "country": "Thailand",
                "image": "https://edamam-product-images.s3.amazonaws.com/."
            }
        },
        {...},
        {...},
        {...},
        {etc},
    ]
}
localhost:5001/api/v1/learning_resources

GET /api/v1/learning_resources?country=laos

Get a list of learning resources from a random country (if no params are passed) OR by selected country, through params.

Parameters

Name Required Type Description
country no string The country you want to get learning resources from.

Response

{
   "data": {
       "id": null,
       "type": "learning_resource",
       "attributes": {
           "country": "Laos",
           "video": {
               "title": "A Super Quick History of Laos",
               "youtube_video_id": "uw8hjVqxMXw"
           },
           "images": [
               {
                   "alt_tag": "standing statue and temples landmark during daytime",
                   "url": "https://images.unsplash.com/photo-1528181304800-259b08848526?ixid=MnwzNzg2NzV8MHwxfHNlYXJjaHwxfHx0aGFpbGFuZHxlbnwwfHx8fDE2Njc4Njk1NTA&ixlib=rb-4.0.3"
               },
               {
                   "alt_tag": "five brown wooden boats",
                   "url": "https://images.unsplash.com/photo-1552465011-b4e21bf6e79a?ixid=MnwzNzg2NzV8MHwxfHNlYXJjaHwyfHx0aGFpbGFuZHxlbnwwfHx8fDE2Njc4Njk1NTA&ixlib=rb-4.0.3"
               },
               {
                   "alt_tag": "orange temples during daytime",
                   "url": "https://images.unsplash.com/photo-1563492065599-3520f775eeed?ixid=MnwzNzg2NzV8MHwxfHNlYXJjaHwzfHx0aGFpbGFuZHxlbnwwfHx8fDE2Njc4Njk1NTA&ixlib=rb-4.0.3"
               },
               {...},
               {...},
               {...},
               {etc},
             ]
       }
   }
}
localhost:5001/api/v1/favorites

GET /api/v1/favorites?api_key=jgn983hy48thw9begh98h4539h4

Get a list of your user's favorite recipes.

Parameters

Name Required Type Description
api_key yes string A unique key created after a successful POST /api/v1/users used to identify user requests

Response

{
   "data": [
       {
           "id": "1",
           "type": "favorite",
           "attributes": {
               "recipe_title": "Recipe: Egyptian Tomato Soup",
               "recipe_link": "http://www.thekitchn.com/recipe-egyptian-tomato-soup-weeknight....",
               "country": "Egypt",
               "created_at": "2022-11-02T02:17:54.111Z"
           }
       },
       {
           "id": "2",
           "type": "favorite",
           "attributes": {
               "recipe_title": "Crab Fried Rice (Khaao Pad Bpu)",
               "recipe_link": "https://www.tastingtable.com/.....",
               "country": "Thailand",
               "created_at": "2022-11-07T03:44:08.917Z"
           }
       }
   ]
}

POST

localhost:5001/api/v1/users

POST /api/v1/users

Create a new user.

Parameters (JSON payload in request body)

{
 "name": "Athena Dao",
 "email": "athenadao@bestgirlever.com",
 "password": "supersecretpassword",
 "password_confirmation": "supersecretpassword"
}

Response

{
 "data": {
   "type": "user",
   "id": "1",
   "attributes": {
     "name": "Athena Dao",
     "email": "athenadao@bestgirlever.com",
     "api_key": "jgn983hy48thw9begh98h4539h4"
   }
 }
}
localhost:5001/api/v1/sessions

POST /api/v1/sessions

Get user info for authentication use on front-end app.

Parameters (JSON payload in request body)

{
 "email": "athenadao@bestgirlever.com",
 "password": "supersecretpassword"
}

Response

{
 "data": {
   "type": "user",
   "id": "1",
   "attributes": {
     "name": "Athena Dao",
     "email": "athenadao@bestgirlever.com",
     "api_key": "jgn983hy48thw9begh98h4539h4"
   }
 }
}
localhost:5001/api/v1/favorites

POST /api/v1/favorites

Create a new favorite recipe for the select user.

Parameters (JSON payload in request body)

{
   "api_key": "jgn983hy48thw9begh98h4539h4",
   "country": "Thailand",
   "recipe_link": "https://www.tastingtable.com/.....",
   "recipe_title": "Crab Fried Rice (Khaao Pad Bpu)"
}

Response

{
   "success": "Favorite added successfully"
}

DELETE

localhost:5001/api/v1/favorites

DELETE /api/v1/favorites

Delete a selected favorite recipe for the select user.

Parameters (JSON payload in request body)

{
   "api_key": "jgn983hy48thw9begh98h4539h4",
   "country": "Thailand",
   "recipe_link": "https://www.tastingtable.com/.....",
   "recipe_title": "Crab Fried Rice (Khaao Pad Bpu)"
}

Response

{
   "success": "Favorite removed successfully"
}

(back to top)

Roadmap

Back-end Main Goal(s)

  • GET /recipes Endpoint
  • GET /learning_resources Endpoint
  • POST /users Endpoint
  • POST /sessions Endpoint
  • POST /favorites Endpoint
  • GET /favorites Endpoint
  • DELETE /favorites Endpoint

Back-end Stretch Goals

  • Add prams check and error handeling
  • Implement basic authentication with bcrypt
  • Utilize Cashing OR Background Workers

Front and Back-end Super Stretch Goals

  • Update docs with Swagger
  • Move authentication from Bcrypt to Google OAuth
  • Deploy to Heroku

See the open issues for a full list of proposed features (and known issues).

Learning Goals

  • Expose an API that aggregates data from multiple external APIs
  • Expose an API that requires and authentication token
  • Expose an API for CRUD functionality
  • Determine completion criteria based on the needs of other developers
  • Test both API consumption and exposure, making use of at least one mocking tool (VCR, Webmock)

Evaluation Rubric

  1. Technical Presentation

    • Demo understanding of learning goals
    • Demo functionality with Postman and live demo
    • Discuss technical quality & organization of code
    • Discuss test coverage, happy path, sad path, and edge cases
  2. Feature Delivery

    • Complete all MVP features (Roadmap: Main Goals) as directed here
    • Complete 3 of 4 stretch goals
  3. Technical Quality

    • Demonstrate good use of abstraction and encapsulation in Facades and Services
    • Demonstrate good use of Model, View, Controller (MVC) design principles
  4. Testing

    • Minimum of 90% testing coverage
    • Include all 'happy path' and 'sad path' testing
    • Include use of VCR and/or Webmock
    • Testing checks for presence of data in payload and data type

(back to top)

Built With

Lunch and Learn is a Ruby on Rails web application hosted on Heroku.


Tech-Stack

(back to top)

Contact

Joseph Hilby Naomi Youcum
GitHub
LinkedIn
GitHub
LinkedIn

(back to top)

Contributing

Do you have a better & cooler way of doing what we did? Your contribution would be greatly appreciated.

Please fork the repo, create your branch, and create a pull request. You can also simply open an issue with the tag "enhancement".

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Thanks again!

(back to top)

Acknowledgments

(back to top)

License

Distributed under the MIT License.

(back to top)

Footnotes

  1. Note: Information on installing Ruby 2.7.4 and Rails 5.2.8 can be found here

  2. Note: The port is crrrently set to 5001. To change the port #, go to config/puma.rb and enter your desired port #: port ENV.fetch("PORT") { <YOUR NUMBER HERE> }. You can also elect to un-comment the Background Workers Job CleanDbJob (favorites_controller: line 40). Before you do this, you will need to set up a Redis server and Sidekiq adapter. Instructions to this can be found here. Troubleshooting Redis and Mac M1 issues can be found here.

  3. Note: The :country section in the JSON Response refers to the search criteria. If no video is found on that country, a video on a related country (by culture or geographic area) will instead be returned.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published