Smart Grocery Sorter: Building a Serverless AI App with Amazon Bedrock
Have you ever created a grocery shopping list only to spend extra time organizing it into categories before heading to the supermarket?
I built Smart Grocery Sorter, a lightweight AI-powered web application that automatically organizes grocery items into meaningful categories using Amazon Bedrock and AWS serverless services.
Simply enter your grocery items, click Sort List, and let AI organize everything for you.
๐ Live Demo: https://gs-ai-jyog.netlify.app/
๐ป GitHub Repository: https://github.com/GunnerJyo/grocery-sorter-ai
๐ก The Idea: Automating a Small Everyday Annoyance
A typical grocery list might contain fruits, vegetables, dairy products, grains, meat, and household supplies, all mixed together.
Manually organizing these items takes time, especially when the same task needs to be repeated every week.
I wanted to solve this problem by building an application that could:
- Automatically categorize grocery items.
- Accept a simple, newline-separated shopping list.
- Use generative AI to understand different grocery items.
- Display organized results directly in the browser.
- Run on serverless infrastructure without managing servers.
The result was Smart Grocery Sorter: a simple application that turns an unorganized list into a structured shopping list within seconds.
๐๏ธ Architecture Overview
I chose a serverless architecture to keep the application lightweight and minimize infrastructure management.
User
|
v
HTML / CSS / JavaScript
(Netlify)
|
| HTTP POST
v
Amazon API Gateway
|
| Invoke
v
AWS Lambda
(Python)
|
| Prompt
v
Amazon Bedrock
(Amazon Nova Lite)
|
| Categorized Items
v
AWS Lambda
|
| JSON Response
v
Amazon API Gateway
|
v
Frontend
The frontend is hosted on Netlify, while the backend logic and AI processing run on AWS.
AWS Services and Technologies Used
| Service / Technology | Purpose |
|---|---|
| Amazon Bedrock | AI-powered grocery categorization |
| Amazon Nova Lite | Foundation model for processing the list |
| AWS Lambda | Serverless Python backend |
| Amazon API Gateway | HTTPS API endpoint |
| Netlify | Frontend hosting |
| IAM | Access control and permissions |
| HTML, CSS, JavaScript | User interface |
| Python | Backend application logic |
โ๏ธ How the Application Works
The application follows a straightforward request-response workflow.
1. Enter grocery items
The user enters one item per line in the web interface.
For example:
Apples
Milk
Bread
Tomatoes
Chicken
Rice
Dishwashing liquid
Cheese
2. Send the request
When the user clicks Sort List, JavaScript collects the input and sends a JSON payload to Amazon API Gateway using the Fetch API.
3. Process the request with Lambda
API Gateway invokes the Python Lambda function. The function extracts the grocery items and constructs a prompt for Amazon Bedrock.
4. Categorize items using AI
Amazon Nova Lite processes the list and organizes the items into relevant grocery categories.
5. Return the results
Lambda formats the model's response as JSON and returns it through API Gateway.
6. Display the organized list
The frontend receives the response and displays the categorized grocery items in the browser.
The entire process happens within seconds, without requiring the user to manually organize the list.
๐ง Why Amazon Bedrock?
One of the main goals was to experiment with generative AI in a practical application rather than building a traditional rule-based categorization system.
Amazon Bedrock provides access to foundation models through a managed service. In this project, I used Amazon Nova Lite to interpret grocery items and determine appropriate categories.
This approach helps handle different kinds of items without maintaining a large collection of manually defined categorization rules.
For example, the model can organize items into categories such as:
- ๐ Fruits
- ๐ฅฆ Vegetables
- ๐ฅ Dairy and Eggs
- ๐พ Grains and Bakery
- ๐ฅฉ Meat and Seafood
- ๐งด Household Supplies
The exact categories depend on the items provided and the model's response.
๐ ๏ธ Challenges I Encountered
Building the application involved a few practical debugging and integration challenges.
1. Handling Different Lambda Event Formats
Initially, my Lambda function expected requests in the format generated by API Gateway.
However, when I tested the function directly through the Lambda console, the
Top comments (0)