Giter Club home page Giter Club logo

nicopierson / hotpotato Goto Github PK

View Code? Open in Web Editor NEW
13.0 2.0 2.0 14.7 MB

Hotpotato is a space for chefs to display their creations. Follow your favorite chef. Like your favorite recipes. And find the latest gluten-free, vegetarian, and multi-culinary recipes.

Home Page: https://hotpotato-app.herokuapp.com/

Shell 0.17% Dockerfile 0.42% Python 67.98% HTML 0.66% CSS 30.41% Mako 0.35%
javascript python flask react redux sqlalchemy postgresql food portfolio

hotpotato's Introduction

Hotpotato

Hotpotato is a recipe portfolio App that assists users to discover and comment new recipes. It is a fullstack React App made with a Redux state manager and a backend using Python, Flask, SQL-Alchemy, and PostgresSQL.

  • View the Hotpotato App Live

  • It is modeled after the Behance App

  • Contains recipes for Vegetarians, Vegans, and Gluten-Free diets.

  • Reference to the Hotpotato Wiki Docs

Table of Contents
1. Features
2. Installation
3. Technical Implementation Details
4. Future Features
5. Contact
6. Special Thanks

Technologies

Features

Sign In and Sign Up

Sign Up Login

Feed Page

Hotpotato feed displays all recipes and chefs Discover and search for new recipes Feed Page

Sort Recipes in Feed

Sort Recipes based on a category Feed Sort by Category

View Recipe

Single recipe of name, photos, ingredients, directions, and comments Recipe Page

Add Recipe

Add a new recipe to the database Add Recipe Cancel adding recipe Cancel Add Recipe

Create, Read, Update, Delete Recipe Preparations

View preparations to make recipe Recipe Preparations Edit and Add a recipe preparation(s) in the database Edit Recipe Preparations Add Recipe Preparations

Create, Read, Update, Delete Recipe Ingredients

View Ingredients to make recipe Recipe Ingredients Edit and Add a recipe preparation(s) in the database Edit Recipe Ingredients Add Recipe Ingredients

Comment

Users can add comments for a recipe Comments

Follow

Follow or unfollow a chef

follow unfollow

Installation

To build/run project locally, please follow these steps:

  1. Clone this repository
git clone https://github.com/nicopierson/hotpotato.git
  1. Install Pipfile dependencies and create the virtual environment
pipenv install
  1. Install npm dependencies for the /react-app
cd react-app
npm install
  1. In the / root directory, create a .env based on the .env.example with proper settings

  2. Setup your PostgreSQL user, password and database and ensure it matches your .env file

  3. In the root folder, create the database by running in the terminal:

flask db create
  1. In the root folder, migrate tables to the database by running in the terminal:
flask db migrate
  1. In the root folder, seed the database by running in the terminal:
flask seed all
  1. Start the flask backend in the / root directory
flask run
  1. Start the frontend in the /react-app directory
npm start

Technical Implementation Details

Follow

Follow feature was a key element for our project and we implemented by creating a self-referential table from the Users table. It was also necessary to add class methods to follow and to unfollow a user or chef. It was challenging to integrate the table and append or remove users to the table.

Part of our user model is shown below:

follows = db.Table(
  "follows",
  db.Column("user_id_follow_owner", db.Integer,
            db.ForeignKey("users.id")),
  db.Column("user_id_follower", db.Integer, db.ForeignKey("users.id"))
)
followers = db.relationship(
  "User",
  secondary=follows,
  primaryjoin=(follows.c.user_id_follow_owner == id),
  secondaryjoin=(follows.c.user_id_follower == id),
  backref=db.backref("follows", lazy="dynamic"),
  lazy="dynamic"
)

def follow(self, user):
  if not self.is_following(user):
    self.follows.append(user)
    return user
  return False

def unfollow(self, user):
  if self.is_following(user):
    self.follows.remove(user)
    return user
  return False

In order to connect the backend to the frontend, we connected the follows api routes to update the following in the redux store. When the Follow component button is clicked, either a removeFollowing or createFollowing dispatch action is called to update the follow and profile slice of state in redux store. As a result the Profile page will re-render because React notices a change in the profile state and updates the followers attribute and the follow button.

export const removeFollowing = (id) => async (dispatch) => {
    const response = await fetch(`/api/follows/users/${id}`, {
        method: 'DELETE',
    });

    if (response.ok) {
        await dispatch(deleteFollowing(id));
        await dispatch(getProfile(id));
        return response;
    } else {
        return ['An error occurred. Please try again.']
    }
}

export const createFollowing = (id) => async (dispatch) => {
    const response = await fetch(`/api/follows/users/${id}`, {
        method: 'POST',
    });

    if (response.ok) {
        const { following } = await response.json();
        await dispatch(addFollowing(following));
        await dispatch(getProfile(id));
        return following;
    } else {
        return ['An error occurred. Please try again.']
    }
}

Integrating React Carousel

In order to show more than main thumbnail, we integrated a third-party react component.

Code snippet is shown here:

<Carousel 
  className='recipe-carousel' 
  renderArrow={arrows} 
>
  { getPhotos()?.map(recipe => (
    <img 
      src={recipe.img_url} 
      alt={recipe} 
      key={recipe.id} className='recipe-carousel-images'
    />
  ))}

  { getVideos()?.map(video => (
      <ReactPlayer url={video}></ReactPlayer>
    ))
  }

  {addVideo &&
    <ReactPlayer url={videoUrl}></ReactPlayer>
  }
</Carousel>

Future Features

  1. Search - search recipes or chefs

  2. Edit Profile - users edit profile info and add banner

  3. Add Tags - add tags to recipes and profile

Contact

Casey Tuer

[email protected]

Leslie Owiti

[email protected]

Nico Pierson

[email protected]

Wes Trinh

[email protected]

Special Thanks

  • Mentors who have given us their time and effort: Zach, Ed, and Javier

hotpotato's People

Contributors

caseytuer avatar leslieowititech avatar nicopierson avatar westrinhkl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

hotpotato's Issues

Edit comment input

Edit comment input field is unstyled and doesn't populate with previous comment

Add Directions Error

Add directions error will error out because of an undeclared variable for a recipe with no directions.

Ingredient Component

Use Direction Component as a model and integrate ingredient component with view recipe page.

API Routes

Develop api routes and test routes postman

Content under navbar.

Navbar is out of the flow, so content is under it. Need a padding in body perhaps

Profile Page

profile page (hardcoded to feed link) is offset to the right, should be justified to the center

Comments

Positioning is slightly off to the left instead of in the middle

Profile Component

Still needs Button for following a User. Also should conditionally render if already following

Directions Component

Started Direction Component and added a base template for conditional rendering.

Styling Comment

Comments will not be styled in the center of the page for new recipes added.

Wireframes

  • we need wireframe for profile page, feed, and recipe post

Footer Component

Finish adding social links for contributors (linkedin and angellist)

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.