Other Services - Yorbre25/P3SOA_MY_microRESTaurant GitHub Wiki

Recommendation System

Operation

This function, given a user input consisting of some menu choices, provides recommendations for the requested type of item.

There are three types of items on the menu

  • main_dish
  • drink
  • dessert

The user can choose up to two of the above elements from our menu and request a recommendation for the remaining type of item. They can also choose only one item and request recommendations for the other two. Finally, as an extreme case, they may have no preferences and request recommendations for all three items. Or they can enter all three dishes, in which case nothing will be recommended to them, and they will simply be redirected to the dishes they already provided.

Input

As input the user must send a json with the following structure

{
    "meal":{
        "main_dish":"Pizza",
        "drink":"",
        "dessert": "ice cream"
    },
    "recommendation_of":["drink"]
}

It is worth mentioning that when sending inputs, this service performs input validations. In this case, it is verified that "meal" is an object with the specified fields, and furthermore, these fields must each have a string value. On the other hand, it is verified that "recommendation_of" exists and its value must be a list of strings, where the only possible valid strings are: "main_dish", "coke", and "dessert".

Output

   {
    "main_dish":"Pizza",
    "drink":"coke",
    "dessert":"ice cream"
   }

Function in the system

In the following image you can see the request's flow in which the function participates. In this case this functions its called when a suggestion its requested by the frontend to the backend. As you can see in the figure, the only service the recommendation services interacts in a direct way its the backend. As discussed previously the recommendation service, given the restaurant menu, and the selected inputs by sent by the front end, shows the menu suggested for consumption

Sentiment Analysis

Operation

This function recieves input message from a client, supposedly a review for the service in the restaurant and returns a msg to show and scale, so the front end can show the client a response for his/her review. Once received, this services, using the authorization token, request to the AI model to evaluate the service review message a value in a scale from 0 to 4, where 0 its the assigned to the worst experiences whereas the 4 its related to the best experience. You can picture it as 0 being 1 start review while 5 being 4 start review

Input

The function recieves a json with the following structure
{
    "review":"Incredible experience. The food was so tasteful"
}

input type validation its applied. The review key must exist and the value must be an string. An empty string will no return and error status code, but will show a scale 0 msg: Error

Output

{
    "msg": "Wow! We're thrilled to hear that you had an outstanding experience with our service. Thank you for your support!",
    "scale": 4.0
}

Function in the system

The following figure show the flow that the system follows once a front end request for a review's sentiment analysis. As reflected in the image, the API service only has direct interaction with the Sentiment Analysis AI model and the backend