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.
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.
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.
- Clone the repository
- Install all dependencies in the project root by running
npm install
- Create a dotenv file named ".env"
- Login to your Spotify account and get an API key
- Add CLIENT_ID=your_spotify_app_client_id to your .env file
- Add CLIENT_SECRET=your_spotify_app_client_secret to your .env file
- Add SESSION_SECRET=a_strong_random_string to your .env file
- 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
- Run
mongod --dbpath='path/to/your/data/directory'
- 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. - Import the butt rock related artists graph into your database
You should now be able to access the app on localhost:3000.
There are two ways you can get some butt rock related artists imported into your development database:
- Download the related.json file from the gist. This file was generated from a recent import done during development.
- Place it in the root of Seven Degrees of Staind project
- Ensure that mongod is running
- 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.
- Ensure that your TypeScript has been compiled to JavaScript.
- Ensure that mongod is running
- Run the
node ./server/dist/scripts/cron/updateButtRockGraph
from the root of your Seven Degrees of Staind project.
- Clone the code to the production VM
- TODO: add node and apache install instructions
- TODO: add and enable the site instructions
- Add CLIENT_ID=your_spotify_app_client_id to your .env file
- Add CLIENT_SECRET=your_spotify_app_client_secret to your .env file
- Add SESSION_SECRET=a_strong_random_string to your .env file
- 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
- Start mongo by running
mongod --fork --dbpath ~/data/db
- Go to the site directory (var/www/butt-rock.com/html/nodejs)
- Install pm2 by running
npm install pm2 -g
- Run
sudo pm2 start bin/www --watch --name butt-rock
- Run
sudo pm2 startup
- Copy and paste the output of the startup command and run it
- Run
sudo pm2 save
to complete the process of daemonizing the app
- 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
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests.
This project adheres to semantic versioning.
- Ryan Woodring - Initial work - rdwoodring
See also the list of contributors who participated in this project.
This project is licensed under the MIT License - see the LICENSE.txt file for details
TODO