Skip to content

streamr-turing/streamr-be

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

119 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Streamr API

Table of Contents

Project Overview

Streamr is an application meant to help users exchange and manage TV show recommendations by creating a space where users can make direct recommendations to other users, browse through TV shows, see the details of a show such as streaming availability, and save those shows to a watchlist for later.

This repo is the back end service of a project built by students at Turing School of Software and Design. You can find the Front End repo HERE, and the app is deployed HERE

Learning Goals

Project Spec

This project's goal was to synthesize the knowledge accumulated over the course of the Turing web development program in order to produce a complete web application from a student-led project idea, focusing on Service-Oriented Architecture with separate front end and back end teams. Communication was crucial as each team was composed of students who were trained solely for their respective side of the stack. As part of the project requirements, a stretch tech had to be learned and incorporated into both ends of the application. GraphQL was the chosen stretch tech for this application. Agile methodologies were also implemented to manage the project during the two-week time period given to complete the Minimum Viable Product. The back-end handles the project's API consumption and acts as the interface to the project's database.

Setup

This application uses Ruby 2.7.2 and Rails 5.2.8.1

This application uses The Movie Database (TMDB) API. You will need to register for your own api key.

  1. Clone the repository
  2. Navigate into the root directory
  3. Install gem packages: bundle install
  4. Setup the database: rails db:{drop,create,migrate}
  5. Configure API key by running bundle exec figaro install and then adding the key to application.yml file:
tmdb_api_key: your_key_here
  1. Run rails s to start the server
  2. Visit the endpoint url http://localhost:3000/graphql to consume the API locally.
  3. You may run the RSpec test suite locally with bundle exec rspec

Endpoints

Back End Server: https://streamr_be.herokuapp.com/

This application uses GraphQL and therefore all requests should be sent as POST https://streamr-be.herokuapp.com/graphql with the appropriate query in the request body.

After setup, non-static documentation is available using GraphiQL, GraphQL's IDE, by visiting localhost:3000/graphiql. Static documentation is provided below to give an initial sense of available data.

  • Fetch Users

Fetch All Users in the Database
Request Body:
  query {
    users {
        id
        username
        avatarUrl
    }
  }

JSON Response Example:

  {
  "data": {
    "users": [
      {
        "id": "1",
        "username": "snoop_dogg",
        "avatarUrl": "https://cdn-icons-png.flaticon.com/512/3940/3940414.png"
      },
      {
        "id": "2",
        "username": "martha_stewart",
        "avatarUrl": "https://cdn-icons-png.flaticon.com/512/3940/3940448.png"
      },
      {...},
      {...}
    ]
  }
Fetch One User From the Database by ID
Request Body:
query {
	fetchUser (
  	id: 5
  )
  {
    id
    username
    avatarUrl
    watchlistItems {
      show {
        tmdbId
        title
        releaseYear
        posterUrl
        mediaType
      }
    }
    recommendations {
      id
      recommendeeId
      recommender {
        id
        username
        avatarUrl
      }
      show {
        tmdbId
        title
        releaseYear
        rating
        genres
        posterUrl
        mediaType
      }
      createdAt
    }
  }
}

JSON Response Example:

 {
  "data": {
    "fetchUser": {
      "id": "5",
      "username": "the_burger_king",
      "avatarUrl": "https://cdn-icons-png.flaticon.com/512/3940/3940429.png",
      "watchlistItems": [
        {
          "show": {
            "tmdbId": 76331,
            "title": "Succession",
            "releaseYear": "2018",
            "posterUrl": "https://image.tmdb.org/t/p/w500/e2X32jUfJ2kb4QtNg3WCTnLyGxD.jpg",
            "mediaType": "tv"
          }
        },
        {..},
        {..}
      ],
      "recommendations": [
        {
          "id": "5",
          "recommendeeId": 5,
          "recommender": {
            "id": "4",
            "username": "sean_not_shaun",
            "avatarUrl": "https://cdn-icons-png.flaticon.com/512/3940/3940421.png"
          },
          "show": {
            "tmdbId": 4608,
            "title": "30 Rock",
            "releaseYear": "2006",
            "rating": 7.45,
            "genres": [
              "Comedy"
            ],
            "posterUrl": "https://image.tmdb.org/t/p/w500/k3RbNzPEPW0cmkfkn1xVCTk3Qde.jpg",
            "mediaType": "tv"
          },
          "createdAt": "2023-02-12T19:29:41Z"
        },
        {..},
        {..}
      ]
    }
  }
}
  • Shows

Search for Shows with Keyword
Request Body:
  query {
    shows(
        query: "30 Rock"
    )
    {
        tmdbId
        title
        imageUrl
        yearCreated
        mediaType
        rating
        genres
    }
}

JSON Response Example:

  {
  "data": {
    "shows": [
      {
        "tmdbId": 4608,
        "title": "30 Rock",
        "imageUrl": "https://image.tmdb.org/t/p/w500//k3RbNzPEPW0cmkfkn1xVCTk3Qde.jpg",
        "yearCreated": "2006-10-11",
        "mediaType": "tv",
        "rating": 7.45,
        "genres": [
          "Comedy"
        ]
      },
      {..},
      {..},
    ]
  }
Fetch Show Details by ID
Note: The argument `userId` is only required if the recommendedBy field is present in query
Request Body:
  query {
    showDetails(
        tmdbId: 4608
        userId: 1
      	mediaType: "tv"
    )
    {
        tmdbId
        title
        releaseYear
        streamingService {
          logoPath
          providerName
        }
        posterUrl
        genres
        rating
        summary
      	mediaType
        recommendedBy {
                id
                username
                avatarUrl
        }
    	 
    }
}

JSON Response Example:

  {
  "data": {
    "showDetails": {
      "tmdbId": 4608,
      "title": "30 Rock",
      "releaseYear": "2006",
      "streamingService": [
        {
          "logoPath": "https://image.tmdb.org/t/p/w500/zxrVdFjIjLqkfnwyghnfywTn3Lh.jpg",
          "providerName": "Hulu"
        },
        {..},
        {..}
      ],
      "posterUrl": "https://image.tmdb.org/t/p/w500/k3RbNzPEPW0cmkfkn1xVCTk3Qde.jpg",
      "genres": [
        "Comedy"
      ],
      "rating": 7.45,
      "summary": "Liz Lemon, the head writer...",
      "mediaType": "tv",
      "recommendedBy": [
        {
          "id": "2",
          "username": "martha_stewart",
          "avatarUrl": "https://cdn-icons-png.flaticon.com/512/3940/3940448.png"
        },
        {..},
        {..}
      ]
    }
  }
}
  • Recommendations

Create New Recommendation
Request Body:
  mutation {
    createRecommendation (
        tmdbId: 4608,
        recommenderId: 1,
        recommendeeId: 2,
        mediaType: "tv"
    )
    {
        id
        tmdbId
        recommenderId
        recommendeeId
    }
}

JSON Response Example:

  {
  "data": {
    "createRecommendation": {
      "id": "30",
      "tmdbId": 4608,
      "recommenderId": 1,
      "recommendeeId": 2
    }
  }
}
  • Watchlist Items

Create New Watchlist Item
Request Body:
  mutation {
    createWatchlistItem (
        tmdbId: 4608,
        userId: 1,
        mediaType: "tv"
    )
    {
        id
        tmdbId
        userId
    }
}

JSON Response Example:

  {
  "data": {
    "createWatchlistItem": {
      "id": "83",
      "tmdbId": 4608,
      "userId": 1
    }
  }
}
Delete Watchlist Item
Request Body:
  mutation {
    deleteWatchlistItem (
        id: 83 )
    {
        id
    }
}

JSON Response Example:

  {
  "data": {
    "deleteWatchlistItem": {
      "id": "83"
    }
  }
}

Schema

Final Streamr Schema

Contributors

James White Madeline Mauser Sean Culliton William Wang Kathleen Brandt
(Project Manager)
Hemesh Patel
(Project Mentor)
github Github
linkedin LinkedIn
github Github
linkedin LinkedIn
github Github
linkedin LinkedIn
github Github
linkedin LinkedIn
github Github
linkedin LinkedIn
github Github
linkedin LinkedIn

Gems

Known Issues/Future Goals

Future features could include:

  • Ability to add other users as friends.
  • Ability to leave individual reviews on shows/movies.
  • Additional recommendations based on popularity or at random.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages