Skip to content

isaialvarado/share-deals

Repository files navigation

ShareDeals

ShareDeals is a web application inspired by Slickdeals built using Ruby on Rails and React Redux.

Motivation

I enjoy browsing Slickdeals and have found many good deals through their website.

Features

  • User accounts with BCrypt authentication
  • User-generated deals (CRUD)
  • Up-vote and down-vote deals
  • Comments
  • Search and filter
Screenshot

ShareDeals search

Technology

Backend

  • Ruby on Rails
  • PostgreSQL
  • Heroku hosting
  • Cloudinary image hosting via Cloudinary gem
Active Record Query Interface

Popular deals on front page are based on total thumb score specified in Rails controller.

@popular_deals =
  Deal
    .select('deals.id')
    .joins(:thumbs)
    .group('deals.id')
    .having('sum(thumbs.value) > 8')
    .order('deals.created_at DESC')
    .limit(20)

Search results are based on whole-word, case-insensitive matches. Default filter values are also added to the query if not present.

@deals =
  Deal
    .where('title ~* ?', search_string)
    .where('price >= ?', min_price)
    .where('price <= ?', max_price)
    .where('category ~* ?', category)
    .order('created_at DESC')
    .limit(25)

Frontend

  • React JavaScript library
  • Redux state management library
  • npm package manager
  • webpack module bundler
  • jQuery
Front-page Thumbs with React

The thumb rendered is based on whether a user enters or leaves the main <div> element. A boolean in the component's state is updated appropriately based on the mouse events below.

return (
  <div
    className={thumbType}
    onMouseEnter={this.mouseEnter}
    onMouseLeave={this.mouseLeave}>
    {thumb}
  </div>
);

If a user's mouse cursor enters the <div> element, this.state.hover is true, and two clickable thumbs appear with their own event handlers.

let thumb;

if (this.state.hover) {
  thumb = (
    <div className='thumbs'>
      <img
        className='thumb1'
        onClick={this.handleThumbClick(1)}
        src={this.thumbsUpImage()} />
      <img
        className='thumb2'
        onClick={this.handleThumbClick(-1)}
        src={this.thumbsDownImage()} />
    </div>
  );
} else {
  thumb = (
    <div className='thumbs'>
      <img src={this.mainThumbImage()} />
      <span>{this.props.thumbs}</span>
    </div>
  );
}

Project Design

ShareDeals was designed and implemented in less than two weeks based on a proposal that included

Colors

Palette by Beklad

About

Single-page, deal-sharing application inspired by Slickdeals

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published