CinePredict is a Flask-based web application delivering AI-powered movie recommendations through an interactive chatbot interface. It leverages SentenceTransformers to encode user story descriptions for semantic similarity matching and spaCy for keyword extraction to enhance recommendation accuracy. Styled with Tailwind CSS, it offers a responsive UI for users to discover films by story or genre/rating preferences.
- Features
- Installation
- Usage
- Project Structure
- Technologies Used
- Contributing
- License
- Acknowledgments
- AI-Driven Recommendations: Utilizes SentenceTransformers (
all-mpnet-base-v2) for semantic similarity and spaCy (en_core_web_sm) for keyword extraction to deliver precise movie recommendations. - Story-Based Recommendations: Users can input a movie plot description, and the AI matches it to similar movies using semantic and keyword analysis.
- Genre & Rating Filters: Filter movies by preferred genre (e.g., Action, Comedy) and minimum rating (e.g., 7.0).
- Responsive Interface: Built with Tailwind CSS for a modern, dark-mode-compatible UI with a clean chatbot design.
- Interactive Chatbot: Provides a user-friendly interface for seamless interaction and movie discovery.
- Data Pipeline: Includes scripts to fetch movie data from TMDB and generate embeddings for recommendations.
- Python 3.8 or higher
- pip (Python package manager)
- Node.js (optional, for Tailwind CSS build if not using CDN)
- Git (for cloning the repository)
- TMDB API key (sign up at TMDB to obtain one)
-
Clone the Repository
https://github.com/maheenshkk/ai-powered-chatbot-cinepredict.git cd cinepredict -
Create and Activate a Virtual Environment
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install Python Dependencies
pip install -r requirements.txt python -m spacy download en_core_web_sm
-
Fetch Movie Data
-
Edit
fetch_movie_data.pyto add your TMDB API key:TMDB_API_KEY = "your_tmdb_api_key_here" # Replace with your TMDB API key
-
Run the script to generate
movies_cleaned.csv:python fetch_movie_data.py
-
-
Generate Embeddings
-
Run the script to generate
embeddings.npyfrommovies_cleaned.csv:python generate_embeddings.py
-
-
Run the Application
python app.py
- Open your browser and navigate to
http://localhost:5000.
- Open your browser and navigate to
-
Access the Web App
- Visit
http://localhost:5000to view the CinePredict interface. - Browse a grid of featured movies with posters, genres, years, ratings, and summaries.
- Visit
-
Interact with the Chatbot
- Click the "CinePredict AI" button (bottom-right corner) to open the chatbot modal.
- Type
storyto get recommendations based on a plot description (e.g., "A hacker discovers a simulated reality"). - Type
genreto filter movies by genre (e.g., "Action") and minimum rating (e.g., "7.0"). - Follow the chatbot prompts to refine your input.
-
View Recommendations
- Recommendations are displayed in a styled container, with each movie listed on a separate line, including title and rating (e.g., "- The Matrix (Rating: 8.7)").
- The chatbot supports iterative queries, allowing you to try different stories or genres.
cinepredict/
├── static/
│ └── styles.css # Custom CSS for recommendation styling
├── templates/
│ └── index.html # HTML template with Tailwind CSS and jQuery
├── app.py # Flask backend with AI recommendation logic
├── fetch_movie_data.py # Script to fetch movie data and create movies_cleaned.csv
├── generate_embeddings.py # Script to generate embeddings and create embeddings.npy
├── movies_cleaned.csv # Movie dataset (generated, not included)
├── embeddings.npy # Precomputed movie embeddings (generated, not included)
├── requirements.txt # Python dependencies
└── README.md # Project documentation
- Backend:
- Flask: Web framework for routing and rendering templates.
- SentenceTransformers (
all-mpnet-base-v2): Encodes movie plots for semantic similarity matching. - spaCy (
en_core_web_sm): Extracts keywords for enhanced recommendation accuracy. - pandas & numpy: Handles movie data and embeddings.
- scikit-learn: Computes cosine similarity for recommendations.
- requests: Fetches movie data from the TMDB API.
- Frontend:
- Tailwind CSS: Provides responsive, utility-first styling via CDN.
- jQuery: Manages AJAX requests and DOM manipulation for the chatbot.
- HTML/CSS/JavaScript: Structures the UI and handles interactivity.
- Environment:
- Python 3.8+: Runs the backend logic.
- Browser-compatible: No additional client-side setup required.
We welcome contributions to enhance CinePredict! To contribute:
-
Fork the repository.
-
Create a feature branch:
git checkout -b feature/your-feature
-
Commit your changes:
git commit -m "Add your feature" -
Push to the branch:
git push origin feature/your-feature
-
Open a pull request on GitHub.
Please adhere to PEP 8 for Python code and include relevant tests or documentation updates.
This project is licensed under the MIT License. See the LICENSE file for details.
- Built with Flask, SentenceTransformers, spaCy, and TMDB API.
- Styled using Tailwind CSS for a modern, responsive UI.
- Inspired by movie recommendation systems and datasets like IMDb and TMDB.