GithubHelp home page GithubHelp logo

romanturner / flavorites-backend Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 786 KB

Ruby on Rails API | Ruby | Nokogiri | Kimurai |

Ruby 99.50% HTML 0.50%
meal-plan pine-meal-planner recipe database bcrypt ruby ruby-on-rails nokogiri kimurai capybara

flavorites-backend's Introduction

Flavorites, the Pine Meal Planner

All of the recipes that are seeded in the database are scraped from the Spruce Eats

Find them on their website -> The Spruce Eats

This is a rails API that is built to communicate with Flavorites, the Pine Meal Planner React application found here ->

Domain Model

Domain Model

User

The user manages all of the data that is accossiated with anyone that signs up to use the application.

Follows

With the spirit of networking, you can interact with other users in the form of following them. They can also follow your profile, and become a flavor fan.

Meal Plan

Each user has the ability to create meal plans. These meal plans have a category for each day of the week and an unassigned category. It is built like this for frontend rendering purposes. Storing the id of the Meal Plan Recipe (Join table) so that it can render them in the correct spot on the calendar.

Meal Plan Recipes

Each Meal Plan needs to have many recipes, so we create an instance of where a Meal Plan uses a recipe on this join table. The User also has the information of all the recipes that they are using through Meal Plan.

Recipes

These consist of a lot of data scraped from the Spruce Eats website. They should be broken out into different models that correspond with eachother but to preserve their data and respect their creations I am just using this data to model a feature that I would love to help them implement on their site.

Authorization and Encryption

We are using Bcrypt to hash and salt user passwords in our database. 1

We are also only allowing interaction with our database if they hold an authorized JWT (JSON WEB TOKEN) 2

Application Controller

Web Scraping

Using the Kimurai gem really saved the bacon on this data collection. After struggling with Nokogiri this made collecting dynamic and fun.

I go to their search page to bulk collect links to individual recipes. With those links I now have new targets for my spider to crawl. I target the content I want on my site and I then loop through collecting a new recipe on each run and creating a new instance of recipe in my database.

This holds a lot of errors in my database for data sake, but as this is a presentational data it serves its purpose. Common propblem was the main image pictures often collected the author's headshot photo. I sanitize that on the front end with a regex match I correlated to the image url string, which replaces those with a default image to render.

Application Controller

Footnotes

  1. More on Bcrypt

  2. More on JWT

flavorites-backend's People

Contributors

romanturner avatar

Watchers

 avatar

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.