Menu Customization#
Menu DB#
Understanding Menu DB#
The menu database JSON can be modified to add, remove or update an existing item. Each item within the menu is composed out of a Json schema which defines that menu item. A sample schema for food item “french fries” is shown below.
{
"_id": {
"$oid": "614fb0b1e80afa927e4267ca"
},
"menu_item": true,
"recommendation_type": [
"toppings"
],
"synonyms": [],
"tags": [
"fries",
"vegetarian"
],
"variations": [
{
"name": "",
"size": "small",
"calories": 300,
"price": 2.69,
"description": "A deep fried treat for potato lovers, made of waffle-cut potatoes. It is cooked in canola oil until crispy outside and tender inside. Sprinkled with sea salt for maximum flavor.",
"image": "images/sides-menu/sides-menu-french-fries.png",
"is_default": true
},
{
"name": "",
"size": "medium",
"calories": 400,
"price": 2.99
},
{
"name": "",
"size": "large",
"calories": 500,
"price": 3.39
}
],
"ingredients": [
"potatoes",
"salt",
"oil"
],
"toppings": [
"garlic",
"chili cheese"
],
"name": "french fries",
"item_id": "6",
"category": "sides"
}
Where:
_id [Dict]
- Stores unique id$oid [Str]
- hexadecimal unique id for each entry in menumenu_item [Bool]
⇒ set to False if you don’t want to show the item over UI as a separate item (for ex, toppings, ingredients), otherwise Truerecommendation_type [List[Str]]
⇒ Reserved for future usesynonyms [List[Str]]
⇒ Alias name, if any, for this itemtags [List[Str]]
⇒ tags based on restrictions, specification etc., (For ex, vegan)variations [List[Dict]]
⇒ Defining all possible variationsname [Str]
⇒ Reserved for future usesize [Str]
⇒ corresponding size of variation (For ex, small)calories [Int]
⇒ total caloriesprice [Float]
⇒ total pricedescription [Str]
⇒ description of the food item (optional if is_default not set)image [Str]
⇒ image location in NGC registry (optional if is_default not set)is_default [Bool]
⇒ if available and set to True, this variation would be added to the cart if the user doesn’t mention a specific variation size
ingredients [List[Str]]
⇒ all ingredients present, ensure that ingredients are also added as separate food items in menu with menu_item=False)toppings [List[Str]]
⇒ all available toppings, ensure that toppings are also added as separate food items in menu with menu_item=False)name [Str]
⇒ name of the food itemitem_id [Str]
⇒ unique alphanumeric item idcategory [Str]
⇒ category of food item to which current item belongs to
All of the key-value pairs for a particular item are mandatory . So while updating OR adding a new menu item , make sure that all the default key-value pairs are present.
Modifying Menu DB#
Downloading DB#
Download the current menu DB used for the deployment. This can be done by running the following command. :
$ ngc registry resource download-version "<NGC_RESOURCES_REPO>/tokkio_menu::<TAG>"
The downloaded DB can be modified based on needs.
Adding an Item#
To add a new item, simply copy the schema definition of one of the items already present and modify it based on your needs. Make sure that you manually modify the keys $oid
and item_id
such that no two items in the menu json have the same set of keys (both $oid
and item_id
).
If a new topping or ingredient is added to an item that is not already present in the menu, you will need to add that topping or ingredient as a separate item in the menu JSON (similar copy paste again with unique ids). For the toppings or ingredients set menu_item=False
, for actual menu items menu_item=True
.
Once all the changes are done, save the new JSON file.
Removing an Item#
To remove an item, just remove its corresponding JSON definition. Save the new JSON file.
Modifying an item#
Modify the information according to the requirements without modifying the $oid
and item_id
keys. Save the new JSON file.
Updating Menu Tag (Example)#
Lets take an example to add a new tag to menu items, lets say we want to add “tangy” as one of the tags to Lemonade. In this scenario, once the current menu DB is downloaded, open the JSON definition file and look for “Lemonade”. Now within its definition schema, look for “tags” which is a list of string. Here, append “tangy” as a new tag. Follow instructions in Uploading Menu DB and Updating Tokkio Deployment sections.
Uploading Menu DB#
To upload the updated menu DB with a new tag, execute the following command (Please make sure you have write access to the NGC resources repo):
ngc registry resource upload-version <NGC_RESOURCES_REPO>:<TAG> --source new_menu.json
Updating Menu Images#
The menu image registry must be updated if any food image needs to be added or modified. To do that, follow the steps below:
Run below commands to generate the UI production build. A “build” directory will be generated:
npm install npm run build
2. Make a new /images
directory and put it inside the /build
directory of the UI. The subfolders in this directory should be equal to image_loc
field in API response from UI server. For example, the API response from GET: category/item/23
will have an image_loc field. Suppose image_loc field is equal to images/image-category/item23.png
. Then UI should have an image for item 23 at directory /public/images/image-category/item23.png
This should be followed for all items in the menu.
3. The new /images
directory should replace existing image directory in /build/images
.
4. Upload updated build directory to S3 bucket:
aws s3 sync ./build s3://tokkio-ui
Serve the newly generated static files in
/build
directory.
Updating Tokkio Deployment#
When Menu DB is Updated#
Edit the parameters YAML file: update the menu registry under service name tokkio-menu-api
.
tokkio-menu-api:
NGC_MENU_REGISTRY: <NGC_RESOURCES_REPO>:<TAG>
Rebuild the UCS app with the updated parameters, and redeploy. The new menu will be downloaded at launch time. For more information, refer to the Quickstart Guide section.
When Menu Images are Updated#
Once the menu images have been updated in UI (Refer to Updating Menu Images section`). The updated UI can be used to re-deploy Tokkio application. For more information, refer to the Quickstart Guide section.
Functionality Customization - Menu Schema, CM, Plugin Server and UI#
The Tokkio QSR reference application expects the user to stick to the menu schema and API flow as defined in the Tokkio QSR Micro Services (MS). However, if needed these can be modified to incorporate any new requirements. In most of the cases changes would be needed across Plugin Server, CM, Menu and UI and their APIs. For example, if a new information is added into the DB, then the user is expected to:
Modify the menu database, push the menu database as a new registry.
Plugin Server logic and API schema would need to be modified if we expect the bot to respond to queries corresponding to the newly added information.
Update the menu MS definition to allow it to filter or re-order based on the new information and pass this info along over the exposed APIs to CM and Plugin server and re-build the MS.
Update Cart Manager and its APIs (in-coming and out-going) to store the information in data dict and pass it along to UI server for rendering. Followed by re-building CM MS.
For rendering, UI server is expected to wrap this new info under the cart and/or page view payload for UI front end. Re-build UI MS.
Based on user’s requirement on how and where the data needs to be presented, the UI front end source and a new MS is built
The user is expected to build the Tokkio UCS app using the newly built versions of these micro services and deploy the app.
Note
Sources for Menu, Cart Manager, UI Server and Plugin Server are available on NGC.