Problem and solution
Problem
A product catalog needs recommendations and search that can respond to both user behavior and product meaning.
Solution
A hybrid recommendation system combining collaborative filtering, semantic product embeddings, and natural-language search in a Next.js and FastAPI commerce app.
Technical approach
- ALS collaborative filtering with scheduled retraining and MLflow tracking
- Sentence Transformer embeddings stored with PostgreSQL and pgvector
- Claude-powered query parsing and Redis recommendation caching
Implementation details
A complete e-commerce platform that combines AI with personalized product recommendations, built with Next.js and FastAPI. Its recommendation engine combines multiple algorithms. ALS collaborative filtering learns from users with similar preferences to recommend products a customer has not yet viewed; the model retrains nightly through a cron job, and MLflow tracks experiments. Content-based filtering converts product names, descriptions, and tags into vector embeddings with Sentence Transformers, stores them in pgvector, and finds similar products through cosine similarity. A hybrid recommender combines both scores with a weighted average to improve accuracy and variety. Claude API powers natural-language search by converting requests such as a birthday gift for a woman with a budget of 500 into structured product filters. Behavior tracking records views, clicks, cart additions, and purchases with weighted events so recommendations can improve over time. The personalized home page includes recommendations, trending products, recently viewed items, similar products, and frequently bought together suggestions. Commerce features include a persistent cart, wishlist, coupons and promotional codes, multi-step checkout, order tracking, returns and refunds, and order history. The administration dashboard reports real-time CTR, conversion rate, and revenue, supports A/B testing across algorithms, and tracks model versions through MLflow. Redis caches recommendation results, similar products, and trending items to reduce latency and computation. The frontend uses Next.js 14 App Router and Tailwind CSS. The backend and machine-learning layer use FastAPI, SQLAlchemy, PostgreSQL with pgvector, Redis, MLflow, Scikit-learn, and Sentence Transformers. Deployment uses Docker, Vercel for the frontend, Railway for the backend, and GitHub Actions for CI/CD.