Skip to content

selector-turing/back_end

Repository files navigation

Selector Back End

This is the backend engine Selector, a web application that connects users with Spotify and Discogs, for a seamless, music browsing (and eventually "purchasing") experience. The application is built with service oriented architecture. The backend communicates with the frontend using our choice of "stretch technology" for this project, as a single GraphQL endpoint, which supplies data from multiple other endpoints the Back End is interacting with. The database currently stores "Favorites", but there are plans for much more, starting with users.

Selector App Created by:

Site Link

https://turing-selector.herokuapp.com/

Related Repos

To explore the full web application, please visit the built out front end application that hooks into this engine and its endpoints.

Continous Integration

Deployed with

Built With

This project was tested with:

Contents

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system. Endpoints can be added to GraphQL, if you plan to use this Back End engine with the frontend web application, however if the endpoints are changed subsequent updates will be necessary on the Frontend repository code.

Prerequisites

  • Ruby

    • The project is built with rubyonrails using ruby version 2.5.3p105, you must install ruby on your local machine first. Please visit the ruby home page to get set up. Please ensure you install the version of ruby noted above.
  • Rails

    gem install rails --version 5.2.5
  • Postgres database

    • Visit the postgresapp homepage and follow their instructions to download the latest version of Postgres app.

Installing

  1. Clone the repo
$ git clone https://github.com/selector-turing/back_end
  1. Bundle Install
$ bundle install
  1. Create, migrate and seed rails database
$ rails db:{create,migrate}

Endpoint

| /graphql |

All endpoints use a POST method.

Screen Shot 2021-05-26 at 4 21 32 PM

API Contract

All endpoints rely on GraphQL to perform queries and mutations of data.

  1. The following queries rely on the third-party APIs from Discogs and Spotify: album, randomAlbum, artistAlbums, and spotifyAlbumID.
  2. The follwoing queries and mutation rely on the the internal database of the app: favorites and createFavorite.
GraphQL Queries
album
{
  album(title: "The Payback"){
    id
    title
    artists {
      name
     }
    year
    genres
    coverImage
    resourceUrl
    styles
    year
    tracklist {
      position
      title
      duration
     }
    uri
  }
}

Required arguments: title.

randomAlbum
{
  randomAlbum {
    id
    title
    artists {
      name
    }
    year
    genres
    coverImage
    resourceUrl
    styles
    year
    tracklist {
      position
      title
      duration
    }
    uri
    randomAlbumSpotifyId
  }
}
artistAlbums
{
  artistAlbums(artist: "James Brown"){
  artist
  title
  id
  coverImage
  format
  year
  label
  }
}

Required arguments: artist.

favorites
query {
  favorites {
    id
    albumId
    title
    artists
    year
    genres
    coverImage
    tracklist
    uri
  }
}

Required returned fields: id, title, artists, year, and genres.

spotifyAlbumID
{
  spotifyAlbumId(title: "The Payback"){
    id
  }
}

Required arguments: title.

GraphQL Mutations
createFavorite
mutation {
  createFavorite(input: {
    albumId: 33990,
    title: "The Payback",
    artists: "James Brown",
    year: 1973,
    genres: "Funk / Soul",
    coverImage: "https://img.discogs.com/MUELn9ObTL-ZpxyUgF5M9D_Kumc=/fit-in/600x591/filters:strip_icc():format(jpeg):mode_rgb():quality(90)/discogs-images/R-719877-1247870750.jpeg.jpg",
    tracklist: "tracklist",
    uri: "uri"
  }) {
    favorite {
      albumId
      title
      artists
      year
      genres
      tracklist
      uri
    }
    errors
  }
}

Required fields: albumId, title, artists, and year.

Postman

Screen Shot 2021-05-26 at 4 36 54 PM

Project Architecture

Screen Shot 2021-05-26 at 4 47 47 PM

Database Schema

download

In addition to favorites, the team has plans to add users, merchants and registration/login with authorization.

Testing

A few examples of things we are testing.

Screen Shot 2021-05-26 at 4 19 21 PM

Running Tests
  • To run the full test suite run the below in your terminal:
$ bundle exec rspec
  • To run an individual test file run the below in tour terminal:
$ bundle exec rspec <file path>

for example: bundle exec rspec spec/features/host/dashboard/index_spec.rb

How to Contribute

In the spirit of collaboration, things done together are better than done on our own. If you have any amazing ideas or contributions on how we can improve this API they are greatly appreciated. To contribute:

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Roadmap

See the open issues for a list of proposed features (and known issues). Please open an issue ticket if you see an existing error or bug.

Contributors

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages