Skip to content

drdhavaltrivedi/grocery-chatbot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›’ Grocery AI - Smart Shopping Assistant

Grocery AI Next.js TypeScript Gemini AI

Order groceries naturally with AI. Chat with our intelligent assistant to add items to your cart, get recommendations, and checkout seamlessly.

πŸš€ Live Demo β€’ πŸ“– Documentation β€’ πŸ’» Installation β€’ 🀝 Contributing


✨ Features

πŸ€– AI-Powered Shopping Experience

  • Natural Language Processing: Chat naturally with the AI assistant - no need to navigate complex menus
  • Smart Product Recognition: Understands product names, quantities, brands, and pack sizes from conversational input
  • Intelligent Clarifications: Asks minimal, focused questions only when needed
  • Context Awareness: Remembers your preferences and previous choices during the session

πŸ›οΈ Shopping Features

  • 18,000+ Products: Extensive inventory with multiple brands and pack sizes
  • Smart Cart Management: Add, update, remove, or clear items with simple commands
  • Upselling & Recommendations: AI suggests complementary products to enhance your shopping experience
  • Real-time Cart Updates: See your cart items instantly with a beautiful drawer interface
  • Seamless Checkout: Complete your order with delivery details and payment options

🎨 User Experience

  • Mobile-First Design: Optimized for mobile devices with responsive layout
  • Dark Theme UI: Modern, eye-friendly dark theme interface
  • Smooth Animations: Polished animations and transitions throughout
  • Auto-Focus Input: Smart input field management for better UX
  • Typing Indicators: Visual feedback when AI is processing your request

πŸ” Smart Features

  • One Question at a Time: AI asks focused, single questions to avoid overwhelming users
  • Smart Pack Size Matching: Automatically matches quantities to available pack sizes
  • Brand Suggestions: Intelligent brand recommendations based on inventory
  • Cart Memory: Remembers your past choices for faster reordering

πŸš€ Getting Started

Prerequisites

Installation

  1. Clone the repository

    git clone https://github.com/yourusername/grocery-chatbot.git
    cd grocery-chatbot
  2. Install dependencies

    npm install
    # or
    yarn install
    # or
    pnpm install
  3. Set up environment variables

    Create a .env.local file in the root directory:

    GEMINI_API_KEY=your_gemini_api_key_here
    NEXT_PUBLIC_SITE_URL=https://your-domain.com
  4. Run the development server

    npm run dev
    # or
    yarn dev
    # or
    pnpm dev
  5. Open your browser

    Navigate to http://localhost:3000


πŸ“ Project Structure

grocery-chatbot/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”‚   └── chat/
β”‚   β”‚   β”‚       └── route.ts          # AI chat API endpoint
β”‚   β”‚   β”œβ”€β”€ globals.css               # Global styles
β”‚   β”‚   β”œβ”€β”€ layout.tsx                # Root layout with SEO
β”‚   β”‚   └── page.tsx                  # Main chat interface
β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ CartDrawer.tsx            # Shopping cart drawer
β”‚   β”‚   └── Checkout.tsx               # Checkout modal
β”‚   └── lib/
β”‚       └── inventory.ts              # Product inventory (18,000+ SKUs)
β”œβ”€β”€ public/                            # Static assets
β”œβ”€β”€ package.json
β”œβ”€β”€ next.config.ts
β”œβ”€β”€ tsconfig.json
└── README.md

🎯 How It Works

1. Natural Language Input

Users type their grocery needs in natural language:

"5 kg rice and 2 liters milk"
"I want toor dal, which brand do you have?"
"Add 3 packs of biscuits"

2. AI Processing

The Gemini AI model:

  • Extracts product names, quantities, brands, and pack sizes
  • Identifies user intent (buy, browse, info, etc.)
  • Asks clarifying questions only when needed
  • Maintains conversation context

3. Smart Cart Management

  • Items are automatically added when fully confirmed
  • Cart state is maintained throughout the session
  • Users can update, remove, or clear items easily

4. Checkout Flow

  • Review order summary
  • Enter delivery details
  • Select payment method
  • Place order

πŸ’¬ Example Conversations

Simple Order

User: "I want 5 kg rice and 2 liters milk"
AI: "Which brand of rice would you like? We have India Gate, Daawat, Fortune, Kohinoor, and Lal Qilla."
User: "India Gate"
AI: "Got it! Which brand of milk? We have Amul, Mother Dairy, Nestle, and Gowardhan."
User: "Amul"
AI: "Perfect! 5 kg India Gate rice and 2 liters Amul milk added to cart. βœ“"

With Clarifications

User: "I need dal"
AI: "Which kind of dal would you like - toor dal, moong dal, or chana dal?"
User: "toor dal, 1 kg"
AI: "For toor dal, which brand? We have Tata Sampann, Rajdhani, and Organic Tattva."
User: "Tata"
AI: "Perfect! 1 kg Tata Sampann toor dal added to cart. βœ“"

Cart Management

User: "show cart"
AI: [Opens cart drawer with items]

User: "change rice to 10 kg"
AI: "Sure, updated rice to 10 kg."

User: "remove milk"
AI: "Removed milk from your cart."

πŸ› οΈ Tech Stack


πŸ”§ Configuration

Environment Variables

Variable Description Required
GEMINI_API_KEY Your Google Gemini API key βœ… Yes
NEXT_PUBLIC_SITE_URL Your site URL for SEO ⚠️ Recommended

Customization

  • Inventory: Edit src/lib/inventory.ts to add/modify products
  • AI Behavior: Modify the system prompt in src/app/api/chat/route.ts
  • Styling: Customize colors and themes in src/app/globals.css

πŸ“± Mobile Optimization

The app is fully optimized for mobile devices:

  • Responsive design that works on all screen sizes
  • Touch-friendly interface elements
  • Optimized chat interface for mobile keyboards
  • Fast loading and smooth animations

πŸš€ Deployment

Deploy to Vercel

  1. Push your code to GitHub
  2. Import your repository in Vercel
  3. Add environment variables in Vercel dashboard
  4. Deploy!

Deploy to Netlify

  1. Push your code to GitHub
  2. Connect your repository in Netlify
  3. Build settings are pre-configured in netlify.toml
  4. Add environment variables
  5. Deploy!

πŸ”’ Security

  • API keys are stored securely in environment variables
  • No sensitive data is exposed to the client
  • Input validation and sanitization
  • Error handling prevents information leakage

πŸ“Š SEO Features

This application includes comprehensive SEO optimization:

  • βœ… Meta Tags: Title, description, keywords
  • βœ… Open Graph: Social media sharing support
  • βœ… Twitter Cards: Twitter sharing optimization
  • βœ… Structured Data: Ready for schema markup
  • βœ… Mobile-Friendly: Responsive and mobile-optimized
  • βœ… Fast Loading: Optimized performance

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“ License

This project is open source and available under the MIT License.


πŸ™ Acknowledgments


πŸ“ž Support

If you have any questions or need help, please:

  • Open an issue on GitHub
  • Check the documentation
  • Review the code comments

Made with ❀️ using Next.js and Gemini AI

⭐ Star this repo if you find it helpful!

About

AI-powered grocery shopping assistant with natural language processing. Chat with AI to order groceries, manage cart, and checkout seamlessly.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors