How to Build a Movie Recommendation App with Streamlit: Step-by-Step

Table of contents
# **How to Build a Movie Recommendation App with Streamlit: Step-by-Step** ๐ฌ
Choosing the right movie to watch can be frustrating. Recommendation systems, like those used by **Netflix and Prime Video**, help by suggesting movies based on user interests.
This blog shares how I built a **Movie Recommendation System** using **Python, Streamlit, and the TMDb API**. The goal was to create a simple yet effective system that:
โ **Suggests movies similar to the one selected**
โ **Fetches movie posters dynamically**
โ **Has a clean and interactive UI**
โ **Can be deployed online for free**
---
## **Technologies Used**
For this project, I used:
๐น **Python** โ The core programming language
๐น **Pandas & NumPy** โ For data handling and processing
๐น **Scikit-Learn** โ To build the recommendation algorithm
๐น **TMDb API** โ To fetch movie posters dynamically
๐น **Streamlit** โ To build the interactive web app
๐น **Git & GitHub** โ To manage and deploy the project
๐น **Git LFS** โ To handle large datasets
---
## **Step 1: How the Recommendation System Works**
A **Content-Based Filtering** approach was implemented to recommend movies based on their similarity to a selected movie.
### **Process:**
1๏ธโฃ **User selects a movie** from the dropdown.
2๏ธโฃ **The system finds similar movies** using machine learning techniques.
3๏ธโฃ **Movie posters are fetched** using the TMDb API.
4๏ธโฃ **Results are displayed** in an interactive UI.
This ensures relevant recommendations while keeping the experience visually engaging.
---
## **Step 2: Fetching Movie Posters with TMDb API**
To enhance the UI, the **TMDb API** was used to fetch movie posters.
```python
import requests
API_KEY = "your_tmdb_api_key"
def get_movie_poster(movie_id):
url = f"https://api.themoviedb.org/3/movie/{movie_id}?api_key={API_KEY}"
response = requests.get(url).json()
poster_path = response["poster_path"]
full_poster_url = f"https://image.tmdb.org/t/p/w500{poster_path}"
return full_poster_url
This function takes a movie ID, calls the TMDb API, and returns the poster URL, which is then displayed in the Streamlit app.
---
Step 3: Deploying the App for Free
The app was deployed on Streamlit Community Cloud, a free hosting platform for Streamlit apps.
Steps to Deploy:
1๏ธโฃ Push the Code to GitHub
git init
git add .
git commit -m "First commit"
git branch -M main
git remote add origin https://github.com/Sourabh-Kumar04/Raso-Movie-Recommendation.git
git push -u origin main
2๏ธโฃ Deploy on Streamlit Cloud
Go to Streamlit Community Cloud
Click on "New app"
Select the GitHub repository
Click "Deploy"
The app went live within minutes. ๐
๐ Live App: Raso Movie Recommendation
---
Step 4: Handling Large Files with Git LFS
Since a large dataset was used, Git LFS (Large File Storage) was implemented to manage it efficiently.
sudo apt install git-lfs # Install Git LFS
This prevented upload errors and ensured smooth version control of large files.
---
What I Learned
This project provided valuable insights into:
โ How recommendation systems work
โ Working with APIs (TMDb) to fetch data
โ Deploying a project for free with Streamlit
โ Handling large datasets using Git LFS
โ Building interactive UI with Streamlit
---
Try It Out!
The Movie Recommendation System is live and open for feedback!
๐ Live Demo: Raso Movie Recommendation
๐ GitHub Repo: Sourabh-Kumar04/Raso-Movie-Recommendation
๐ Connect with Me on LinkedIn: Sourabh Kumar
---
Final Thoughts
Writing this first blog on Hashnode has been a great experience! ๐
Let me know your thoughts in the comments. Also, feel free to connect and share feedback!
What should I build next?
Subscribe to my newsletter
Read articles from Sourabh Kumar directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
