/MixCapsule

A website to make a time capsule playlist of your most played Spotify tracks for the last month

Primary LanguageJavaScript

See the live version here

A website to make time capsule playlists of your most played Spotify tracks for the last month!

Uptime Robot ratio (30 days) LGTM Grade LGTM Grade GitHub stars

About

When I started college, I got the advice from a good friend to make CDs of all the songs I listened to each semester so I could listen to them years down the line and be transported back. It was a great idea (after I decided to exchange "CDs" for "playlists"), but I had a hard time remembering to keep tracks of songs as my tastes changed, and I quickly started finding holes in my self-recorded music history. To solve that problem, I created Mix Capsule.

Once you login with Spotify, Mix Capsule will deposit a playlist in your library every month containing your most listened to songs for that month. Now, whenever you want to kick back and listen to music that reminds you of the past, flip through your Mix Capsule playlists and see what you were listening to 1 month, 6 months, or even a year ago.

Tech Stack

Frontend

Mix Capsule utilizes NextJS on the frontend with Tailwind for styling, Material UI for buttons, Ionicons for icons, and Drift for live chat.

Backend

Mix Capsule uses Django and Django Rest Framework on the backend with an sqlite database.

Deployment

The frontend is deployed with Vercel. The backend is deployed to a DigitalOcean droplet running an Apache webserver. Apache runs a WSGI proxy to send requests to Django. Additionally, monthly playlist creation is scheduled by systemd timers, which are preferable over cron jobs since they handle system down-time gracefully.

API interactions

When interacting with the Spotify API, Mix Capsule uses the "authorization code" flow so that the backend can save a refresh token and continue to act on the user's behalf even after they've left the site. This is what allows monthly playlist creation with no intervention from the user.

Setting up Local Development

Environment

cp .env.example .env
nano .env # Follow the instructions in the file to fill in secrets
source .env

Backend

python3 -m venv venv
source venv/bin/activate
python -m pip install -r requirements.txt
cd backend
python manage.py migrate
python manage.py runserver

Frontend

cd frontend
npm i
npm start

Services/Scripts

cd scripts
chmod +x trigger-month.sh

cd ../services
mv TriggerMonth.service.example TriggerMonth.service
nano TriggerMonth.service # Fill in missing information
sudo systemctl link /full/path/to/TriggerMonth.service
sudo systemctl enable /full/path/to/TriggerMonth.timer