Skip to content

inboxpraveen/Movie-Recommendation-System

Repository files navigation

🎬 Movie Recommendation System

A production-ready, AI-powered movie recommendation system built with Django and advanced machine learning. Scalable from thousands to millions of movies.

Python Django License


Logo Image


πŸ“‘ Table of Contents


🎯 Overview

The Movie Recommendation System provides intelligent movie suggestions using content-based filtering with TF-IDF and SVD dimensionality reduction. It features a modern web interface, RESTful API, and supports datasets from 2K to 1M+ movies.

Header Image

Why This Project?

  • βœ… Production Ready - Security hardened, optimized, well-documented
  • βœ… Scalable Architecture - Handles millions of movies efficiently
  • βœ… Modern Tech Stack - Django 5.0, Python 3.10+, advanced ML
  • βœ… Easy to Use - Simple installation, clear documentation
  • βœ… Flexible - Train your own models or use demo models

Key Technologies

  • Backend: Django 6.0, Python 3.10+
  • ML/Data: scikit-learn, pandas, numpy, scipy
  • Storage: Parquet (efficient data format)
  • Deployment: Render, Heroku, Docker compatible

πŸ“Έ Screenshots & Demo

Demo Video

Application Demo

Model Loading

Model Loading

Home Page

Home Page

Movie Search Recommendations

Movie Recommendations


✨ Features

User Features

  • πŸ” Smart Search - Real-time autocomplete with fuzzy matching
  • 🎬 AI Recommendations - Content-based filtering with 15+ suggestions
  • ⭐ Rich Metadata - Ratings, votes, genres, production companies
  • πŸ”— External Links - Google Search and IMDb integration
  • πŸ“± Responsive Design - Works seamlessly on all devices
  • ⚑ Fast Performance - Sub-50ms recommendation generation

Technical Features

  • πŸ€– Advanced ML - TF-IDF + SVD dimensionality reduction
  • πŸ“Š Scalable - Handles 2K to 1M+ movies
  • πŸ’Ύ Efficient Storage - Parquet format with compression
  • πŸ”§ Configurable - Easy model switching via MODEL_DIR
  • πŸ“‘ REST API - JSON endpoints for integration
  • πŸ”’ Secure - Production-ready security settings
  • πŸ“ Logging - Comprehensive error tracking
  • πŸš€ Deployment Ready - Render, Heroku, Docker configs included

πŸš€ Quick Start

Prerequisites

  • Python 3.10 or higher
  • pip package manager
  • 8GB RAM (recommended for training)
  • Git

Installation

# 1. Clone the repository
git clone https://github.com/yourusername/movie-recommendation-system.git
cd movie-recommendation-system

# 2. Create virtual environment
python -m venv venv

# 3. Activate virtual environment
# Windows:
venv\Scripts\activate
# macOS/Linux:
source venv/bin/activate

# 4. Install dependencies
pip install -r requirements.txt

# 5. Run database migrations
python manage.py migrate

# 6. Start the development server
python manage.py runserver

Access the Application

Open your browser and navigate to:

http://localhost:8000

That's it! The demo model (2K movies) is included and works out of the box. πŸŽ‰


πŸ“ Project Structure

movie-recommendation-system/
β”‚
β”œβ”€β”€ πŸ“š Documentation
β”‚   β”œβ”€β”€ README.md                  # This file - overview and quick start
β”‚   β”œβ”€β”€ PROJECT_GUIDE.md           # Complete technical guide
β”‚   └── CHANGELOG.md               # Version history and changes
β”‚
β”œβ”€β”€ βš™οΈ Django Application
β”‚   β”œβ”€β”€ movie_recommendation/      # Django project settings
β”‚   β”‚   β”œβ”€β”€ settings.py           # Configuration
β”‚   β”‚   β”œβ”€β”€ urls.py               # URL routing
β”‚   β”‚   └── wsgi.py               # WSGI entry point
β”‚   β”‚
β”‚   β”œβ”€β”€ recommender/              # Main application
β”‚   β”‚   β”œβ”€β”€ views.py              # Recommendation logic
β”‚   β”‚   β”œβ”€β”€ urls.py               # App URLs
β”‚   β”‚   └── templates/            # HTML templates
β”‚   β”‚       └── recommender/
β”‚   β”‚           β”œβ”€β”€ index.html    # Search page
β”‚   β”‚           β”œβ”€β”€ result.html   # Results page
β”‚   β”‚           └── error.html    # Error page
β”‚   β”‚
β”‚   β”œβ”€β”€ manage.py                 # Django management script
β”‚   └── requirements.txt          # Python dependencies
β”‚
β”œβ”€β”€ πŸŽ“ Model Training
β”‚   └── training/
β”‚       β”œβ”€β”€ train.py              # Training pipeline
β”‚       β”œβ”€β”€ infer.py              # Inference examples
β”‚       └── guide.md              # Training documentation
β”‚
β”œβ”€β”€ 🎯 Models (Created after training)
β”‚   └── models/
β”‚       β”œβ”€β”€ movie_metadata.parquet    # Movie information
β”‚       β”œβ”€β”€ similarity_matrix.npz     # Similarity scores
β”‚       β”œβ”€β”€ title_to_idx.json         # Title mappings
β”‚       β”œβ”€β”€ tfidf_vectorizer.pkl      # TF-IDF model
β”‚       └── svd_model.pkl             # SVD reduction model
β”‚
β”œβ”€β”€ πŸ“¦ Static Files
β”‚   └── static/
β”‚       β”œβ”€β”€ logo.png                  # Application logo
β”‚       β”œβ”€β”€ demo_model.parquet        # Demo similarity model (2K)
β”‚       └── top_2k_movie_data.parquet # Demo movie data (2K)
β”‚
└── πŸš€ Deployment
    β”œβ”€β”€ Procfile                  # Heroku configuration
    β”œβ”€β”€ render.yaml               # Render configuration
    └── .gitignore                # Git ignore rules

πŸ’‘ Usage

Web Interface

  1. Search for a Movie

    • Go to http://localhost:8000
    • Start typing a movie name in the search box
    • Select from autocomplete suggestions or type the full name
  2. View Recommendations

    • Click "Get Recommendations"
    • Browse 15 similar movie suggestions
    • Each card shows: rating, release date, genres, production company
  3. Explore Movies

    • Click "Google" to search for the movie
    • Click "IMDb" to view on IMDb (if available)

API Usage

Search Movies (Autocomplete)

GET /api/search/?q=matrix

Response:
{
  "movies": ["The Matrix", "The Matrix Reloaded", "The Matrix Revolutions"],
  "count": 3
}

Health Check

GET /api/health/

Response:
{
  "status": "healthy",
  "movies_loaded": 100000,
  "model_dir": "./models",
  "model_loaded": true
}

πŸŽ“ Model Training

Using Demo Model

The project includes a pre-trained demo model with 2,000 popular movies. No training needed!

# Demo model is in static/ directory
export MODEL_DIR=./static
python manage.py runserver

Training Your Own Model

Want to train on more movies or your own dataset? See the Training Guide for:

  • πŸ“– Complete training documentation
  • 🎯 Configuration options (10K to 1M+ movies)
  • βš™οΈ Performance tuning guidelines
  • πŸ“Š Dataset requirements
  • πŸ”§ Advanced features

Quick Training Example:

from training.train import MovieRecommenderTrainer

# Initialize trainer
trainer = MovieRecommenderTrainer(
    output_dir='./models',
    use_dimensionality_reduction=True,
    n_components=500
)

# Train on your dataset
df, sim_matrix = trainer.train(
    'path/to/your/dataset.csv',
    quality_threshold='medium',  # low/medium/high
    max_movies=100000            # Limit dataset size
)

For detailed training instructions, see:


πŸ“‘ API Reference

Endpoints

Endpoint Method Description
/ GET Home page with search interface
/ POST Submit movie search and get recommendations
/api/search/ GET Search movies (autocomplete)
/api/health/ GET Health check endpoint

Search Movies

Request:

GET /api/search/?q=inception

Response:

{
  "movies": ["Inception", "Inception: The Cobol Job"],
  "count": 2
}

Health Check

Request:

GET /api/health/

Response:

{
  "status": "healthy",
  "movies_loaded": 100000,
  "model_dir": "./models",
  "model_loaded": true
}

For complete API documentation, see PROJECT_GUIDE.md - API Reference


βš™οΈ Configuration

Environment Variables

Create a .env file (optional for development):

# Django Settings
SECRET_KEY=your-secret-key-here
DEBUG=True
ALLOWED_HOSTS=localhost,127.0.0.1

# Model Configuration
MODEL_DIR=./models

# Database (optional - defaults to SQLite)
# DATABASE_URL=postgresql://user:password@localhost/dbname

# Deployment
# RENDER_EXTERNAL_HOSTNAME=your-app.onrender.com

Using Different Models

To switch between models, set the MODEL_DIR environment variable:

# Use demo model (2K movies)
export MODEL_DIR=./static

# Use your trained model (custom)
export MODEL_DIR=./models

# Use absolute path
export MODEL_DIR=/path/to/your/models

For detailed configuration options, see PROJECT_GUIDE.md - Configuration


πŸ“š Documentation

Main Documentation

  • README.md (this file) - Overview, quick start, basic usage
  • PROJECT_GUIDE.md - Complete technical guide
    • Installation
    • Model training
    • Configuration
    • Development
    • Deployment
    • API reference
    • Troubleshooting
  • CHANGELOG.md - Version history and changes

Training Documentation

  • training/guide.md - Complete model training guide
    • Dataset requirements
    • Training configurations
    • Performance tuning
    • Advanced features

Quick Links

Topic Documentation
Installation Quick Start or PROJECT_GUIDE.md
Model Training training/guide.md
Deployment PROJECT_GUIDE.md - Deployment
API Reference API Reference or PROJECT_GUIDE.md
Troubleshooting PROJECT_GUIDE.md - Troubleshooting
Configuration Configuration or PROJECT_GUIDE.md

πŸš€ Deployment

Quick Deploy to Render

  1. Push your code to GitHub
  2. Connect repository to Render
  3. Render auto-detects render.yaml
  4. Set environment variables
  5. Deploy!

Other Platforms

  • Heroku: Uses Procfile
  • Docker: Create Dockerfile from PROJECT_GUIDE
  • AWS: Elastic Beanstalk compatible
  • Digital Ocean: App Platform ready

For detailed deployment instructions, see PROJECT_GUIDE.md - Deployment


🀝 Contributing

Contributions are welcome! Here's how:

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Guidelines

  • Follow PEP 8 style guide
  • Add tests for new features
  • Update documentation
  • Keep commits focused and descriptive

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ†˜ Support

Need help? Here are your options:


🎯 Roadmap

Version 2.1 (Planned)

  • User authentication system
  • Personal watchlists
  • Movie rating system
  • Advanced filtering (multiple genres, year ranges)
  • Recommendation history

Version 2.2 (Planned)

  • Collaborative filtering
  • Social features (sharing, comments)
  • Movie reviews
  • Advanced analytics dashboard

Version 3.0 (Long-term)

  • Mobile applications (iOS/Android)
  • Real-time recommendations
  • Streaming service integration
  • Enhanced ML models (hybrid recommendations)

πŸ“Š Performance

Metric Value
Recommendation Time < 50ms
Search Response < 100ms
Page Load < 200ms
Memory Usage ~200MB (100K movies)
Concurrent Users 1000+
Model Size 180MB (100K movies)

πŸ™ Acknowledgments

  • Movie data from TMDB and IMDb
  • Built with Django, scikit-learn, pandas
  • UI inspired by modern design principles
  • Community contributions and feedback

Made with ❀️ for movie lovers and developers

⭐ Star this repo β€’ πŸ› Report Bug β€’ πŸ’‘ Request Feature