A graph-based movie recommendation system only for movies available on Netflix. System uses bipartite graph of users and movies for recommendations.
Algorithms and Data Structures 2 • Data Science and AI • ETF Sarajevo
- Overview
- Features
- Demo
- Technologies
- Architecture
- Algorithms
- Installation
- Usage
- Project Structure
- Screenshots
- Deployment
- Contributing
- License
This project implements a movie recommendation system using bipartite graph theory and collaborative filtering. Built as part of the Algorithms and Data Structures 2 course at the Faculty of Electrical Engineering (ETF), University of Sarajevo, it demonstrates practical applications of graph algorithms in real-world recommendation systems.
The system analyzes user-movie relationships in a bipartite graph structure to find similar users and recommend movies based on shared preferences using Jaccard similarity and common neighbors algorithms.
- 🎯 Smart Recommendations - Jaccard similarity & Common Neighbors algorithms
- 👥 Similar Users Detection - Find users with matching movie preferences
- 🎨 Interactive Visualization - Plotly-based bipartite graph exploration
- 🔍 Real-time Search - Filter through 4,800+ Netflix movies instantly
- ⭐ Rating Filter - Set minimum rating thresholds (0-5 stars)
- 🎭 Genre Filtering - Filter by specific movie genres
- ❤️ Like System - Select multiple movies to build preference profile
- ⚡ Optimized Performance - 10-50x faster with pre-computed caches
- 🌙 Netflix Dark Theme - Modern, familiar interface
- 📱 Responsive Design - Works on desktop, tablet, and mobile
- 🚀 Fast Performance - Optimized graph algorithms
- 💾 Session Persistence - Maintain state across page navigation
Live Demo: https://ln.run/NetflixRecommendation (may take 30s to wake up)
- 🔍 Search and select movies you like
- ⚙️ Configure recommendation settings
- 🎯 Get personalized recommendations
- 📊 Visualize the recommendation graph
- 👥 See which users have similar taste
- Python 3.11 - Core programming language
- Flask 3.0 - Web framework
- NetworkX 2.8 - Graph algorithms and data structures
- Pandas 2.0 - Data manipulation and analysis
- Plotly 5.0 - Interactive graph visualizations
- HTML5 & CSS3 - Structure and styling
- JavaScript (ES6+) - Client-side interactivity
- Font Awesome 6.5 - Icon library
- MovieLens Dataset - 100,000+ ratings from 600+ users
- Netflix Filtered Subset - ~4,800 movies available on Netflix
- CSV Format - ratings_netflix.csv, movies_netflix.csv, netflix_titles.csv
Users Movies
┌─────────┐ ┌─────────┐
│ User 1 │──────────│ Movie A │
└─────────┘ └─────────┘
│ │
│ ┌─────────┐
└───────────────│ Movie B │
└─────────┘
┌─────────┐ │
│ User 2 │──────────────┘
└─────────┘ ┌─────────┐
│ │ Movie C │
└───────────────└─────────┘- Nodes: Users and Movies (two distinct sets)
- Edges: User-Movie ratings (threshold: ≥3.5 stars)
- Properties: Movie metadata (title, genres, avg rating)
- User Selection → Select liked movies via UI
- Graph Query → Find users who liked the same movies
- Similarity Calculation → Compute Jaccard or CN scores
- Candidate Filtering → Apply genre/rating filters
- Ranking → Sort by score and present top-N results
- Visualization → Generate interactive bipartite graph
Measures overlap between user movie sets:
J(A,B) = |A ∩ B| / |A ∪ B|Use case: Balanced similarity metric, good for diverse recommendations
Counts shared movie preferences:
CN(u,v) = |N(u) ∩ N(v)|Use case: Emphasizes strong overlaps, popular movie bias
Optional weighted scoring:
Score_weighted = Score × (avg_rating / 5.0)Use case: Boost highly-rated movies in recommendations
- Python 3.11 or higher
- pip (Python package manager)
- Git
git clone https://github.com/ehadziabdic/NetflixRecommendation.git
cd NetflixRecommendationpython -m venv .venv
.venv\Scripts\activate # Windows
# source .venv/bin/activate # Linux/Macpip install -r requirements.txtcopy .env.example .envEdit .env and add your secret key:
SECRET_KEY=your_generated_secret_key_here
FLASK_DEBUG=True
PORT=5000Generate secret key:
python -c "import secrets; print(secrets.token_hex(32))"python app.pyOpen browser: http://localhost:5000
-
Select Movies
- Search for movies using the search bar
- Click ❤️ heart icon to like movies
- Selected movies appear in "Your Movies" section
-
Configure Settings
- Top # Recommendations: Number of results (1-100)
- Genre: Filter by specific genre or "All"
- Rating Limit: Minimum average rating (0-5)
- Algorithm: Toggle between Jaccard/Common Neighbors
- Prioritize Rating: Weight scores by movie ratings
-
Get Recommendations
- Click "Get recommendations" button
- View results in sortable table
- See rank, title, score, genres, and ratings
-
Visualize Graph
- Click "Visualize Recommendation Graph"
- Interactive Plotly visualization shows:
- 🟡 You (virtual user node)
- 🟢 Similar users (circles)
- 🟦 Liked movies (squares)
- 🟩 Recommended movies (squares)
- Info panel displays similar users with shared movie counts
NetflixRecommendation/
├── app.py # Flask application & routes (main entry)
├── test.py # Testing & analysis suite
├── src/ # Core algorithms (optimized)
│ ├── graph.py # Graph construction & data loading
│ ├── scoring.py # Recommendation algorithms (Jaccard/CN)
│ └── graphvis.py # Plotly visualization generator
├── templates/ # HTML templates
│ ├── index.html # Main page (movie selection)
│ ├── recommendations.html # Results display
│ └── graph.html # Interactive graph visualization
├── static/ # Static assets
│ ├── css/
│ │ └── style.css # Netflix dark theme styling
│ ├── js/
│ │ └── script.js # Client-side interactivity
│ └── icons/
│ └── favicon.png # Site favicon
├── notebooks/ # Jupyter notebooks
│ ├── EDA.ipynb # Exploratory Data Analysis
│ └── Filtering.ipynb # Data filtering pipeline (Netflix subset)
├── res/ # Dataset files
│ ├── movies.csv # Full MovieLens dataset (~87K movies)
│ ├── movies_netflix.csv # ✅ Filtered Netflix movies (~4.8K)
│ ├── ratings.csv # Full ratings dataset (100K+ entries)
│ ├── ratings_netflix.csv # ✅ Filtered Netflix ratings
│ └── netflix_titles.csv # Netflix catalog reference (~6K)
├── .venv/ # Python virtual environment
├── .env # Environment variables (SECRET_KEY, etc.)
├── .env.example # Environment template
├── requirements.txt # Python dependencies
├── .gitignore # Git ignore rules
├── .gitattributes # Git attributes
├── LICENSE # MIT License
└── README.md # This file-
app.py: Main Flask application with optimized recommendation engine- Pre-computed caches for 10-50x performance improvement
- Supports Jaccard similarity and Common Neighbors algorithms
- Genre filtering, rating limits, and weighted scoring
-
src/scoring.py: Core recommendation algorithms- Optimized Jaccard 2-hop similarity
- Common neighbors counting
- Batch scoring for multiple candidates
-
src/graph.py: Bipartite graph construction- Data loading and validation
- User downsampling (min 10 ratings ≥3.5)
- Node/edge creation with metadata
-
notebooks/Filtering.ipynb: Data preprocessing- Multi-strategy title matching (with/without year)
- Text cleaning and normalization
- Filters movies.csv to Netflix-only subset (~4.8K from 87K)
-
Push to GitHub:
git push origin main
-
Create Render Account:
- Go to render.com
- Sign up with GitHub
-
Deploy:
- New → Web Service
- Connect repository
- Build:
pip install -r requirements.txt - Start:
python app.py - Add environment variable:
SECRET_KEY
-
Access:
- Your app:
https://your-app.onrender.com
- Your app:
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create feature branch (
git checkout -b feature/AmazingFeature) - Commit changes (
git commit -m 'Add AmazingFeature') - Push to branch (
git push origin feature/AmazingFeature) - Open Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- MovieLens Dataset - GroupLens Research @ University of Minnesota
- ETF Sarajevo - Course instructors and teaching assistants
- NetworkX Team - Excellent graph algorithms library
- Flask Community - Web framework and documentation
Emin Hadžiabdić
Data Science and AI Student
ETF Sarajevo
- GitHub: @ehadziabdic
- Project Link: https://github.com/ehadziabdic/NetflixRecommendation
⭐ Star this repo if you found it helpful!


