Project
- Description: A full-stack movie recommendation system that provides movie search and recommendations. The repository contains a React client, an Express server, and a small Python FastAPI service that serves TF-IDF based recommendations using precomputed pickled models.
Features
- Search movies: Query movie details via the OMDb API (server uses
OMDB_API_KEY). - Content-based recommendations: A Python FastAPI service returns TF-IDF recommendations from precomputed data by natural language processing.
- Simple REST API: The
serverexposes endpoints used by the Reactclient.
Tech Stack
- Frontend: React (create-react-app)
- Backend: Node.js + Express
- ML service: Python + FastAPI (served by
uvicorn)
Repository Structure (important files)
client/— React app (run withnpm start)server/— Node/Express API (run withnpm start)server/python-ml/— FastAPI TF-IDF recommender (main.pyand pickled model files)
Prerequisites
- Node.js (16+) and npm
- Python 3.8+ and pip
- An OMDb API key (set as
OMDB_API_KEYin server.env)
Setup & Run (Windows)
- Clone the repo
git clone <repo-url>
cd movie-recommendation-system- Server (Node/Express)
- Install dependencies and set environment variables:
cd server
npm install
# create a .env file with at least:
# OMDB_API_KEY=your_key_here- Start the server:
npm startThe server uses server.js and exposes the API used by the client. The OMDB_API_KEY environment variable is read as process.env.OMDB_API_KEY.
- Python ML service (TF-IDF recommender)
- Create and activate a virtual environment, then install the minimal packages:
cd server/python-ml
python -m venv venv
venv\Scripts\activate
pip install fastapi uvicorn pandas numpy- Start the FastAPI service (binds to port 8001 by default):
uvicorn main:app --host 0.0.0.0 --port 8001Notes:
- The
python-mlfolder already containsdf.pkl,indices.pkl, andtfidf_matrix.pklused bymain.py. - The server calls the recommender at
http://localhost:8001/recommend/tfidf(seeserver/utils/pythonML.js).
- Client (React)
cd ../../client
npm install
npm startThe React app will open in the browser (usually at http://localhost:3000) and talk to the Express server for search and recommendations.
Environment variables
- Create
server/.envwith:
OMDB_API_KEY=your_omdb_key
# (other env vars if added later)
Run order
- Start the Python ML service (
uvicorn) first (so recommender endpoint is available). - Start the Node
servernext (npm start). - Start the React
clientlast (npm startinclient/).
Testing
- Use the browser UI to search for titles and request recommendations.
- You can call recommender directly:
curl "http://localhost:8001/recommend/tfidf?title=The%20Matrix&top_n=5"Troubleshooting
- If the client cannot fetch data, confirm the Express server is running and that CORS is enabled.
- If the recommender returns 404 for a title, the title may not exist in the pickled dataset (ensure titles are normalized and present in
indices.pkl). - If Python packages fail to install, confirm
pipand Python versions; usepython -m pip install --upgrade pip.