With the new capabilities added in HeatWave GenAI such as HeatWave GenAI native JavaScript support and multi-lingual support, we extend the E-Commerce application introduced in Part 1 to further improve user purchasing experience:
- Automatically analyze the sentiment of user submitted reviews.
- Automatically summarize and translate two separate summaries for reviews with positive and negative sentiments.
Before reading, feel free to watch the demo!
Application Architecture
We use the same architecture for the e-commerce application as in Part 1 of the blog. This means Next.js serves as the front-end web server and Strapi serves as the middleware. HeatWave GenAI’s in-database LLMs are accessed through the in-database JavaScript GenAI API, providing a user-friendly developer experience. .

Schema
We use the same schema as a base from the earlier blog.
- Languages
- Products
- Product Descriptions
- Customers
- Reviews
- Orders
- Order Items
The only change we make is to add a sentiment field in the “Reviews” table for the product reviews.
Use Case 1 : Analyze the sentiment of reviews
Reviews submission
In the E-Commerce application, in addition to using pre-generated reviews for the demo, we now allow users to submit their reviews. These submitted reviews undergo a standard moderator approval process before being added to the “Reviews” table. After inserting the review, we also invoke a JavaScript stored procedure to invoke HeatWave in-database LLM to determine the sentiment of the review. Once the LLM responds with the sentiment, the sentiment field is updated for the same review as an additional step. By storing the raw review separately from the sentiment analysis, we ensure that the review persists at the earliest opportunity.

Sentiment Analysis
Once the moderator approves the submitted review, a stored procedure is invoked to perform three tasks:
- Compute review sentiment using in-database LLM.
- Process the response from LLM.
- Update the sentiment of the review in the database.

All the steps are implemented using JavaScript stored procedure. First, we construct a prompt using a natural language string command. This prompt is then given to the JavaScript HeatWave GenAI API “ml.generate”. The raw sentiment returned from LLM is subsequently processed to convert a probabilistic LLM response into a deterministic value, which is used to update review sentiment in the database.
Rendering product page
Once the review and sentiment data are stored, , the product page can use this information to show a summary of reviews. Instead of showing a single summary for all reviews, the blog shows two seperate summaries for reviews with positive and negative sentiment. This approach ensures that potential customers can see summaries from both satisfied and unsatisfied customers, preventing any one-sided viewpoint that could mislead them.

Use case 2: Summarization & Translation
Now we explore how the review summaries can be translated to a different language before being presented on the website.
After accumulating reviews in the database we invoke a stored procedure to compute the summary and translation. The JavaScript stored procedure implements the following tasks:
- Retrieves all reviews with the same sentiment for a given product.
- Aggregates all reviews of the same sentiment by concatenating the reviews.
- Uses the aggregated reviews as a prompt to invoke the HeatWave in-database LLM to retrieve a summary.
- If the target language is English, then the stored procedure’s task is complete. Otherwise, the produced summary is used in a subsequent prompt for translation into the target language.

The JavaScript stored procedure is invoked twice: once for “POSITIVE” sentiment and once for “NEGATIVE” sentiment.
Benefits
In-database Javascript support and its integration with HeatWave GenAI offer additional benefits to HeatWave GenAI capability:
- Data and processing stay close as they are colocated in the database. During the entire flow of review submission and summarization, the data never leaves the database, even when the LLMs are prompted multiple times. This provides enhanced data security to protect valuable customer data.
- The JavaScript implementation is very intuitive and requires minimal coding effort. This is especially useful during pre-processing the LLM prompt and post-processing LLM’s response.
- Invoking the GenAI JavaScript API is as simple as invoking a JavaScript method, without needing to know the SQL interface.
Create your E-Commerce application
The JavaScript code for this demo e-commerce application is available on Github. Feel free to download the sample code and data to try out HeatWave GenAI or create your own e-commerce application.
Conclusion
In this blog, we show how easy it is to develop rich GenAI applications with HeatWave. Organizations can seamlessly build new class of applications where all necessary components are available within HeatWave – OLTP, JavaScript, analytics, AutoML, GenAI. In addition, all components in HeatWave are integrated, data and processing of the data stay inside HeatWave. This enables organizations to develop secure applications at low cost. Using HeatWave GenAI, organizations further improve and personalize their end user experience, which in turns improve sales.

