Skip to content

Commit

Permalink
feat: add readme
Browse files Browse the repository at this point in the history
  • Loading branch information
mashb1t committed Jan 26, 2022
1 parent 58fe839 commit 9ddc6f9
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# SpotiSights - Spotify Insights

This project displays (soon to be sexy) Spotify Insights via Grafana.

It uses a PHP Script for fetching data from the Spotify API and saves it to InfluxDB.

## Setup

It is advised to use a PHP website serving tool of your choice, such as [Laravel Valet].

1. Copy ``configuration.env.dist`` to ``configuration.env`` and change the credentials
1. Copy ``php/.env.dist`` to ``php/env`` and change the credentials
2. Run ``docker-compose up -d`` to provision Grafana and InfluxDB
3. Log in to the [Spotify Developer] website
4. Set up a new Spotify App, save client id and client secret on your local machine
5. Set up static website serving by using ``cd php && valet link spotisights``
6. (optional) Make your connection secure by executing ``valet secure``
7. Edit your Spotify App and add the callback URL ``https://spotisights.test/callback.php`` (http when not securing the connection)

## Data Flow

1. Call https://spotisights.test/ and follow the displayed auth flow (technical reference: [Authorization Code Flow])
2. app.php will be called which collects recent tracks fron the logged in user, saves them to InfluxDB and prompts "done" when finished
3. Open Grafana at http://localhost:3000/ and navigate to the Dashboard "spotisights" (http://localhost:3000/?orgId=1&search=open)

## Auth

This app implements the [Authorization Code Flow] of Spotify with [Refresh Tokens] by using file sessions.


## References

### Spotify API
- https://developer.spotify.com/console/get-recently-played/?limit=2&after=&before=
- https://github.com/jwilsson/spotify-web-api-php

### InfluxDB
- https://github.com/influxdata/influxdb-client-php

[Authorization Code Flow]: https://developer.spotify.com/documentation/general/guides/authorization/code-flow/
[Laravel Valet]: https://laravel.com/docs/master/valet
[Refresh Tokens]: https://github.com/jwilsson/spotify-web-api-php/blob/main/docs/examples/refreshing-access-tokens.md
[Spotify Developer]: https://developer.spotify.com/dashboard/
4 changes: 2 additions & 2 deletions grafana/dashboards/spotify-insights.json
Original file line number Diff line number Diff line change
Expand Up @@ -486,8 +486,8 @@
]
},
"timezone": "",
"title": "Spotify Insights",
"uid": "spotify-insights",
"title": "SpotiSights - Spotify Insights",
"uid": "spotisights",
"version": 2,
"weekStart": ""
}

0 comments on commit 9ddc6f9

Please sign in to comment.