Code Monkey home page Code Monkey logo

lunch_n_learn's Introduction

This repo handles only the Back End project responsibilities.

Table of Contents

Project Overview

This is the backend service for an application called Lunch n Learn. Lunch and Learn allows users to find recipes around the world and learn about different countries. When a user creates an account, they are able to save recipes to their favorites for later enjoyment. This project was completed as part of the backend curriculum at Turing School of Software and Design. At this time there is no frontend built.

Schema

Screen Shot 2023-03-06 at 7 51 09 PM

API Endpoints

Here is a list of all mapped client requests with their respective json responses below them:

'Get Recipes for a Specific Country'

first

2

'Get Recipes by Country'

3

3 5

'Get a video for a specific Country'

new 4

4 5

4 8

'Get a photo for a specific Country'

new5

6

7

'User Registration, Add Favorites, Get Users Favorites,'
https://documenter.getpostman.com/view/25513104/2s93JqRQTz

Tech Stack

Lunch n Learn copy

Setup and Installation

From your terminal, run:

  • git clone [email protected]:jlweave/lunch_n_learn.git
  • bundle install
  • rails db:create
  • To run the tests: bundle exec rspec
  • As of right now there is no front end to view this project with

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
  • 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, etc).

API Information

We are consuming several API's for this project:

Needs API key

Does not need an API key

Repository Owner

Lacey
Lacey Weaver
LinkedIn

lunch_n_learn's People

Contributors

jlweave avatar

Watchers

 avatar

Forkers

cry0lab

lunch_n_learn's Issues

User Story 4

Add Favorites

Functionality to add recipes to a favorited list for a particular user can be done with the following request.

Request:

POST /api/v1/favorites
Content-Type: application/json
Accept: application/json

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

{
"success": "Favorite added successfully"
}
Requirements:

  • This POST endpoint should NOT call your endpoint like /api/v1/favorites?country=thailand,recipe_link="https://www.tastingtable.com/....."&recipe_title="Crab Fried Rice (Khaao Pad Bpu)"&api_key=jgn983hy48thw9begh98h4539h4p. You must send a JSON payload in the body of the request
  • in Postman, under the address bar, click on “Body”, select “raw”, which will show a dropdown that probably says “Text” in it, choose “JSON” from the list
  • this is a hard requirement to pass this endpoint!
  • If the api_key is invalid (no user with that api key), an appropriate 400-level status code should be returned, as well as a message explaining what went wrong.
  • If the api_key is valid, create a favorite for the user with that api key.
  • A successful request creates a Favorite for that user in the database, and returns a 201 status code.
  • Your Favorites Table can store country, recipe_link and recipe_title, as well as a foreign key for user. (One to many relationship between User and Favorites)

User Story 2

Get Learning Resources for a Particular Country

Request:

GET /api/v1/learning_resources?country=laos
Content-Type: application/json
Accept: application/json
Response:

The response data should contain exactly these elements and nothing more:

  • a data attribute, under which all other attributes are present:
  • id, always set to null
  • type, set to “learning_resource”
  • attributes, under which the following is present:
  • country name
  • video, an object containing:
  • title of video
  • video id from youtube
  • images, a collection holding elements that have information about that image, for example:
  • alternative description (for alt tags)
  • url for image

Requirements:

  • Endpoint needs to use the search lists endpoint from the YouTube API. We suggest pulling videos from the Mr. History YouTube Channel, but if there’s another educational channel you’d like to pull from instead, you can. You only need to return one video.
  • Note: You’ll need to use snippet to get more data on your search.
  • Implement a new API service (Unsplash, Pexels, Microsoft Bing Image search, Wikimedia image search, Flickr and more) to use the name of the country to get the URL of up to 10 images for that country search.
  • If no videos or images are found, those keys should point to an empty object:

User Story 3

User Registration

Your api should expose this endpoint:

Request:
POST /api/v1/users
Content-Type: application/json
Accept: application/json

{
"name": "Athena Dao",
"email": "[email protected]"
}

Response:

{
"data": {
"type": "user",
"id": "1",
"attributes": {
"name": "Athena Dao",
"email": "[email protected]",
"api_key": "jgn983hy48thw9begh98h4539h4"
}
}
}

Requirements:

  • This POST endpoint should NOT call your endpoint like /api/v1/users?name=Athena Dao&email=[email protected]. You must send a JSON payload in the body of the request
  • in Postman, under the address bar, click on “Body”, select “raw”, which will show a dropdown that probably says “Text” in it, choose “JSON” from the list
  • this is a hard requirement to pass this endpoint!
  • A successful request creates a user in your database, and generates a unique api key associated with that user, with a 201 status code.
  • THIS IS NOT REAL AUTHENTICATION – Real authentication using bcrypt is an extension. The expectations for this endpoint is that upon creation of this user, a randomly generated code should be stored in the database for that user. This code will be used to add favorites to a particular user’s favorite list.
  • Email addresses must be unique. If a unique email address is not used for registration, an appropriate error message should be returned in the response.

Read Me completed

READ ME should include:

  • - schema
  • - about project
  • - endpoints
  • - how to use
  • - api used
  • - about owner

User Story 1

Get Recipes for a Particular Country


Request:

GET /api/v1/recipes?country=thailand
Content-Type: application/json
Accept: application/json
Response:

The response data should contain exactly these elements and nothing more:

  • a data attribute, under which all other attributes are present:
  • collection, each containing the following:
  • id, always set to null
  • type, always set to recipe
  • attributes, containing the following:
  • title
  • url
  • country used for search
  • image url

Requirements:

If country is not sent in by the user, you will need to use the REST Countries API to randomly choose one country’s name.
For whichever country is either passed in or chosen at random, find recipes using the Edamam Recipe API
Note: use the q parameter to search for recipes related to that country
If the country parameter is either an empty string, or a value that doesn’t return any recipes, return an empty array:
{
"data": []
}
Testing should look for more than just the presence of attribute fields in the response. Testing should also determine which fields should NOT be present. (don’t send back unnecessary data in the response)

User Story 5

Get a User's Favorites

Your api should expose this endpoint:

Request:

GET /api/v1/favorites?api_key=jgn983hy48thw9begh98h4539h4
Content-Type: application/json
Accept: application/json
Response:

The response data should contain exactly these elements and nothing more:

  • a data attribute, under which all other attributes are present:
  • id, from the database
  • type, always set to “favorite”
  • attributes, an object containing favorited book information:
  • recipe title
  • recipe link
  • country
  • created at date/time

Requirements:

  • For this get request, api_key can be sent as a query parameter.
  • If the api_key is invalid, an appropriate 400-level status code should be returned, as well as a message explaining what went wrong.
  • If the api_key is valid, this response will return all recipes that the user has favorited.
  • If the user has not favorited any recipes, the data object should point to an empty array.

Sad path testing

Check to make sure sad path testing is completed and that edge cases are looked into

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.