Coder Social home page Coder Social logo

rdwoodring / seven-degrees-of-staind Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 1.99 MB

A web app that classifies music as "butt rock" based on it's proximity to Staind in the Spotify related artists API.

License: MIT License

JavaScript 2.44% CSS 0.07% TypeScript 96.23% HTML 1.25%

seven-degrees-of-staind's Introduction

CircleCI GitHub license GitHub release GitHub contributors

Seven Degrees of Staind (Butt Rock Classifier)

At work, we got tired of arguing over which bands were or were not butt rock, so we wanted an objective way to make the determination. Everyone could agree that Staind was the epicenter of butt rock, so this app uses Spotify's Related Artist API to build a tree of related artists seven degrees out from Staind to classify what's butt rock.

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.

Prerequisites

You will need to install a copy of Node.js to run this project. Download the appropriate installer for your system and follow the installation wizard. Note that the project was built using Node 10.15, though it probably should work on later versions and maybe on older versions.

You will also need to have either NPM or Yarn installed. NPM comes packaged with Node.js so you'll get that for free by installing Node.js. If you want to use Yarn download the appropriate installer and follow the installation wizard. Yarn should work fine, but note that the project was developed using NPM and the instructions are based on NPM.

Finally, you will need an instance of MongoDB. You can probably use one of Mongo's free cloud instances, but the project was developed using a copy of MongoDB locally. MongoDB is primarily used for secure, server-side storage of session data so that the access token and refresh token returned from Spotify don't have to be stored client-side in something like a cookie.

Installing

  1. Clone the repository
  2. Install all dependencies in the project root by running npm install
  3. Create a dotenv file named ".env"
  4. Login to your Spotify account and get an API key
  5. Add CLIENT_ID=your_spotify_app_client_id to your .env file
  6. Add CLIENT_SECRET=your_spotify_app_client_secret to your .env file
  7. Add SESSION_SECRET=a_strong_random_string to your .env file
  8. Add DB_CONN_STRING=my_db_connection_string to your .env file. If you installed MongoDB locally, the connection string will look something like this: mongodb://localhost:1234/my-seven-degrees-of-staind-dev-db-cluster
  9. Run mongod --dbpath='path/to/your/data/directory'
  10. Run npm run watch to compile the TypeScript server and client code into JavaScript that Node can run. This command runs the server behind nodemon so the server gets restarted on all changes and also ensures that the client code gets re-overlayed on all changes.
  11. Import the butt rock related artists graph into your database

You should now be able to access the app on localhost:3000.

Importing Butt Rock Artists

There are two ways you can get some butt rock related artists imported into your development database:

Import Manually Using a Pre-built Related Artists JSON
  1. Download the related.json file from the gist. This file was generated from a recent import done during development.
  2. Place it in the root of Seven Degrees of Staind project
  3. Ensure that mongod is running
  4. Run the mongoimport --uri ${process.env.DB_CONN_STRING} --collection relatedartists --drop --jsonArray --file ./related.json command from the root of your Seven Degrees of Staind project.
Import Using the Import Scripts
  1. Ensure that your TypeScript has been compiled to JavaScript.
  2. Ensure that mongod is running
  3. Run the node ./server/dist/scripts/cron/updateButtRockGraph from the root of your Seven Degrees of Staind project.

Deployment

  1. Clone the code to the production VM
  2. TODO: add node and apache install instructions
  3. TODO: add and enable the site instructions
  4. Add CLIENT_ID=your_spotify_app_client_id to your .env file
  5. Add CLIENT_SECRET=your_spotify_app_client_secret to your .env file
  6. Add SESSION_SECRET=a_strong_random_string to your .env file
  7. Add DB_CONN_STRING=my_db_connection_string to your .env file. If you installed MongoDB locally, the connection string will look something like this: mongodb://localhost:1234/my-seven-degrees-of-staind-prod-db-cluster
  8. Start mongo by running mongod --fork --dbpath ~/data/db
  9. Go to the site directory (var/www/butt-rock.com/html/nodejs)
  10. Install pm2 by running npm install pm2 -g
  11. Run sudo pm2 start bin/www --watch --name butt-rock
  12. Run sudo pm2 startup
  13. Copy and paste the output of the startup command and run it
  14. Run sudo pm2 save to complete the process of daemonizing the app

Built With

  • Node.js - Web framework
  • NPM - Dependency Management
  • TypeScript - JavaScript... but with type safety!
  • React - Fast and straightforward UI library
  • MaterialUI - UI components library
  • Express - Server framework
  • MongoDB - Persistent server-side storage

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests.

Versioning

This project adheres to semantic versioning.

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.txt file for details

Acknowledgments

TODO

seven-degrees-of-staind's People

Contributors

rdwoodring avatar dependabot[bot] avatar

Stargazers

Donny Andrews avatar

Watchers

James Cloos avatar  avatar

seven-degrees-of-staind's Issues

Hitting the API with a malformed request isn't properly handled

Steps to Reproduce:

  1. Navigate to YOURBUTTROCKINSTANCE.com/api/v1/search?artist=iron%0boss

Expected Result
Should get a 400 bad request error because of the malformed '%0'

Actual Result
The page hangs and doesn't receive a response from the server, resulting in an eventual 504 Gateway Timeout instead.

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.