Build an E-commerce AI Assistant That Gives the Right Answers
Imagine you own Varastra, an online store that sells Indian ethnic wear, such as cotton kurtas, sarees, and festive outfits.
A customer asks:
“I need a lightweight cotton kurta for summer, suitable for office wear, under ₹1,500.”
How can Varastra's AI assistant recommend the right product without making up product details?
Let's understand the architecture, one component at a time.
1. Customer
The customer tells the assistant what they want to buy.
Example: “I need a cotton kurta for office wear under ₹1,500.”
The assistant must understand these requirements before recommending products.
2. FastAPI — The Request Handler
FastAPI receives the customer's question and sends it to the right components.
Think of it as a receptionist who receives a request and directs it to the right team.
3. Embedding Model — Understands Meaning for Search
It converts the question into numbers so the system can find products with similar meanings.
For example, “clothes for hot weather” might match a product described as “lightweight cotton wear.”
4. Retriever — Finds Matching Products
It searches the available product information and selects the most relevant results.
It helps find cotton kurtas instead of unrelated products, such as silk festive outfits.
5. ChromaDB — Stores Searchable Product Information
It stores product descriptions in a form that makes searching by meaning possible.
For Varastra, this could include fabric, color, style, and occasion.
Current prices and stock should be checked against the actual store database.
6. Prompt Builder — Prepares Instructions and Information
It combines the customer's question, product details, and rules for answering.
For example: “Recommend products using the supplied information. Do not invent prices or product details.”
7. GPT-4o-mini — Writes the Answer
The AI model uses the supplied information to explain why a product matches the customer's needs.
It makes the response easy to read, but it must not invent missing facts.
8. Grounded Answer — The Final Response
The assistant returns a recommendation that the application can display to the customer.
The backend should verify important details, such as the product ID, current price, and availability, before displaying them.
What happens when no product matches?
Imagine a customer asks:
“Show me a cotton kurta under ₹500.”
Varastra's search finds no suitable product.
The assistant should not invent a product just to answer the question.
Instead, it could say:
“I couldn't find a matching kurta under ₹500. Would you like to see options at a higher price?”
This is called handling a grounding failure — the system does not have enough evidence to give the requested answer.
How do we check whether the AI gives correct answers?
The diagram includes RAGAS Evaluation. In simple terms, it helps us test whether the AI is using the retrieved information correctly.
For example:
- Faithfulness: Did the AI make claims supported by the product information?
- Context Precision: Did the search return useful information rather than unrelated products?
Suppose the actual product price is ₹1,799, but the assistant says ₹1,299. That is a failure, even if the rest of the answer sounds convincing.
Varastra should test these situations before making the assistant available to customers.
What is the Grounding Layer?
The Grounding Layer is the group of components that helps the AI find and use relevant information before answering.
It includes the embedding model, ChromaDB, retriever, product chunks, and prompt builder.
Without this layer, the AI might rely on its general knowledge and give answers that do not match Varastra's actual catalog.
With this layer, the system can use relevant product information to answer customer questions more reliably.
Remember this simple idea:
- The database stores product information.
- The search system finds relevant information.
- The AI explains that information to the customer.
- The application checks important facts before showing the result.
That is how Varastra can build an AI shopping assistant that helps customers find the right products without making up product details.
