Giter VIP home page Giter VIP logo

beatdrinks's Introduction

Issues License

Description

A simple API that returns a song / playlist and a matching cocktail for a given mood.

This project was originally a university project as an introduction to web development. Our idea was to create an API that returns a song / playlist via Spotify and a matching cocktail for a given mood. Since this was a university project a simple json File with some cocktails and a very simple matching algorithm did suffice.

We still think that this is a fun idea, thats why this project is now being revived. There are still a lot of things to be done and help is greatly appreciated (remember that this was a university project... The code might not be the greatest but it is working. And that's what counts... Right?? ;) ).

Setup

To run this project locally some things have to be done:

  1. You have to create a Spotify API App to receive a client secret and id (see Spotify API)
  2. Clone or fork this project
  3. Add a .env file in the projects root with the following variables:
    • CLIENT_SECRET (your Spotify API Client Secret)
    • CLIENT_ID (your Spotify API Client Id)
  4. Run npm install to install the dependencies
  5. Run npm start to start the API

Now you should be able to get a track and cocktail combination from the API (see Routes for more information on how to get the data).

Routes

These are the current available routes and how to use them:

/combination/track?mood

Get a single Track paired with a cocktail, if the mood query parameter is not provided the default mood (happy) will be used.

/combination/playlist?mood

Get multiple Tracks paired with a cocktail, if the mood query parameter is not provided the default mood (happy) will be used.

Important

The code of this API might change a lot over the course of the next few weeks. This includes the routes and the responses. Because of that this API should not be used in a project as a dependency (yet), until we have achived a stable code base.

The last commit that could be seen as belonging to the original university project is 817337c. This commit merges some project clean up efforts by @nickcrisci. This did not change the original functionality of the API.

beatdrinks's People

Contributors

dependabot[bot] avatar nickcrisci avatar paul-johne avatar sebastianbroc avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

beatdrinks's Issues

Mehrbenutzer Betrieb

Hi Markus,
wir stehen vor dem Problem, dass wir uns unsicher sind wie wir mit mehreren Nutzern umgehen sollen.
Im unseren Webservice kann man bspw. Präferenzen festlegen, das Problem ist jetzt jedoch wie wir diese abspeichern sollen.
Bekommt jede Präferenz bzw. Liste von Präferenzen eine eindeutige ID und der jeweilige Nutzer kann nur auf die Liste mit der entsprechenden ID zugreifen, ODER ist ein Nutzer eingeloggt und die Variablen gehören daher sowieso zu diesem Nutzer?
Allerdings würde solch eine Nutzerverwaltung ja unsere jetzigen Programmierkentnisse übersteigen.

Unbenannt
(nach Stand auf dem Bild wären die Präferenzen theoretisch global und demnach für alle Nutzer gleich)

Die dritte Möglichkeit wäre, den Code einfach so zu schreiben, als wäre es nur ein Nutzer.

Welche der Varianten ist für dieses Projekt gewünscht und soll demnach umgesetzt werden?

Vielen Dank im Voraus

"Cannot find request module" in proof_of_concept.js

Als ich den Code ausführen wollte, stellte ich fest, dass mir scheinbar etwas fehlt.
Ich werde in der Dokumentation von Spotify mal nachschauen, jedoch sollten wir dieses Problem lösen, da das proof_of_concept nicht einfach so ausführbar ist.

Matching Algorithm

Currently the matching of a mood and a drink is done rather random. Since this project is originally a university project a proof of concept did suffice. Therefor we decided for ourselves which drink matches with a certain mood. There is currently no real matching algorithm.

A matching algorithm could make use of the drinks description and match certain keywords to a mood. This would mean, that the description of each cocktail would have to be parsed.

Another solution would be to associate certain alcohols with certain moods. This way the cocktail database could be searched for drinks with the alcohol as an ingredient. Since moods can't just be randomly associated with certain alcohols a scientific approach would be preferred (maybe there are papers that examined the correlation between different alcohols and moods?).

Fragen für den Beratungstermin am 20.11.2020

1. Ist der begonnene Weg zur Domänenerschließung ersichtlich?

Wir sind bei unserer Domänensuche auf das Problem der Kombination von Cocktail & Musik im Barsektor gestoßen. Da nicht jeder Besucher einer Bar nicht seine explizit nur seine eigene Musik wahrnehmen kann, fällt dies vermutlich schon raus. Da wir allerdings "nur" eine eher "neutrale" Backend-Idee realisieren, würde die konkrete Umsetzung eher ein Problem des Frontends sein, oder?

  • beantwortet

2. Ist die Eingrenzung der APIs, welche sich im Wiki-Protokoll vorfinden soweit für eine solche Idee von Vorteil?

Link zum Wiki-Protokoll

  • beantwortet

3. Um Eigenschaften der Cocktails festzulegen, haben wir uns dazu entschieden, eine eigene JSON-File mit Daten sämtlicher Cocktails zu schreiben. Ist dieses Format gut, um auf eine "Datenbank" zurückzugreifen?

  • beantwortet

Aufpolieren des Projektes

Aufpolieren

@Paul-Johne @sebastianbroc ich habe vor das Projekt mal ein wenig aufzupolieren. Also Refactoring zu betreiben, vielleicht die Dokumentation ein wenig aufzuräumen und mehr.
Die Idee dahinter ist, dass wir das Projekt in unser persönliches Portfolio aufnehmen können (falls gewollt).

To-Do

Hier sind ein paar meiner persönlichen Todos, ihr könnt gerne in der Diskussion des Issues noch weitere Punkte hinzufügen.

  • Code Linting (z.B. durch ESLint)
  • Secrets (z.B. Spotify Client Secret etc...) aus dem Code auslagern
  • Dokumentation verbessern
  • Funktionalität hinzufügen (von uns angedachte Ideen, die wir im Projekt noch nicht umgesetzt hatten)

Ausarbeitung des URL Generators

https://github.com/nickcrisci/GDWWS2021_Crisci_Johne_Brock/blob/696e4f9242c221c0aa522559c280e0da01a7912c/lib/modules/urlGenerator.js#L43

Durch das Hard Coding der URL ist der Generator noch nicht generisch genug.
Zu Schönheitszwecken kann/sollte das Query-Symbol erst an die URL gehangen werden, wenn der erste Parameter angehangen wird.
Außerdem sollte an einem Punkt der Logik das angegebene Genre mit der spotifyGenres.json geprüft werden. @sebastianbroc sollte diese Aufgabe übernehmen, da er bereits eine ähnliche Umsetzung gelöst hat.

Neuklonen des Repositories ist erwünscht

Durch den letzten Commit von Nick ist sämtlicher Code, den ich die letzten Tage geschrieben habe, verschwunden.
In der Commithistory sieht man gut, dass ich gewisse Dateien am 14.2. geändert habe.
Im Repository stand beim spotifyPlayground "geändert vor 11 Tagen". (bereits gefixt)

Scheinbar wurden meine Änderungen durch Nicks push rückgängig gemacht.
Jedenfalls habe ich das Repository nun gefixt und ich bitte euch diese Version zu klonen.
Die neue Version des urlGenerators wurde bereits implementiert.

Cocktail Database

Currently the "cocktail database" is a simple json file with some crawled cocktails in a single language (german). The problem with this is, that the data is incosistent and hard to translate to other languages.

A better aproach would be to incorporate a cocktail database (or api). By using an already existing database or api the data would be easier to maintain and possible already in mutiple languages.

Additional context
It is important, that the data provided by the database or api allows for some way of matching the drinks to a mood (e.g. by associating a certain alcohol with a certain mood, or correlating certain keywords in the drinks description to a mood).

Schnittstellenmodellierung

Hallo zusammen. Habt ihr eine Schnittstellenmodellierung vorgenommen? Wenn ja, wo finde ich diese in eurem Repository?

URI Tunneling Parameter für Spotify Recommendation-Anfrage

Spotify möchte nur BIS ZU 5 SEEDS für die GET Recommendations erhalten. Da wir keine spezifischen Artists und Tracks vorgeben wollen, greifen wir NUR mithilfe der Genres auf die Schnittstelle zu.
Unter lib/data/spotifyGenres.json finden sich alle aktuell verfügbaren Genres.

Zudem sollte der Parameter limit und evtl. market angegeben werden, weil:

  1. market: gewisse Songs sind evtl. in einem Land für den Endnutzer nicht verfügbar, aber in der Liste enthalten.
  2. limit: default liegt bei 20 Tracks und sollte änderbar sein.

Problem mit dem Datenformat des urlGenerators

Der URL Generator enthält aktuell folgenden Code, um an die URL die gewollten Properties anzuhängen:

    for (const property of properties) {

        if (!property["name"]) {
            return callback(new Error("Name of the property is missing"));
        }
        if (!property["value"]) {
            return callback(new Error("Value of the property is missing"));
        }

        let suffix = `&${property["name"]}=${property["value"]}`;

        queryUrl += suffix;
    };

Eine beispielhafte (auf Beatdrinks) zugeschnittene URL sollte so aussehen:

https://api.spotify.com/v1/recommendations?limit=3&market=US&seed_genres=disney%2C%20movies

Die einzelnen Attribute sind mit & getrennt, während mehrere Seed per %2C%20 getrennt werden.
Außerdem ist mir die genaue Übergabe der Property-Liste nicht bekannt.
Meine Ideen waren:

  1. Als Objekt: {limit: 2, market: "US", seed_genres: "disney", seed_genres: "movies"}
  2. Als Array: [limit = 2, market = "US", seed_genres = "disney", seed_genres = "movies"]

Eventuell kann man mit ...args die Elemente übergeben, ich bin mir allerdings gerade nicht mehr ganz sicher.

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.