Coder Social home page Coder Social logo

spotify-suggester's Introduction

Spotify Suggester

Spotify Suggester is a web app that suggests music to you based on the currently playing track.

Getting Started

To host Spotify Suggester locally, follow this guide.

Prerequisites

  • Docker - for starting up the server and database processes with one command
    • As a side note, while docker makes it super easy to spin up these processes, Docker for Mac has some issues where it takes up a lot of resources in general, even when no containers are running. I recommend quitting Docker Desktop whenever it is not in use.

Configure .env Environment File

Since there are passwords and other unique tokens required for the server to run, they are included in an environment file name .env. This file is not committed to the repository on purpose since including it would allow anyone to see them. The file .env-default contains the environment variables that are needed, but the values are replaced with default values.

To set up the environment, you must

  1. Make a copy of the file .env-default and rename it to .env
  2. Paste in the Client ID and Client Secret unique identifiers, found in your app on the Spotify Dashboard.

Optionally, you may also change the application URL and/or the MySQL database credentials. While it is not required, it is not a good idea to leave the root password for the database as secret, but it will do just fine for development purposes.

Start the Containers

To start up the database and the server, navigate to the app directory

cd app

and run the following command:

docker-compose up -d

The optional -d flag runs the containers in the background (detached). If you want to see output from any of the containers when you run them detached, simply run the command docker-compose logs -f.

Note: it might take a while to get started the first time (since it has to download all the images for the first time), but since the images will be cached, it should take considerably less time to start next time.

The server will restart whenever it sees changes to any of the files in the src directory. You may have to refresh your browser to see changes. It may also take a moment for the server to restart. You can keep an eye on the status of the program by opening the logs with docker-compose logs -f. Once you see the message Listening at http://localhost:3000 in the logs, it should be live on your browser.

Open a Tunnel

To expose port 3000 (that the server is running on) to the internet, run the following command:

ssh -R spotifysuggester.serveo.net:80:localhost:3000 serveo.net

This creates an SSH tunnel to the server listening for traffic on port 3000 of your computer. This allows you to go to the website http://spotifysuggester.serveo.net from any internet-connected device and see the application run. Because of how Spotify redirects the user to authorize the use of its data, this internet connection is required (it won't work to just go to http://localhost:3000).

Note: while you could replace spotifysuggester.serveo.net in the above command with any subdomain of serveo.net, Spotify requires that each redirect domain be whitelisted in the app's settings on the Spotify Developer Dashboard. In other words, if you change it, Spotify won't give you any data.

Shutting Down

If you started the containers detached (using the command docker-compose up -d) then simply run the following command (from within the app directory) to stop the containers

docker-compose down

Note: if you started the containers in the foreground (without the -d flag), pressing CTRL-C will stop them.

Note: by default, docker-compose down doesn't delete or remove the volumes that are created when starting up the containers. This means that in between times you shut down and start up the containers, the database will remain the same. If you want to delete this volume to get a fresh start, simply add the --volumes flag to docker-compose down

docker-compose down --volumes

spotify-suggester's People

Contributors

dependabot[bot] avatar e13h avatar

Watchers

 avatar  avatar

spotify-suggester's Issues

Calls to Spotify do not handle expired access token

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.