📌 Overview The Movies Recommendation System is an AI-powered platform designed to recommend movies based on semantic similarity between their descriptions, titles, and genres. It leverages vector embeddings generated from Hugging Face and OpenAI models to enable fast, accurate similarity searches in MongoDB.
This project is intended for:
• Developers exploring AI-powered recommendation engines.
• Data engineers learning vector search in MongoDB.
• AI/ML practitioners experimenting with semantic embeddings.
• Full-stack developers integrating AI models with React + Node.js.
🧠 What Are Vector Embeddings in AI? Vector embeddings are numerical representations of data (e.g., text, images) in a high-dimensional space. For example, the sentence "A superhero movie with time travel" is converted into a 384-dimensional vector like:
Semantically similar items will have embeddings that are close in this vector space.
[0.1232, 0.345, 0.456, ...]
🔍 What Is Vector Similarity Search?
Vector similarity search finds items in a database whose embeddings are most similar to a given query vector.
Common metrics include cosine similarity and dot product.
In this project, similarity search is performed using MongoDB's Vector Search index.
🤖 Hugging Face Model We use Hugging Face's all-MiniLM-L6-v2 model from the Sentence Transformers library.
► Embedding size: 384 dimensions
► Optimized for semantic similarity and search
► Lightweight and fast
► API Access: Requires a Hugging Face API token (HUGGINGFACE_API_KEY) for hosted inference.
📥 Data Ingestion Process (Sample Data – 250 Movies) Create MongoDB Collection – Store movie metadata.
1. Generate Vector Embeddings – For each movie, convert title, plot, and genre into embeddings.
2. Insert Into MongoDB – Store embeddings as arrays in a field (e.g., embedding).
3. Create MongoDB Vector Search Index – Enable fast similarity queries.
4. Run Aggregation Pipeline in MongoDB Compass – Test vector search manually.
🖥 API Server Setup Backend is built with Node.js + Express.js.
Endpoints:
GET /movies → Returns all movies.
GET /movies/recommend/:id → Returns similar movies for a given movie ID.
GET /movies/search?query="avengers" → Returns movies matching a text query.
📂 Project Structure
├── backend/
│ ├── index.js/
│ ├── createEmbeddings.js/
│ ├── db.js
│ └── getHuggingFaceEmbeddings.js/
├── frontend/
│ ├── components/
│ ├── pages/
│ └── services/
Data Ingestion Flow
Recommendation by Target Movie ID
Recommendation by Search Term
Instructions on how to set up the project locally.
-
Clone the repository
git clone https://github.com/your-username/movies-recommendation-system.git cd movies-recommendation-system
-
Install backend dependencies
cd backend npm install
-
Create environment variables
cp .env.example .env Edit .env with your MongoDB URI, Hugging Face API key, and other settings
-
Install frontend dependencies
cd ../frontend npm install
-
Set up MongoDB
Start local MongoDB server OR Use MongoDB Atlas and paste connection string in backend .env
-
Run the backend server
cd ../backend npm run dev
-
Run the frontend application
cd ../frontend npm run dev
React – UI framework (Vite + Tailwind)
Node.js + Express – Backend API
MongoDB – Database with vector search
Hugging Face – all-MiniLM-L6-v2 model for text embeddings
Redis – Caching layer (optional)