Giter Club home page Giter Club logo

media-api's Introduction

Media API

This API allows consumers to search for & retrieve information regarding movies & TV shows

(Please note: I am using the free-tier service on Heroku. This means the first request may be slow while the app 'wakes up'. After this, it should be performant for you.)

Main Details

This is a RESTful API built in Ruby on Rails that serves JSON back to the client. The codebase is stored in GitHub and the live API is hosted on Heroku. Documentation is hosted on Apiary, written in the API Blueprint specification. There are 3 routes:

Data Details

  • The data for this app consists of movies, TV shows, and media types
  • The data is fetched from an external API (The Movie Database) and seeded into our PostgreSQL database
  • The external API is very robust and well-documented, providing a clean contract that allowed me to model my relational data very effectively
  • 300 records of each media type for local development, 500 for production (this number can be easily modified by tweaking the environment variables)
  • In order to determine the genres for each media type, I fetch the genre ID's from the external API, and store in a local hash for fast lookup. I then use this data structure to build the 'genres' attribute for each movie & show record.

Some Programming Decisions

  • In order to clean up code in DB seeding operation, I made use of Ruby service objects (found in app/services directory)
  • I intentionally didn't wrap seeding operation (when persisting to the DB) in a transaction. If a record fails to save, it's OK, it's not the end of the world. We can tolerate imperfect data at the moment. I didn't experience this issue at all, though.
  • Used integers for movie & show ID's, instead of UUID's. Makes for a friendlier request URL. Would most likely use UUID in a bigger, real production app though!

Deployment Strategy

  • Deployed onto Heroku
  • Utilized Heroku Pipelines to have a Development, Staging, and Production app.
  • Can tweak environment of apps independently of one another
  • Performed continuous delivery by integrating with GitHub repo
* UPDATE * Additional Deployment Strategy

I also wanted to deploy this API application onto Google Cloud Platform for further fun :)

  • Hosted on Google Cloud App Engine
  • Integrates with cloud-hosted database: Cloud SQL for PostgreSQL (9.6)
  • Worked with correctly allocating traffic to appropriate version of app
  • Same API as described in the documentation, except the host is "https://media-api-matt-santa.fun/"
  • This host domain above was registered on Namecheap (DNS provider), and verified by Google to point to my App Engine application ("https://media-api-216302.appspot.com/")

Third-Party Gems Harnessed

  • 'rest-client' (for consuming external API)
  • 'active_model_serializers' (for cleaner JSON serialization)
  • 'pg_search' (for Search endpoint, leveraging postgres full text search)
  • 'api-pagination' (wrapper for rendering paginated JSON)
  • 'kaminari' (the actual gem performing the pagination)
  • 'dotenv-rails' (to easily manage environment variables in local development)
  • 'colorize' (to make the seed command CLI nice and pretty - see below :)

Screenshots

Seeding operation

Movies in DB

Shows in DB

GET Movie endpoint

GET Show endpoint

Paginated Search endpoint

Heroku Pipeline

media-api's People

Contributors

msantam2 avatar

Stargazers

 avatar

Watchers

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