PerplexiCart helps users make informed, value-aligned purchasing decisions. Powered by the Perplexity Sonar API, it analyzes products across the web and returns structured insights with prioritized recommendations, pros/cons, trade‑off analysis, and user sentiment — tailored to preferences like Eco‑Friendly, Durability, Ethical, and region‑specific needs.

Features

  • Intelligent Product Recommendations beyond simple spec comparison
  • Priority-Based Value Alignment (Best Value, Eco‑Friendly, Ethical, Durability, Made in India)
  • Contextual Personalization (skin type, usage patterns, region, etc.)
  • Structured Research Output with:
    • Research summary and top recommendations
    • Value alignment with reasoning
    • Pros/Cons and key specifications
    • User sentiment and community insights (Reddit, Quora)
    • Trade‑off analysis and buying tips
  • Transparent Sources with citations for verification

Prerequisites

  • Node.js 18+ and npm/yarn
  • Python 3.10+ and pip
  • Perplexity API key

Installation

# Clone the repository
git clone https://github.com/fizakhan90/perplexicart.git
cd perplexicart

# Backend (FastAPI) setup
cd backend
python -m venv .venv
source .venv/bin/activate  # Windows: .venv\Scripts\activate
pip install -r requirements.txt

# Frontend (Next.js) setup
cd ../frontend
npm install

Configuration

Create a .env file in the backend directory:
PERPLEXITY_API_KEY=your_perplexity_api_key
(Optional) Add any app‑specific settings as needed (cache, region defaults, etc.).

Usage

  1. Start Backend (FastAPI):
    cd backend
    uvicorn main:app --reload  # adapt module:app if your entrypoint differs
    
  2. Start Frontend (Next.js):
    cd frontend
    npm run dev
    
  3. Open the App: Visit http://localhost:3000 and search for a product. Select your priority (e.g., Eco‑Friendly) and add optional context (skin type, region).

Code Explanation

  • Backend (FastAPI): Orchestrates Sonar calls with dynamic prompt engineering based on query, selected priority, and context
  • Structured Outputs: Enforces a strict JSON schema via response_format to ensure consistent UI rendering
  • Live Web Research: Directs Sonar to search e‑commerce platforms, forums, review blogs, and sustainability reports
  • Semantic Analysis: Extracts value alignment, pros/cons, sentiment, and cites sources for transparency
  • Frontend (Next.js/React): Presents a clear, user‑friendly view of recommendations, trade‑offs, and citations

How the Sonar API Is Used

PerplexiCart leverages the Perplexity Sonar API as its intelligence core, dynamically generating customized prompts based on user inputs like search queries, priorities and context. The API performs comprehensive web research across e-commerce sites, forums, and review platforms, with responses structured in a consistent JSON format. Through semantic analysis, it extracts key product insights including alignment with user priorities, pros/cons, and sentiment - all backed by cited sources. The FastAPI backend processes these structured responses before serving them to the Next.js frontend for a polished user experience.