Git Product home page Git Product logo

imdb-emotions's Introduction

Data processing pipeline

Problem

Pick two APIs from RapidAPI โ€” one that produces text content and the other one that consumes it. One example is, Reddit API and Yoda Translator API.

Design the following:

  • Another API that is a composition of the ones you've chosen

  • As a bonus, simulate (if needed) different rate limits on the APIs you've chosen and design an efficient pipeline that continuously processes the data via composition of the two APIs.

Solution

I have provided a solution that stiches together two APIs-

  1. Movie Database API
  2. Emotion Analysis API

To run locally, clone this repository, and run npm install, then node server.js to start the server.

Test the API by making a GET request to http://localhost:3000/films?title={title}, for example, http://localhost:3000/films?title=gremlins

A response to a valid request will provide basic information on the movie, including its plot, and an emotions analysis of the plot. For example,

{
  status: 200,
  data: {
    imdbID: "tt0087363",
    plotAnalyzed: "Minature green monsters tear through the small town of Kingston Falls. Hijinks ensue as a mild-mannered bank teller releases these hideous loonies after gaining a new pet and violating two of three simple rules: No water (violated), no food after midnight (violated), and no bright light. Hilarious mayhem and destruction in a town straight out of Norman Rockwell. So, when your washing machine blows up or your TV goes on the fritz, before you call the repair man, turn on all the lights and look under all the beds. 'Cause you never can tell, there just might be a gremlin in your house.",
    title: "Gremlins",
    year: "1984",
    emotionScores: {
      fear: 0.18077003383633,
      sadness: 0.074569747768044,
      surprise: 0.065499617731342,
      anger: 0.044530763520042,
      joy: 0.030528182192787,
      disgust: 0
    }
  }
}

To run the app locally yourself, create a .env file where you specify EMOTIONS_HOST, IMDB_HOST, RAPID_API_KEY. Visit Rapid API for docs on the APIs and your key.

Tests

I'm using supertest to make test requests to the API. If you are running the app locally and would like to run the API tests, make sure Mocha is installed, and run npm test.

Rate Limiting

The bottleneck library is used to limit the rate of outgoing requests to the vendor APIs. The bottleneck is currently set to limit outgoing requests to a maximum of 1 concurrent request and a maximum of 1 outgoing request per second.

imdb-emotions's People

Contributors

sonoilconte avatar valued-code avatar

Watchers

Jordan Eldredge avatar James Cloos 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.