You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Star0Β (0)You must be signed in to star a repository
About
RecoSense is a full-stack recommendation system that delivers personalized content using a hybrid approach. Built with Node.js, Express, MongoDB, React, and Python, it combines collaborative and content-based filtering with LightFM to generate accurate, scalable, and efficient recommendations for real-world applications.
A production-grade, full-stack e-commerce marketplace powered by a dual-mode hybrid recommendation engine,
combining LightFM collaborative filtering, RoBERTa sentiment analysis, and a Groq-powered AI Consultant.
RecoSense is a premium, AI-driven electronics marketplace that transforms traditional e-commerce browsing into an intelligent product discovery experience. Built as a B.Tech Project (BTP), the system demonstrates advanced concepts in:
Hybrid Recommendation Systems β combining collaborative filtering with content-based features
Aspect-Based Sentiment Analysis (ABSA) β extracting granular product insights from user reviews
LLM-Powered Shopping Assistance β real-time conversational product analysis via Groq
The platform serves a catalog of electronics products with intelligent discovery features that adapt to each user's behavior, preferences, and demographic profile in real time.
π Key Features
π§ Intelligence & Analytical Discovery
Feature
Description
AI Consultant (Groq)
LLM-powered assistant (Llama 3.3 70B via Groq API) providing real-time product analysis, pros/cons summaries, and multi-turn conversational follow-ups grounded in actual review sentiment data.
Hybrid Recommendation Engine
Dual-mode engine using LightFM for matrix factorization with WARP loss and ABSA feature vectors from RoBERTa for content-aware hybrid filtering.
Aspect-Based Sentiment Analysis
RoBERTa (Robustly Optimized BERT Pretraining Approach) processes review text to extract per-aspect scores (Battery, Camera, Screen, Price, Software, Build Quality) used as item feature vectors.
Smart Cold-Start Resolution
New users receive curated recommendations via demographic profiling (age group + gender popularity), with graceful fallback to global trending products.
Auto-Triggered Retraining
Counter-based pipeline tracks user interactions (likes + reviews) and automatically recomputes recommendations when the configurable threshold is reached.
Alternative frontend hosting (with vercel.json config)
Nodemon
Development hot-reload
ESLint
Code quality and linting
ποΈ System Architecture
graph TD
subgraph "Frontend (React 19 + Vite 7)"
A[Landing Page] --> B[Product Catalog]
B --> C[Product Detail + AI Chat]
B --> D[Wishlist / Cart / Orders]
A --> E[Auth: Login / Register]
B --> F[Recommendations Page]
B --> G[Admin Dashboard]
end
subgraph "Backend (Express 5 API)"
H[API Gateway + CORS + JWT Auth]
H --> I[Product Controller]
H --> J[User Controller]
H --> K[Review Controller]
H --> L[Recommendation Controller]
H --> M[AI Controller - Groq]
H --> N[Cart Controller]
H --> O[Order Controller]
H --> P[Admin Controller]
end
subgraph "Data Layer"
Q[(MongoDB Atlas)]
R[(Redis Cache)]
S[lightfm_recs.json]
T[retrain_counters.json]
end
subgraph "ML Pipeline (Python)"
U[train_lightfm.py]
V[ABSA Feature Vectors]
W[LightFM Model Training]
end
C --> H
D --> H
F --> H
G --> H
L --> S
L --> Q
L --> R
M -->|Llama 3.3 70B| X[Groq Cloud API]
I --> Q
J --> Q
K --> Q
N --> Q
O --> Q
L -->|Threshold Trigger| Y[RetrainManager]
Y -->|Level 1: Quick Re-run| Z[Node.js Inference]
Y -->|Level 2: Heavy Retrain| U
U --> V
V --> W
W --> S
Z --> S
The engine operates in a dual-mode architecture with automatic threshold-based triggering:
Level 1 β Quick Re-run (Node.js)
Attribute
Detail
Language
JavaScript (Node.js)
Speed
< 5 seconds
CPU Usage
Minimal
Algorithm
Weighted popularity heuristic with personal filtering
Trigger
Auto (every N interactions) or manual via Admin Panel
Pipeline: Merge historical reviews + live MongoDB likes β Compute global popularity scores β Filter per-user (remove already-interacted) β Enrich with metadata β Write lightfm_recs.json β Sync to MongoDB.
Level 2 β Heavy Retrain (Python LightFM)
Attribute
Detail
Language
Python 3.8+
Speed
30β60 seconds
CPU Usage
High (matrix factorization)
Algorithm
LightFM hybrid filtering with WARP loss + ABSA feature vectors
Trigger
Admin Panel click, CLI, or scheduled via cron
Pipeline: Load ABSA feature vectors from RoBERTa β Build sparse interaction matrix β Train LightFM (20-30 epochs, WARP loss) β Batch predict Top-20 per user β Write lightfm_recs.json β Bulk update MongoDB.
Recommendation Priority Logic
1. LightFM precomputed β User has β₯ LIGHTFM_THRESHOLD interactions & recs file exists
2. Demographic popularity β User has age_group + gender β popular items in cohort
3. Global popularity β Fallback for new users with no profile data
Auto-Trigger Pipeline
User likes a product or submits a review
β incrementCounter('like' | 'review')
β if (pending >= MODEL_RUN_THRESHOLD)
β startModelRun() (async, non-blocking)
β Recompute all recommendations
β Reset counters to 0
π€ AI Consultant
The AI Consultant is powered by Groq's Llama 3.3 70B Versatile model and provides two capabilities:
1. Product Analysis (GET /api/ai/analyze/:asin)
Fetches product details + aggregated ABSA sentiment scores from MongoDB
cd backend
python -m venv ../.venv
# Windows
..\.venv\Scripts\activate
# macOS / Linuxsource ../.venv/bin/activate
pip install -r recommender/requirements.txt
4. Seed Database & Run
# In backend directory
npm run seed # Seed users, products, and reviews
npm run create-admin # Create admin account (user_id: 1, password: 123456)
npm run dev # Start API server with hot-reload (port 5001)# In frontend directory (new terminal)
npm run dev # Start Vite dev server (port 5173)
5. Open in Browser
Navigate to http://localhost:5173 β you'll see the landing page. Log in with:
Field
Value
User ID
1
Password
123456
βοΈ Environment Variables
Variable
Required
Default
Description
MONGO_URI
β
β
MongoDB connection string
PORT
β
5001
API server port
JWT_SECRET
β οΈ
Fallback
Secret for JWT signing (set in production!)
GROQ_API_KEY
β
β
Groq API key for AI Consultant
MODEL_RUN_THRESHOLD
β
10
Interactions before auto model run
LIGHTFM_THRESHOLD
β
3
Interactions needed to use LightFM recs
DEMO_LIKED_WEIGHT
β
4.0
Weight for likes in popularity scoring
DEMO_REVIEW_WEIGHT
β
1.0
Weight for reviews in popularity scoring
ADMIN_USERS
β
β
Comma-separated admin user IDs
ADMIN_SECRET
β
β
Secret for admin registration
REDIS_URL
β
β
Redis connection URL (falls back to memory)
RETRAIN_CRON
β
β
Cron expression for scheduled retrains
SERVE_FRONTEND
β
false
Serve frontend from backend (single-service)
FRONTEND_URL
β
β
Frontend URL for CORS
VITE_API_URL
β
/api
Backend API URL (set in frontend)
PYTHON_EXECUTABLE
β
Auto-detect
Path to Python venv executable
π‘ API Reference
Authentication
Method
Endpoint
Auth
Description
POST
/api/user/register
β
Register new user (with demographic data)
POST
/api/user/login
β
Login β returns JWT token
GET
/api/user/me
π JWT
Get authenticated user profile
POST
/api/user/change-password
π JWT
Change password
Products
Method
Endpoint
Auth
Description
GET
/api/products
β
List products (paginated, searchable)
GET
/api/products/:asin
β
Get product by ASIN
GET
/api/products/bulk
β
Bulk-fetch multiple products by ASINs
User Interactions
Method
Endpoint
Auth
Description
PUT
/api/user/:user_id/like
π
Toggle product like (auto-increments counter)
POST
/api/reviews
π
Submit a review (auto-increments counter)
GET
/api/reviews
β
Get reviews (by product or user)
Recommendations
Method
Endpoint
Auth
Description
GET
/api/recommendations
π
Get personalized recommendations
POST
/api/recommendations/model/run
π Admin
Trigger infer-only model run
GET
/api/recommendations/retrain/status
β
Check model run status
GET
/api/recommendations/model/counters
π Admin
View interaction counters
POST
/api/recommendations/model/counters/reset
π Admin
Reset counters
POST
/api/recommendations/retrain
π Admin
Trigger full LightFM retrain
POST
/api/recommendations/retrain/clean
π Admin
Clean stale users from recs file
AI Consultant
Method
Endpoint
Auth
Description
GET
/api/ai/analyze/:asin
π
AI product analysis (summary, pros, cons)
POST
/api/ai/ask
π
Conversational follow-up question
Cart & Orders
Method
Endpoint
Auth
Description
GET
/api/cart
π
Get user's cart
POST
/api/cart/add
π
Add item to cart
PUT
/api/cart/update
π
Update cart item quantity
DELETE
/api/cart/remove
π
Remove item from cart
POST
/api/orders
π
Create order from cart
GET
/api/orders
π
Get order history
GET
/api/orders/:id
π
Get order details
Admin
Method
Endpoint
Auth
Description
GET
/api/admin/products
π Admin
Admin product management
PUT
/api/admin/products/:asin
π Admin
Update product details
π§ Admin Dashboard
Access the admin panel at /admin (visible only to admin users).
Capabilities
Action
Description
Run Model (Infer-Only)
Trigger Level 1 Quick Re-run (~5s)
Trigger Retrain
Trigger Level 2 Heavy Retrain (~60s, requires Python)
# Level 1: Quick Re-run (Node.js)
node -e "require('./recommender/retrainManager').startModelRun()"# Level 2: Heavy Retrain (Python LightFM)
node -e "require('./recommender/retrainManager').startRetrain()"# Or via npm scripts
npm run model:run # Python infer-only
npm run train:lightfm # Full LightFM training
βοΈ Deployment
Render (Recommended)
The project includes a render.yaml Infrastructure-as-Code config for one-click deployment:
Two-Service Architecture:
Service
Type
Root Dir
Build
Start
Backend
Web Service
backend
npm ci
npm start
Frontend
Static Site
frontend
npm ci && npm run build
Publish dist/
Single-Service Architecture:
Set SERVE_FRONTEND=true and use a combined build command.
Vercel
Frontend can be deployed directly to Vercel with the included vercel.json config.
Built with β€οΈ by RecoSense Engineering
Empowering the future of personalized tech discovery. β¨
About
RecoSense is a full-stack recommendation system that delivers personalized content using a hybrid approach. Built with Node.js, Express, MongoDB, React, and Python, it combines collaborative and content-based filtering with LightFM to generate accurate, scalable, and efficient recommendations for real-world applications.