shinzobolte/product-recommendation-system
0
AI Product Recommendation System
A small full-stack project for the coding exercise:
frontend/: React app that shows a product catalog and a preference formbackend/: FastAPI API that returns products and asks Groq for recommendations
Hugging Face Spaces
This repository is set up for a Docker Space.
After creating the Space:
- Add the Space as a git remote:
git remote add hf https://huggingface.co/spaces/shinzobolte/product-recommendation-system- Push the repository:
git push hf main- In the Space settings, add a secret:
GROQ_API_KEYOptional variable:
GROQ_MODEL=openai/gpt-oss-20bWhat it does
- The React frontend loads a list of products from the backend.
- The user enters a preference such as
I want a phone under $500. - The FastAPI backend sends the filtered catalog and the preference to Groq.
- Groq returns recommended product IDs in JSON.
- The frontend highlights the recommended products and shows a short summary.
Tech Stack
- Frontend: React + Vite + TypeScript
- Backend: FastAPI
- AI API: Groq
- Data storage: local JSON file for simplicity
Backend setup
cd backend
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txt
Copy-Item .env.example .envAdd your Groq key to backend/.env:
GROQ_API_KEY=your_groq_api_key_here
GROQ_MODEL=openai/gpt-oss-20bRun the API:
.\.venv\Scripts\python -m uvicorn app.main:app --reloadThe backend runs at http://127.0.0.1:8000.
Frontend setup
cd frontend
npm install
Copy-Item .env.example .env.local
npm run devThe frontend runs at http://localhost:5173.
API endpoints
GET /healthGET /api/productsPOST /api/recommendations
Example request body:
{
"preference": "I want a phone under $500"
}Notes
- The project uses a local JSON catalog instead of a database because the exercise only requires browsing a small product list and returning recommendations.
- The backend does a simple budget pre-filter first, then asks Groq to select the best matches from the remaining products.
- If
GROQ_API_KEYis missing, the frontend shows a clear error message from the backend.
