Skip to content
ateebarmanPublic

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.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation


RecoSense πŸš€

Find Exactly What You'll Love Tomorrow

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.

Quick Start »   Engine Deep-Dive »   Deploy Guide »


πŸ“‹ Table of Contents


πŸ”­ Overview

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
  • Production-Grade Full-Stack Engineering β€” JWT auth, caching, CI/CD, and cloud deployment

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.
Dual Computation Modes Level 1 (Quick Re-run): ~5s Node.js popularity heuristic. Level 2 (Heavy Retrain): ~30-60s Python LightFM deep learning pipeline.

🎨 Premium User Experience

Feature Description
Cinematic Dark Theme Modern design system with glassmorphism, CSS custom properties, and fluid animations via Framer Motion.
Responsive Design Mobile-first layouts across all pages with collapsible navigation, adaptive grids, and touch-friendly interactions.
AI Chat Modal In-product AI assistant with conversation history, streaming-like UX, and context-aware responses.
Scroll-to-Top Automatic scroll restoration on route changes for seamless navigation.
Accessibility ARIA attributes, focus-visible outlines, lazy-loaded images, and semantic HTML throughout.

πŸ›’ E-Commerce Marketplace

Feature Description
Product Catalog Paginated, searchable product browsing with high-detail cards, category filtering, and sorting options.
Product Detail Pages Rich product views with image galleries, description panels, community reviews, and integrated AI analysis.
Wishlist System Real-time like/unlike with global state synchronization (UserContext) β€” persisted across sessions.
Shopping Cart Full cart system with quantity management, price calculations, and persistent state (CartContext).
Checkout & Orders Complete checkout flow with order creation, order history, status tracking, and detailed order views.
Review System Submit, browse, and manage reviews with star ratings β€” reviews feed into the ABSA pipeline for improved recommendations.
User Profiles Profile management with personal info editing, demographic data, and activity history.
Authentication Secure JWT-based auth with bcrypt password hashing, login/register, and password change flows.
Admin Dashboard Role-based admin panel for triggering model runs, monitoring system status, resetting counters, and managing inventory.

πŸ› οΈ Tech Stack

Frontend

Technology Version Purpose
React 19.1 UI component library
Vite 7.1 Build tool & dev server
React Router DOM 7.9 Client-side routing with protected routes
Framer Motion 12.34 Animations, transitions, and micro-interactions
Axios 1.12 HTTP client for API communication
Lucide React 0.564 Modern icon library
Vanilla CSS β€” Design system with CSS custom properties, glassmorphism, dark theme tokens

Backend

Technology Version Purpose
Node.js 18+ Runtime environment
Express 5.1 Web framework & REST API
MongoDB β€” Document database (via Mongoose 8.18 ODM)
Redis 5.11 (client) Response caching layer with in-memory fallback
JWT 9.0 Stateless authentication tokens
bcryptjs 2.4 Password hashing
Groq SDK 0.37 LLM API integration for AI Consultant
node-cron 3.0 Scheduled retraining jobs
CORS 2.8 Cross-origin request handling
dotenv 17.2 Environment variable management

AI / ML (Python)

Technology Purpose
LightFM Hybrid collaborative + content-based filtering with WARP loss
RoBERTa (HuggingFace Transformers) Aspect-Based Sentiment Analysis for feature extraction
Pandas Data manipulation & interaction matrix construction
NumPy Numerical computations
SciPy Sparse matrix operations for LightFM
PyMongo Direct MongoDB access from Python training scripts

DevOps & Infrastructure

Technology Purpose
GitHub Actions CI/CD pipeline (build validation + Render deploy triggers)
Render Cloud hosting (Web Service + Static Site)
Vercel 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
Loading

Request Flow

Client Request
  β†’ React Router (protected routes)
    β†’ Axios (with JWT header)
      β†’ Express API Gateway
        β†’ CORS validation
          β†’ JWT middleware (auth.js)
            β†’ Controller logic
              β†’ MongoDB / Redis / JSON file reads
                β†’ Response with caching headers

🧠 Recommendation Engine

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
  • Generates structured output: Summary, 3 Pros, 2 Cons
  • Grounded in actual community review data (not hallucinated)

2. Conversational Follow-up (POST /api/ai/ask)

  • Multi-turn conversation with full message history
  • Context-aware responses anchored to the specific product
  • Temperature 0.7 for natural, varied responses

πŸ“ Project Structure

RecoSense/
β”œβ”€β”€ .github/
β”‚   └── workflows/
β”‚       └── ci-render-deploy.yml       # CI/CD: Build + Render deploy triggers
β”‚
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ server.js                      # Express app entry, CORS, MongoDB, cron
β”‚   β”œβ”€β”€ package.json                   # Node.js dependencies
β”‚   β”œβ”€β”€ seed.js                        # Database seeding (users, products, reviews)
β”‚   β”œβ”€β”€ seed_full.js                   # Extended seed with full dataset
β”‚   β”œβ”€β”€ createAdmin.js                 # Quick admin account creation
β”‚   β”œβ”€β”€ simulate_interactions.js       # Generate test interactions
β”‚   β”‚
β”‚   β”œβ”€β”€ controllers/
β”‚   β”‚   β”œβ”€β”€ productController.js       # CRUD, search, pagination, bulk fetch
β”‚   β”‚   β”œβ”€β”€ userController.js          # Auth (login/register), profile, likes
β”‚   β”‚   β”œβ”€β”€ reviewController.js        # Review submission & retrieval
β”‚   β”‚   β”œβ”€β”€ recommendationController.js # Rec logic, priority selection, merging
β”‚   β”‚   β”œβ”€β”€ aiController.js            # Groq AI analysis & chat
β”‚   β”‚   β”œβ”€β”€ cartController.js          # Cart CRUD operations
β”‚   β”‚   β”œβ”€β”€ orderController.js         # Order creation & history
β”‚   β”‚   └── adminController.js         # Admin inventory management
β”‚   β”‚
β”‚   β”œβ”€β”€ models/
β”‚   β”‚   β”œβ”€β”€ userModel.js               # User schema (demographics, likes, admin)
β”‚   β”‚   β”œβ”€β”€ productModel.js            # Product schema (ASIN, metadata, pricing)
β”‚   β”‚   β”œβ”€β”€ reviewModel.js             # Review schema (ratings, ABSA scores)
β”‚   β”‚   β”œβ”€β”€ cartModel.js               # Shopping cart schema
β”‚   β”‚   β”œβ”€β”€ orderModel.js              # Order schema (items, totals, status)
β”‚   β”‚   β”œβ”€β”€ recommendationModel.js     # Cached recommendations
β”‚   β”‚   └── systemConfigModel.js       # System state & retrain status
β”‚   β”‚
β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   β”œβ”€β”€ productRoutes.js           # /api/products
β”‚   β”‚   β”œβ”€β”€ userRoutes.js              # /api/user
β”‚   β”‚   β”œβ”€β”€ reviewRoutes.js            # /api/reviews
β”‚   β”‚   β”œβ”€β”€ recommendationRoutes.js    # /api/recommendations
β”‚   β”‚   β”œβ”€β”€ aiRoutes.js                # /api/ai
β”‚   β”‚   β”œβ”€β”€ cartRoutes.js              # /api/cart
β”‚   β”‚   β”œβ”€β”€ orderRoutes.js             # /api/orders
β”‚   β”‚   └── adminRoutes.js             # /api/admin
β”‚   β”‚
β”‚   β”œβ”€β”€ middleware/
β”‚   β”‚   β”œβ”€β”€ auth.js                    # JWT verification middleware
β”‚   β”‚   └── requireAdmin.js            # Admin role-gating middleware
β”‚   β”‚
β”‚   β”œβ”€β”€ recommender/
β”‚   β”‚   β”œβ”€β”€ retrainManager.js          # Dual-mode engine orchestrator
β”‚   β”‚   β”œβ”€β”€ train_lightfm.py           # Python LightFM training script
β”‚   β”‚   β”œβ”€β”€ requirements.txt           # Python deps (lightfm, pandas, scipy...)
β”‚   β”‚   β”œβ”€β”€ retrain_status.json        # Model run status tracking
β”‚   β”‚   β”œβ”€β”€ retrain_counters.json      # Interaction counter state
β”‚   β”‚   └── logs/                      # Model run stdout/stderr logs
β”‚   β”‚
β”‚   β”œβ”€β”€ utils/
β”‚   β”‚   └── cacheManager.js            # Redis + in-memory cache abstraction
β”‚   β”‚
β”‚   β”œβ”€β”€ data/
β”‚   β”‚   β”œβ”€β”€ filtered_smartphone_reviews.json    # Historical review corpus
β”‚   β”‚   β”œβ”€β”€ filtered_smartphone_metadata.json   # Product metadata
β”‚   β”‚   └── lightfm_recs.json                   # Precomputed recommendations
β”‚   β”‚
β”‚   └── tools/
β”‚       β”œβ”€β”€ set_admin.js               # CLI: Grant admin privileges
β”‚       β”œβ”€β”€ create_admin_user.js       # CLI: Create admin account
β”‚       β”œβ”€β”€ set_default_passwords.js   # CLI: Reset user passwords
β”‚       └── add_likes.js              # CLI: Add test likes
β”‚
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ index.html                     # SPA entry point
β”‚   β”œβ”€β”€ vite.config.js                 # Vite build configuration
β”‚   β”œβ”€β”€ vercel.json                    # Vercel deployment config
β”‚   β”œβ”€β”€ STYLEGUIDE.md                  # Design tokens & component guidelines
β”‚   β”‚
β”‚   └── src/
β”‚       β”œβ”€β”€ main.jsx                   # React DOM render + providers
β”‚       β”œβ”€β”€ App.jsx                    # Route definitions + layout
β”‚       β”œβ”€β”€ index.css                  # Global design system (68KB+ tokens)
β”‚       β”œβ”€β”€ App.css                    # App-level overrides
β”‚       β”‚
β”‚       β”œβ”€β”€ pages/
β”‚       β”‚   β”œβ”€β”€ Landing.jsx            # Hero landing page with animations
β”‚       β”‚   β”œβ”€β”€ Home.jsx               # Product catalog with search & filters
β”‚       β”‚   β”œβ”€β”€ ProductDetail.jsx      # Rich product view + AI chat
β”‚       β”‚   β”œβ”€β”€ Recommendations.jsx    # Personalized recommendation feed
β”‚       β”‚   β”œβ”€β”€ LikedProducts.jsx      # Wishlist dashboard
β”‚       β”‚   β”œβ”€β”€ MyReviews.jsx          # User review management
β”‚       β”‚   β”œβ”€β”€ Cart.jsx               # Shopping cart
β”‚       β”‚   β”œβ”€β”€ Checkout.jsx           # Checkout flow
β”‚       β”‚   β”œβ”€β”€ Orders.jsx             # Order history & tracking
β”‚       β”‚   β”œβ”€β”€ Profile.jsx            # User profile management
β”‚       β”‚   β”œβ”€β”€ Login.jsx              # Authentication
β”‚       β”‚   β”œβ”€β”€ Register.jsx           # User registration (with demographics)
β”‚       β”‚   β”œβ”€β”€ ChangePassword.jsx     # Password change form
β”‚       β”‚   └── AdminPanel.jsx         # Admin controls & system monitoring
β”‚       β”‚
β”‚       β”œβ”€β”€ components/
β”‚       β”‚   β”œβ”€β”€ Navbar.jsx             # Responsive nav with mobile toggle
β”‚       β”‚   β”œβ”€β”€ Footer.jsx             # Global footer
β”‚       β”‚   β”œβ”€β”€ ProductCard.jsx        # Product display card with like button
β”‚       β”‚   β”œβ”€β”€ ReviewCard.jsx         # Review display component
β”‚       β”‚   β”œβ”€β”€ AddReviewForm.jsx      # Review submission form
β”‚       β”‚   β”œβ”€β”€ AIChatModal.jsx        # AI Consultant chat interface
β”‚       β”‚   └── ScrollToTop.jsx        # Route-change scroll restoration
β”‚       β”‚
β”‚       β”œβ”€β”€ context/
β”‚       β”‚   β”œβ”€β”€ UserContext.jsx        # Auth state, user profile, wishlist sync
β”‚       β”‚   └── CartContext.jsx        # Cart state management
β”‚       β”‚
β”‚       β”œβ”€β”€ services/
β”‚       β”‚   └── api.js                 # Axios API client (all endpoints)
β”‚       β”‚
β”‚       └── styles/
β”‚           β”œβ”€β”€ Profile.css            # Profile page styles
β”‚           β”œβ”€β”€ Cart.css               # Cart page styles
β”‚           β”œβ”€β”€ Checkout.css           # Checkout page styles
β”‚           └── Orders.css             # Orders page styles
β”‚
β”œβ”€β”€ render.yaml                        # Render IaC deployment config
β”œβ”€β”€ RECOMMENDATION_SYSTEM.md           # Complete engine documentation (1000+ lines)
β”œβ”€β”€ QUICK_RE_RUN.md                    # Level 1 engine documentation
β”œβ”€β”€ LIGHTFM_RETRAIN.md                 # Level 2 engine documentation
β”œβ”€β”€ DEPLOY.md                          # Deployment guide (Render, Vercel, single-service)
└── .gitignore

πŸš€ Quick Start

Prerequisites

Requirement Version Notes
Node.js 18+ Required
MongoDB 6+ Local instance or MongoDB Atlas
Python 3.8+ Optional β€” only needed for Level 2 Heavy Retrain
Redis 7+ Optional β€” falls back to in-memory cache
Groq API Key β€” Optional β€” needed for AI Consultant feature

1. Clone & Install

git clone https://github.com/ateebarman/RecoSense.git
cd RecoSense

# Install backend dependencies
cd backend
npm install

# Install frontend dependencies
cd ../frontend
npm install

2. Configure Environment

Create a .env file in the backend/ directory:

# ─── Required ───────────────────────────────
MONGO_URI=mongodb://localhost:27017/recommender_db
PORT=5001

# ─── Authentication ─────────────────────────
JWT_SECRET=your_super_secret_key_here

# ─── AI Consultant (optional) ───────────────
GROQ_API_KEY=your_groq_api_key

# ─── Recommendation Thresholds ──────────────
MODEL_RUN_THRESHOLD=10       # Interactions before auto-trigger
LIGHTFM_THRESHOLD=3          # Interactions to use LightFM recs

# ─── Demographic Weighting ──────────────────
DEMO_LIKED_WEIGHT=4.0        # Weight for likes in popularity calc
DEMO_REVIEW_WEIGHT=1.0       # Weight for reviews in popularity calc

# ─── Admin Configuration ────────────────────
ADMIN_USERS=TEST_USER_101
ADMIN_SECRET=your_admin_secret

# ─── Caching (optional) ─────────────────────
REDIS_URL=redis://localhost:6379

# ─── Scheduled Retrain (optional) ───────────
RETRAIN_CRON=0 3 * * *       # Daily at 03:00

# ─── Frontend Serving (optional) ────────────
SERVE_FRONTEND=false
FRONTEND_URL=http://localhost:5173

3. Setup Python Environment (Optional β€” Level 2 only)

cd backend
python -m venv ../.venv

# Windows
..\.venv\Scripts\activate

# macOS / Linux
source ../.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)
Clean Rec File Remove stale/deleted users from lightfm_recs.json
Get Model Counters View current interaction counts
Reset Counters Manually reset interaction counters to 0
Refresh Status Poll current model run status

Become an Admin

# Option 1: CLI Tool
cd backend && node tools/set_admin.js YOUR_USER_ID

# Option 2: Create admin script
npm run create-admin   # Creates user_id=1 with admin privileges

# Option 3: Environment variable (restart required)
ADMIN_USERS=YOUR_USER_ID_1,YOUR_USER_ID_2

# Option 4: Register with admin secret
curl -X POST http://localhost:5001/api/user/register \
  -H "x-admin-secret: your-secret" \
  -H "Content-Type: application/json" \
  -d '{"user_id":"ADMIN_2","reviewerName":"Admin","isAdmin":true}'

Manual CLI Engine Triggers

# 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.

CI/CD

GitHub Actions workflow (.github/workflows/ci-render-deploy.yml) automates:

  1. Frontend build validation
  2. Backend dependency installation
  3. Render deploy trigger via API

See DEPLOY.md for step-by-step deployment instructions for Render, Vercel, and single-service setups.


πŸ“„ Documentation

Document Description
RECOMMENDATION_SYSTEM.md Complete engine guide (1000+ lines): architecture, data flow, API specs, DB schemas, troubleshooting
QUICK_RE_RUN.md Level 1 engine: Node.js popularity heuristic, step-by-step lifecycle
LIGHTFM_RETRAIN.md Level 2 engine: LightFM + ABSA hybrid pipeline, vector interaction logic
DEPLOY.md Deployment guide: Render, Vercel, single-service, CI/CD setup
frontend/STYLEGUIDE.md Design system: color palette, typography, spacing, component guidelines
backend/RECOMMENDER.md Backend recommender quickstart: install, train, endpoints, scheduler
backend/README_AI_DIVE.md Technical deep-dive: retrain vs re-run, matrix factorization, threshold pipeline

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feat/your-feature
  3. Commit changes: git commit -m "feat: add your feature"
  4. Push to branch: git push origin feat/your-feature
  5. Open a Pull Request

npm Scripts Reference

Backend (cd backend):

Script Command Description
npm start node server.js Production server
npm run dev nodemon server.js Dev server with hot-reload
npm run seed node seed.js Seed database
npm run create-admin node tools/create_admin_user.js Create admin (user_id=1)
npm run set-passwords node tools/set_default_passwords.js Reset passwords to default
npm run train:lightfm python ./recommender/train_lightfm.py Full LightFM training
npm run model:run python ./recommender/train_lightfm.py --infer-only Infer-only run

Frontend (cd frontend):

Script Command Description
npm run dev vite Start Vite dev server
npm run build vite build Production build
npm run preview vite preview Preview production build
npm run lint eslint . Run linter

πŸ“œ License

ISC


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.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages