How mithra-21/movie-recommendation-system works
1. Repository purpose
- This is a movie recommendation application centered on content-based filtering.
- The main runtime looks to be a Streamlit app (app.py) that lets a user browse movies, get recommendations, view movie details, and interact through ratings, watchlists, and feedback.
2. Primary runtime boundary
- The user-facing application is the Streamlit frontend + application logic in app.py.
- There is no sign of a separate API server or database layer; the app appears to run as a single-process, file-backed application.
3. Offline data preparation pipeline
- The notebook recomender system-checkpoint.ipynb is the offline preprocessing / model-building step.
- Its role is to transform raw movie data into runtime artifacts, especially:
- movie_list.pkl
- similarity.pkl
- These artifacts are then loaded by the app at runtime to generate recommendations quickly.
4. Recommendation engine
- The recommendation logic is based on text similarity over movie metadata.
- Per the README, the model combines fields such as genres, cast, crew, keywords, title, overview, movie ID, and tags into a unified representation.
- That similarity matrix is the core engine for finding “nearest” movies to a user’s selected movie or preferences.
5. Data sources and persisted user state
- The repo includes CSV-backed state files:
- users.csv
- watchlist.csv
- feedback.csv
- These likely represent persistent user/account data, saved watchlist entries, and feedback history.
- This suggests the system stores mutable user interactions in flat files rather than a relational database.
6. Authentication subsystem
- generate_keys.py is used to generate hashed_pw.pkl, which implies a password hashing / login bootstrap flow.
- The README explicitly references streamlit-authenticator==0.1.5, so authentication is integrated into the Streamlit app rather than handled by an external identity service.
7. User interaction features
- Beyond recommendations, the app supports:
- movie ratings
- watchlist management
- user feedback
- movie detail display such as cast, crew, and overview
- These features feed back into the persisted CSV files and may influence future recommendations or personalization.
8. Artifact-driven architecture
- The repo depends on prebuilt artifacts stored outside the main source files, specifically in an artifacts directory mentioned in the README.
- At runtime, app.py likely reads those serialized objects instead of recomputing similarity from raw data, which keeps the app responsive.
9. Source layout
- src/ exists as a Python package, but only src/__init__.py is present in the tree, so most of the implemented logic likely lives in app.py and the notebook.
- setup.py and requirements.txt define the environment and dependency set for running the app and its preprocessing steps.
10. External dependencies that affect architecture
- The app depends on Streamlit for the UI and streamlit-authenticator for login.
- The README also mentions creating an API key, which suggests at least one external integration exists or is planned, but the concrete service is not visible from the file tree.
11. End-to-end data flow
- Raw movie dataset → notebook preprocessing → serialized recommendation artifacts → Streamlit app loads artifacts → user selects a movie / preference → similarity lookup returns recommendations → user actions are saved to CSV files.
12. Architectural summary for diagramming
- Draw this as a two-phase system:
- Offline preprocessing phase: dataset + notebook → recommendation artifacts
- Online interactive phase: Streamlit app → authentication → recommendation lookup → user persistence
- The main boundary is between read-only model/artifact loading and mutable user data stored in CSV files.
Main entry points: app.py Streamlit app · recomender system-checkpoint.ipynb Prep notebook · users.csv Users · watchlist.csv Watchlist
Components 17
Offline prep
Builds recommendation artifacts from the raw movie dataset.
- Movie data · Source movie metadata used to build the recommendation model.
dataset - Prep notebook · Offline feature engineering and similarity generation.
recomender system-checkpoint.ipynb - Model artifacts · Prebuilt objects loaded at runtime for fast recommendation lookup.
- Movie list · Serialized movie index/list used by the app.
- Similarity matrix · Serialized pairwise similarity structure for content-based ranking.
Interactive app
Streamlit runtime for browsing, login, recommendations, and user actions.
- Streamlit app · Main user-facing process coordinating UI, auth, recommendations, and persistence.
app.py - Browse UI · Movie browsing, detail display, and recommendation interaction surface.
- Recommender · Selects nearest movies using precomputed similarity over movie metadata.
- Login · Streamlit-authenticator based sign-in and user session setup.
- Key bootstrap · Generates hashed credentials used by the login flow.
generate_keys.py - Ratings · Captures explicit movie ratings from the user.
Persistent data
Flat-file state used by the app and bootstrap scripts.
Other components
- Environment · Python dependencies and packaging metadata for app and preprocessing.
requirements.txt - Package setup · Project packaging and install configuration.
setup.py - Src package · Package namespace placeholder for shared code.
src/__init__.py
Connections 21
- Movie data → Prep notebook: inputs · Raw movie data is transformed offline.
- Prep notebook → Movie list: writes · Builds the serialized movie index.
- Prep notebook → Similarity matrix: writes · Computes and serializes similarity structure.
- Movie list → Model artifacts: bundled · Serialized movie list becomes part of runtime artifacts.
- Similarity matrix → Model artifacts: bundled · Serialized similarity matrix becomes part of runtime artifacts.
- Streamlit app → Browse UI: renders · The Streamlit runtime presents the browsing interface.
- Streamlit app → Login: uses · Login is integrated into the app session.
- Key bootstrap → Users: bootstraps · Credential hashes are generated for stored users.
- Streamlit app → Model artifacts: loads · Runtime recommendation lookup uses prebuilt artifacts.
- Model artifacts → Recommender: feeds · Artifacts provide the data needed for ranking.
- Browse UI → Recommender: requests · User selections trigger recommendation lookup.
- Recommender → Ratings: consumes · Explicit user ratings can shape interaction state.
- Browse UI → Watchlist: persists · Saved movies are written to flat-file state.
- Browse UI → Feedback: persists · User feedback is stored for later use.
- Login → Users: checks · Authentication consults the user store.
- Streamlit app → Watchlist: reads/writes · Watchlist is part of the interactive runtime state.
- Streamlit app → Feedback: reads/writes · Feedback is captured by the app process.
- Streamlit app → Users: reads/writes · User metadata is maintained in flat files.
- Streamlit app → Environment: depends on · Runtime and preprocessing share the project dependencies.
- Streamlit app → Package setup: depends on · Packaging metadata supports installation and execution.
- Streamlit app → Src package: imports · Shared package namespace is available to the app.