Sergio-Azcona / lunch_and_learn_BE

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

alt text


Lunch and Learn Table of Contents

Lunch and Learn App Overview

The overarching goal of the project is to allow users to explore cuisines through a simple country search, save their favorite recipes for later, and provide educational material related to the cuisine's country.

The project is designed using Service Oriented Architecture, with this app serving as the backend service.

Learning Goals

  • Expose an API that aggregates data from multiple external APIs
  • Expose an API that requires an authentication token
  • Expose an API for CRUD functionality
  • Test, both, API consumption and exposure using a mocking tool (Webmock)

APIs Consumed

  • country input is varified by using Restcountries
  • recipes from Edamam
  • videos providing a brief history of the country from Youtube
  • popular photo images of the country from Unsplash

(back to top)

Schema

Users: A users must have a unique email address. We create an API key for each user. Users can have many favorite recipes.

Favorites: we store the title, url, and the country that relates to the recipes.

alt text

Specs and Deployment instructions

Ruby & Rails version:

Ruby '2.7.4'
Rails 5.2.8.1

To run the app locally run the following 4 commands in your termianl :

  1. Clone the app to your local pc: $ git clone git@github.com:Sergio-Azcona/lunch_and_learn_BE.git
  2. Set up the Gems & dependencies: $ bundle install
  3. Database creation: $ rails db:{drop,create,migrage,seed}
  4. Run the server on localhost:3000: $ rails s

Additionally, you can now run the test suite: $ bundle exec rspec spec

Endpoints

Creating Users and Favorites
Users Creating a user:
  • Users require a name and unique email address
  • API Endpoint: http://localhost:3000/api/v1/users
Request/Response:
  • Happy Path - User is SUCCESSFULLY created
  • Sad Path - User was NOT created
Favorites Creating a favorite:
  • data required: recipe title, recipe url, country and user's api key
  • API Endpoint: http://localhost:3000/api/v1/favorites
Request/Response:
  • Happy Path - favorite is SUCCESSFULLY created
  • Sad Path - favorite was NOT created
Recipes, Learning Resources, and User's Favorites
Recipes Happy Paths Recipes can be search by country or by letting the app select a country for them.
  • Searching by country: pass a country name as a query param to the endpoint
    http://localhost:3000/api/v1/recipes?country=country_name
  • example: search results for thailand:
    http://localhost:3000/api/v1/recipes?country=thailand
  • Random Searching: no country is passed in the query parms; endpoint
    http://localhost:3000/api/v1/recipes
  • Random Searching: no country is passed in the query parms; endpoint

    Sad Paths:
  • Response when a country name is invalid:
  • Note: in the event that no recipes exest, an empty data array is returned

(back to top)


Learning Resources
    Happy Paths:
  • Searching by country: pass a country name as a query param to the endpoint (name can partial or full)
    http://localhost:3000/api/v1/learning_resources?country=country_name
  • example: search results for marsh, which returns responses for Marshall Islands:
    http://localhost:3000/api/v1/learning_resources?country=marsh

  • Sad Paths:
  • Response when a country name is invalid:

User's Favorites
    Happy Paths:
  • The url must include the users api_key in the query param
    http://localhost:3000/api/v1/favorites?api_key=user_api_key
  • Response when user has favorites:
  • Response when valid user does not have favorites:

    Sad Paths:
  • Response when no api key or invalid api_key is passed

(back to top)

About


Languages

Language:Ruby 99.7%Language:HTML 0.3%