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

Sourabh KumarSourabh Kumar
3 min read

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?

0
Subscribe to my newsletter

Read articles from Sourabh Kumar directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Sourabh Kumar
Sourabh Kumar