Giter Club home page Giter Club logo

omdb-tracker's Introduction

OMDb Movie Tracker

Demo

To skip installation and view the app, navigate to https://omdb-tracker.herokuapp.com/.

Local Installation

Make sure to have PostgreSQL installed and running properly in your machine. Also, make sure that you have Ruby 2.4.1 installed and running locally.

  1. Navigate to the root directory of the project.

  2. Create a new database named omdb_tracker:

createdb omdb_tracker
  1. Import the sql schema to the database.
psql omdb_tracker < db/schema.sql
  1. Install dependencies by running:
bundle install

Note: you need to have bundler installed

  1. Once all gem dependencies have been satisfied, run:
bundle exec ruby server.rb

This will start the Sinatra server at localhost:4567

  1. Navigate to localhost:4567 in your browser to access the application.

Testing

Make sure that you complete the local installation.

  1. Create a test database named omdb_tracker_test
createdb omdb_tracker_test
  1. Import the sql schema to the test database
psql omdb_tracker_test < db/schema.sql
  1. Run all tests
bundle exec ruby test/api_test.rb

Additional Notes

Stack

  • Sinatra as backend API server
  • Postgres as RDBMS, connected via pg gem
  • React/Redux as frontend, bundled using Webpack
  • Raw CSS with icons from semantic-ui

OMDb API Client

An API wrapper client is built to handle logging, status checking, and server-side caching. Currently, the API client uses a Ruby Hash to cache responses. In a production setting, Redis or Memcached can be used instead to preserve cached data in case of a server crash.

Backend Validation

The application's model layer (represented by the Favorite class in db/favorite.rb) performs appropriate validations before querying the Postgres database. For validating unique values, we rely on Postgres to take advantage of index search for the unique column.

Favorites List Object

The object for favorites list has this format:

const favoritesList = {
  imdbID1: {
    title: 'Star Wars',
    year: '1977',
    plot: 'Luke Skywalker...',
    poster: 'https://...',
    rating: '5',
    comment: 'An awesome movie...',
  },
  imdbID2: {
    title: 'Avatar',
    '...': '...',
  }
}

The advantage of using an object with imdbID as the key is that we can perform a lookup for a particular movie in O(1) time. This is efficient to determine whether or not a movie query result matches a movie in the favorites list.

endyear column

When fetching data from OMDb, a movie's year value may contain a year range (for example: 1978โ€“1979). To conform to the schema of a year column to contain only four-digit year numbers YYYY, it makes sense to create a separate column endyear to store the ending year. When forming a response, the ending year is recombined with the starting year.

omdb-tracker's People

Contributors

yingcgooi 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.