Skip to content

vkumar04/mcp-ui

Repository files navigation

AI Product Recommendations App

A Next.js application powered by OpenAI that provides intelligent product recommendations based on customer queries. The app uses AI to analyze customer needs and recommend the most suitable products from the catalog.

Features

  • AI-Powered Recommendations: Uses OpenAI GPT-4 to understand customer needs and provide personalized product suggestions
  • Vehicle-Specific Tire Fitment: Automatically recommends the correct wheel and tire sizes based on the customer's vehicle make and model
  • Fitment Style Detection: Intelligently detects desired fitment style (mild drop, aggressive, or bagged) from customer queries
  • Smart Search: Natural language search - customers can describe what they need in plain English
  • Comprehensive Fitment Database: Includes fitment data for 80+ vehicle models from BMW, Nissan, Toyota, Honda, Subaru, and more
  • Product Categories: Currently supports tires and electronics, easily extensible to other categories
  • Beautiful UI: Modern, responsive interface built with Tailwind CSS
  • Detailed Product Cards: Display comprehensive product information including wheel size, tire size, specs, ratings, and reviews

Tech Stack

  • Next.js 15: React framework with App Router
  • TypeScript: Type-safe development
  • Tailwind CSS: Utility-first CSS framework
  • OpenAI API: GPT-4 for intelligent recommendations
  • MCP-UI: Model Context Protocol UI components

Getting Started

Prerequisites

Installation

  1. Clone the repository or navigate to the project directory:
cd product-recommendation-app
  1. Install dependencies:
npm install
  1. Set up environment variables:

Copy the .env.example file to .env.local:

cp .env.example .env.local

Then edit .env.local and add your OpenAI API key:

OPENAI_API_KEY=your_actual_api_key_here
  1. Run the development server:
npm run dev
  1. Open http://localhost:3000 in your browser

Usage

Example Queries

Here are some example queries you can try:

For Tires (with vehicle-specific fitment):

  • Query: "I need performance tires" + Vehicle: "BMW E46 M3" → Automatically recommends 18x9.5 +22 fitment
  • Query: "Looking for winter tires" + Vehicle: "Nissan 350Z" → Suggests winter tires in correct size
  • Query: "I want an aggressive fitment" + Vehicle: "Subaru WRX" → Recommends 18x9.5 +22 options
  • Query: "Need tires for daily driving" + Vehicle: "Honda S2000" → Shows 18x8.5 +35 mild drop fitment
  • Query: "I have a bagged car" + Vehicle: "Toyota GT86" → Recommends 18x10.5 +12 extreme fitment

For Tires (general):

  • "Budget-friendly touring tires for highway driving"
  • "High-performance summer tires for track days"

For Electronics:

  • "I need noise-cancelling headphones for work"
  • "Looking for a laptop for programming"

How It Works

  1. Customer Input: User enters their requirements in natural language and optionally their vehicle info
  2. Vehicle Fitment Lookup: If a vehicle is provided, the system automatically:
    • Identifies the make and model
    • Looks up the correct wheel fitment from the database
    • Detects fitment style from the query (mild drop, aggressive, or bagged)
    • Filters products to match the recommended wheel size
  3. AI Analysis: OpenAI GPT-4 analyzes the query, considering:
    • Product specifications
    • User requirements
    • Correct wheel and tire fitment for the specific vehicle
    • Value for money
    • Ratings and reviews
    • Seasonal considerations
    • Fitment style preferences
  4. Smart Recommendations: The AI returns 3-4 most suitable products with reasoning
  5. Display: Products are displayed as cards with detailed specs including wheel size and tire size

Project Structure

product-recommendation-app/
├── app/
│   ├── api/
│   │   └── recommendations/
│   │       └── route.ts          # API endpoint for recommendations
│   └── page.tsx                   # Main page
├── components/
│   ├── ProductCard.tsx            # Product display component
│   └── ProductSearch.tsx          # Search interface component
├── lib/
│   ├── ai/
│   │   └── recommendations.ts     # OpenAI integration logic
│   └── data/
│       ├── products.ts            # Product catalog with tire sizes
│       └── vehicle-fitment.ts     # Vehicle fitment database (80+ vehicles)
├── .env.local                     # Environment variables (not in git)
├── .env.example                   # Environment variables template
└── next.config.ts                 # Next.js configuration

Customization

Adding New Products

Edit lib/data/products.ts to add new products to the catalog:

export const yourCategory: Product[] = [
  {
    id: "product-1",
    name: "Product Name",
    brand: "Brand",
    category: "Category",
    price: 99.99,
    image: "image-url",
    description: "Product description",
    specs: {
      "Spec 1": "Value 1",
      "Spec 2": "Value 2",
    },
    rating: 4.5,
    reviews: 100
  },
  // ... more products
];

Customizing AI Behavior

Edit the system prompt in lib/ai/recommendations.ts to adjust how the AI evaluates and recommends products.

Styling

The app uses Tailwind CSS. You can customize the design by editing:

  • components/ProductCard.tsx - Product card styling
  • components/ProductSearch.tsx - Search interface styling
  • tailwind.config.ts - Global theme configuration

API Endpoints

POST /api/recommendations

Request body:

{
  "query": "I need tires for winter driving",
  "userDetails": {
    "vehicle": "2020 Honda Civic",
    "preferences": "Budget-friendly"
  }
}

Response:

{
  "recommendations": [
    {
      "id": "tire-1",
      "name": "Product Name",
      "brand": "Brand",
      // ... product details
    }
  ],
  "reasoning": "AI explanation of why these products were recommended"
}

Deployment

Vercel (Recommended)

  1. Push your code to GitHub
  2. Import the project in Vercel
  3. Add your OPENAI_API_KEY environment variable in the Vercel project settings
  4. Deploy

Other Platforms

The app can be deployed to any platform that supports Next.js:

  • Netlify
  • AWS Amplify
  • Railway
  • Render

Make sure to set the OPENAI_API_KEY environment variable in your deployment platform.

Development

Running Tests

npm run test

Building for Production

npm run build

Linting

npm run lint

Future Enhancements

  • User authentication
  • Shopping cart functionality
  • Real-time inventory integration
  • Product comparison feature
  • Save favorite products
  • Price tracking and alerts
  • Integration with real e-commerce APIs
  • More product categories
  • Advanced filtering options

License

MIT

Support

For questions or issues, please open an issue on GitHub.

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors