Jun 2024
6 min read

Lessons Learned Building SarkarBrothers: AI Shopping Assistant with Gemini API

Architecture and optimization strategies for integrating Google Gemini API into an e-commerce platform for intelligent product recommendations and natural language search.

  • AI
  • E-commerce
  • Next.js
  • Gemini API
  • MongoDB
Lessons Learned Building SarkarBrothers: AI Shopping Assistant with Gemini API

Integrating Generative AI into e-commerce goes beyond standard chatbots; it transforms how users discover products. While building SarkarBrothers, a modern toys & gifts purchasing platform, our goal was to allow customers to describe what they are looking for in conversational language and receive instant, tailored product recommendations.

The primary engineering hurdle was ensuring structured and predictable outputs from the AI model. Large Language Models (LLMs) can produce free-form text that easily breaks frontend UI components. By utilizing Google Gemini API's structured JSON response schema and system instructions, we constrained the model to return strict product arrays matching our database schemas.

To optimize performance, we implemented real-time response streaming. Rather than waiting 3-4 seconds for the complete LLM response, token streams are piped directly to React components via Server-Sent Events (SSE). Customers see product recommendations rendered incrementally in under 400ms.

Paired with Firebase Authentication and MongoDB for inventory tracking, the result is a seamless, AI-augmented shopping experience.

Written by Soumyadeep Sarkar

Full Stack & Web3 Developer • GSSoC'25 Mentor