Skip to content

AI-powered chatbot for querying supplier and product data using natural language. Built with React, FastAPI, and OpenAI.

License

Notifications You must be signed in to change notification settings

KrDevanshu06/query-chatbot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Query-Chatbot🤖

An intelligent chatbot that allows users to query product and supplier data using natural language. Built with React (frontend), FastAPI (backend), and integrated with OpenAI for data summarization.

Features

  • Natural Language Queries: Ask questions like:
    • "Show me all products under brand X"
    • "Which suppliers provide laptops?"
  • Supplier Data Summarization: Enhanced responses using LLM (OpenAI GPT-3.5/4).
  • Product & Supplier Search: Query structured data from MySQL/PostgreSQL.
  • Responsive UI: Modern chat interface with query history panel.
  • REST API: Fully documented endpoints with Swagger UI.

Tech Stack

Backend
FastAPI
Python
SQLAlchemy
MySQL
OpenAI

Frontend
React
TypeScript
MaterialUI
Vite

Installation

Backend Setup

# Clone the repository
git clone https://github.com/yourusername/ai-chatbot.git
cd ai-chatbot/chatbot-backend

# Create and activate virtual environment
python -m venv venv
source venv/bin/activate  # Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Set up environment variables
cp .env.example .env  # Update values in .env

Frontend Setup

cd ../chatbot-frontend
npm install

Configuration

  1. Database: Update .env with your MySQL/PostgreSQL credentials:

    DATABASE_URL=mysql+pymysql://user:password@localhost:3306/chatbot_db
  2. OpenAI: Add your API key for LLM features:

    OPENAI_API_KEY=your_api_key_here
  3. Initialize Database:

    -- Run via MySQL Workbench or CLI
    CREATE DATABASE chatbot_db;
    USE chatbot_db;
    SOURCE database/init.sql;

Usage

  1. Start Backend:

    cd chatbot-backend
    uvicorn app.main:app --reload
  2. Start Frontend:

    cd chatbot-frontend
    npm run dev
  3. Access the chatbot at http://localhost:5173.

API Documentation

Interactive documentation available at http://localhost:8000/docs:

Endpoint Method Description
/api/v1/products/{brand} GET Get products by brand
/api/v1/suppliers/{category} GET Get suppliers by product category
/api/v1/suppliers/{id}/summary GET Get LLM-summarized supplier info

Example Response:

{
  "summary": "Supplier A specializes in Electronics and Laptops. Contact: contact@supplierA.com"
}

Deployment

  1. Frontend:
    Deploy with Vercel

  2. Backend:
    Deploy to Render or AWS EC2 with:

    docker build -t chatbot-backend .
  3. Database: Use PlanetScale or AWS RDS.

Contributing

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

License

MIT License - see LICENSE


Need Help?
Open an issue or contact krdevanshu06@rediffmail.com


Key Features

  • Clear installation instructions
  • Badges for tech stack visibility
  • API documentation table
  • One-click deployment buttons
  • Mobile-responsive formatting
  • License and contribution guidelines

About

AI-powered chatbot for querying supplier and product data using natural language. Built with React, FastAPI, and OpenAI.

Topics

Resources

License

Stars

Watchers

Forks