RAZ321 / spaceflix

Spaceflix is a pixel-perfect clone of Netflix. Browse and watch trailers, create individualized profiles, and save movies to your personal list for later viewing.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Spaceflix

Visit the Live Site here

Spaceflix is a space-themed, pixel-perfect clone of Netflix. Like the real thing, Spaceflix allows users to stream movies (trailers) on demand. Users can create and delete profiles, each of which has its own independent Watch List where movies can be saved for later viewing. Movies can be previewed by hovering over their thumbnails, and additional details can be accessed by opening their respective show-sections. In the future, Spaceflix will feature search functionality as well as recommendations based on movies a profile has already watched.

Features

  • Secure user authentication with component, model, and database level validations.
  • User passwords are securely stored in hashed and salted format.
  • Ability to create and delete up to 5 custom profiles per user, each of which has its own dedicated Watch List.
  • Ability to add or remove videos from Watch lists from the video preview or show page.
  • Ability to switch between profiles seamlessly using the Navigation bar or dedicated Profiles page.
  • Ability to watch videos with custom video control panel designed specifically for Spaceflix.
  • User authentication process includes error handling, rendering descriptive errors to the user for an intuitive signup/login experience.

Technologies

Spaceflix is built with Ruby on Rails on the backend and React/Redux on the frontend. User and movie information is stored in a PostgreSQL database and AWS S3 is used for cloud storage of image and video files. Secure user authentication is implemented without any dedicated authentication libraries, but user passwords are stored securely in hashed + salted format with assistance from BCrypt. The application is additionally supported by Webpack, jQuery, and Jbuilder.

Technical Challenges

Authorizing AWS S3 Requests with proper expiration guidelines

In the final stages of this project, I noticed that attempts to play videos on the Browse page would return a 403 Forbidden error from AWS S3 a few minutes after the page was initially loaded. To debug this, I began researching pre-signed signatures in AWS and eventually learned that the media request URLs being sent to AWS by way of ActiveStorage were setting a default query parameter of expires_in: 300 - meaning that each request would only remain valid for five minutes. Using the Ruby on Rails and ActiveStorage documentation, I researched and built a custom Rails initializer, active_storage.rb, to override that default parameter with the following line of code:

ActiveStorage::Service.url_expires_in = 1.hour

Fading video controls based on user inactivity

The problem here is pretty straightforward: there is no event listener for the absence of user activity. To implement such behavior, I defined a series of functions which increment a timer while the mouse is not actively moving, and trigger a fade animation when that timer reaches three seconds. The timer starts/ends by hovering over the parent element, and is reset onMouseMove, ensuring that the controls do not disappear too quickly and that they can reappear instantaneously. This functionality can be observed in the application when hovering over a movie preview, or on a movie's dedicated Watch page.

// components/movies.jsx
startFadeTimer() {
    this.fadeInterval = window.setInterval(this.incrementFadeTimer, 1000)
    this.containerElement.classList.remove("fade-trigger")
}

resetFadeTimer() {
    this.containerElement.classList.remove("fade-trigger")

    this.fadeTime = 0;
    clearInterval(this.fadeInterval);
    this.fadeInterval = window.setInterval(this.incrementFadeTimer, 1000)
}

endFadeTimer() {
    this.fadeTime = 0;
    clearInterval(this.fadeInterval);

    this.containerElement.classList.remove("fade-trigger");
}

incrementFadeTimer() {
    this.fadeTime++;
    
    if (this.fadeTime >= 3) {
        this.fadeControls();
        this.fadeTime = 0;
    }
}

fadeControls() {
    this.containerElement.classList.add("fade-trigger")
}

Upcoming Features

  • Searchable Movie Database
  • Dedicated Genre View pages
  • Recommended movies based on user activity
  • Continue Watching feature which keeps track of movies that have been started but not finished

About

Spaceflix is a pixel-perfect clone of Netflix. Browse and watch trailers, create individualized profiles, and save movies to your personal list for later viewing.


Languages

Language:JavaScript 41.7%Language:Ruby 35.0%Language:SCSS 16.2%Language:HTML 3.1%Language:CSS 3.1%Language:CoffeeScript 0.8%