2. API descriptors¶
The React front-end has access to mapping coordinates reflecting product categories, countries and indicators. See project root static_assets:
- final_countryTree_exiovisuals.csv
- final_productTree_exiovisuals.csv
- mod_indicators.csv
These mapping coordinates are not only used to render tree selectables, but also to transmit the global id’s of the product categories, countries and indicators over the websocket channel. In turn the back-end handles these messages to perform calculations and store results. For example all countries and all products in the world represent the global id [1]. The indicator [1] represents product output. For further reference see the mapping CSV files.
API routing:
- API URL Websockets:
<domain-ip>/ramascene/
- API URL AJAX:
<domain-ip>/ajaxhandling/
- Interface format: JSON
2.1. Default calculations¶
The following queries denote the communication between front-end and back-end for performing default calculations.
Interface descriptors [websocket message to back-end]:
Stage | Instances relation | Variable name, dataType, example |
---|---|---|
Calculation type | Default calculation |
|
Dimension | Production, Consumption |
|
Visualization | TreeMap, GeoMap |
|
Filter | Product |
|
Filter | Country |
|
Filter | Indicator |
|
Year | Default reference year |
|
All |
|
|
→ to back-end complete payload example:
Interface descriptors [websocket messages from back-end]:
Stage | Instances relation | Variable name, dataType, example |
---|---|---|
Action request status |
|
|
Job status |
|
|
Job status |
|
|
Job name |
|
|
→ from back-end complete response example:
If the websocket message job_status is set to “completed”, the front-end can perform a POST request for results via Ajax containing the job_id named as ‘TaskID’. For example in the above websocket response we see that job_id is 176, the Ajax POST request is ‘TaskID:176’.
Interface descriptors [AJAX response]:
Stage | Instances relation | Variable name, dataType, example |
---|---|---|
Retrieve calculation |
|
|
All |
|
|
All |
|
|
All |
|
|
→ from back-end complete response example:
An important aspect is that in the current version the back-end expects the websocket message to contain a single value for indicator and year. Additionally if the query selection contains “GeoMap” the “nodesReg” descriptor can be an array of multiple elements denoting multiple countries, while the “nodesSec” descriptor can only have a single indicator. On the other hand if the query selection contains “TreeMap” the “nodesSec” descriptor can be an array of multiple elements denoting multiple products, while the “nodesReg” descriptor can only have a single indicator.
2.2. Modelling calculations¶
The following table denotes the communication between front-end and back-end for modelling calculations. Modelling is applied on existing default query selections.
Stage | Instances relation | Variable name, dataType, example |
---|---|---|
Product of interest | Model details : Product |
|
Manufacturing region | Model details : Product origin region |
|
Model type of calculation | Model details : Model type |
|
Region consuming | Model details : Region of consumption |
|
Technological change | Model details : Technical change |
|
The technological change is a single value denoting a percentage. See below for a full query example:
→ from back-end complete response example:
Multiple model selections can be added, however a user can only specify a single-selection per “product”, “originReg”, “consumedBy”, “consumedReg” in the array for this version of the application. The websocket response contains the added model details specified by name.