# mithra-21/movie-recommendation-system architecture

> Architecture diagram of the GitHub repository mithra-21/movie-recommendation-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mithra-21/movie-recommendation-system
- Repository: https://github.com/mithra-21/movie-recommendation-system

## Overview

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`](https://github.com/mithra-21/movie-recommendation-system/blob/main/app.py) (Streamlit app), [`recomender system-checkpoint.ipynb`](https://github.com/mithra-21/movie-recommendation-system/blob/HEAD/recomender%20system-checkpoint.ipynb) (Prep notebook), [`users.csv`](https://github.com/mithra-21/movie-recommendation-system/blob/main/users.csv) (Users), [`watchlist.csv`](https://github.com/mithra-21/movie-recommendation-system/blob/main/watchlist.csv) (Watchlist)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_offline["Offline prep"]
  node_dataset[("Movie data<br/>raw dataset")]
  node_notebook["Prep notebook<br/>preprocessing notebook"]
  node_artifacts[("Model artifacts<br/>serialized recommender data")]
  node_movie_list["Movie list<br/>pkl artifact"]
  node_similarity["Similarity matrix<br/>pkl artifact"]
end

subgraph group_online["Interactive app"]
  node_app["Streamlit app<br/>runtime entrypoint<br/>[app.py]"]
  node_ui["Browse UI<br/>presentation layer"]
  node_rec_engine{{"Recommender<br/>content-based engine"}}
  node_auth["Login<br/>auth flow"]
  node_keys["Key bootstrap<br/>hash generator<br/>[generate_keys.py]"]
  node_rating(("Ratings<br/>user input"))
end

subgraph group_data["Persistent data"]
  node_watchlist["Watchlist<br/>saved list<br/>[watchlist.csv]"]
  node_feedback["Feedback<br/>[feedback.csv]"]
  node_users["Users<br/>account store<br/>[users.csv]"]
end

node_build["Environment<br/>deps and packaging<br/>[requirements.txt]"]
node_setup["Package setup<br/>build config<br/>[setup.py]"]
node_srcpkg["Src package<br/>python package<br/>[__init__.py]"]

node_dataset -->|"inputs"| node_notebook
node_notebook -->|"writes"| node_movie_list
node_notebook -->|"writes"| node_similarity
node_movie_list -->|"bundled"| node_artifacts
node_similarity -->|"bundled"| node_artifacts
node_app -->|"renders"| node_ui
node_app -->|"uses"| node_auth
node_keys -->|"bootstraps"| node_users
node_app -->|"loads"| node_artifacts
node_artifacts -->|"feeds"| node_rec_engine
node_ui -->|"requests"| node_rec_engine
node_rec_engine -.->|"consumes"| node_rating
node_ui -->|"persists"| node_watchlist
node_ui -->|"persists"| node_feedback
node_auth -->|"checks"| node_users
node_app -->|"reads/writes"| node_watchlist
node_app -->|"reads/writes"| node_feedback
node_app -->|"reads/writes"| node_users
node_app -.->|"depends on"| node_build
node_app -.->|"depends on"| node_setup
node_app -.->|"imports"| node_srcpkg

click node_dataset "https://github.com/mithra-21/movie-recommendation-system/tree/main/dataset"
click node_notebook "https://github.com/mithra-21/movie-recommendation-system/blob/main/recomender system-checkpoint.ipynb"
click node_app "https://github.com/mithra-21/movie-recommendation-system/blob/main/app.py"
click node_keys "https://github.com/mithra-21/movie-recommendation-system/blob/main/generate_keys.py"
click node_watchlist "https://github.com/mithra-21/movie-recommendation-system/blob/main/watchlist.csv"
click node_feedback "https://github.com/mithra-21/movie-recommendation-system/blob/main/feedback.csv"
click node_users "https://github.com/mithra-21/movie-recommendation-system/blob/main/users.csv"
click node_build "https://github.com/mithra-21/movie-recommendation-system/blob/main/requirements.txt"
click node_setup "https://github.com/mithra-21/movie-recommendation-system/blob/main/setup.py"
click node_srcpkg "https://github.com/mithra-21/movie-recommendation-system/blob/main/src/__init__.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_dataset,node_notebook,node_artifacts,node_movie_list,node_similarity toneBlue
class node_app,node_ui,node_rec_engine,node_auth,node_keys,node_rating toneAmber
class node_watchlist,node_feedback,node_users toneMint
class node_build,node_setup,node_srcpkg toneNeutral
```

## Components

### Offline prep

Builds recommendation artifacts from the raw movie dataset.

- [Movie data](https://github.com/mithra-21/movie-recommendation-system/tree/main/dataset): raw dataset · Source movie metadata used to build the recommendation model. · `dataset`
- [Prep notebook](https://github.com/mithra-21/movie-recommendation-system/blob/HEAD/recomender%20system-checkpoint.ipynb): preprocessing notebook · Offline feature engineering and similarity generation. · `recomender system-checkpoint.ipynb`
- **Model artifacts**: serialized recommender data · Prebuilt objects loaded at runtime for fast recommendation lookup.
- **Movie list**: pkl artifact · Serialized movie index/list used by the app.
- **Similarity matrix**: pkl artifact · Serialized pairwise similarity structure for content-based ranking.

### Interactive app

Streamlit runtime for browsing, login, recommendations, and user actions.

- [Streamlit app](https://github.com/mithra-21/movie-recommendation-system/blob/main/app.py): runtime entrypoint · Main user-facing process coordinating UI, auth, recommendations, and persistence. · `app.py`
- **Browse UI**: presentation layer · Movie browsing, detail display, and recommendation interaction surface.
- **Recommender**: content-based engine · Selects nearest movies using precomputed similarity over movie metadata.
- **Login**: auth flow · Streamlit-authenticator based sign-in and user session setup.
- [Key bootstrap](https://github.com/mithra-21/movie-recommendation-system/blob/main/generate_keys.py): hash generator · Generates hashed credentials used by the login flow. · `generate_keys.py`
- **Ratings**: user input · Captures explicit movie ratings from the user.

### Persistent data

Flat-file state used by the app and bootstrap scripts.

- [Watchlist](https://github.com/mithra-21/movie-recommendation-system/blob/main/watchlist.csv): saved list · Persistent user watchlist state. · `watchlist.csv`
- [Feedback](https://github.com/mithra-21/movie-recommendation-system/blob/main/feedback.csv): feedback log · Persistent user feedback records. · `feedback.csv`
- [Users](https://github.com/mithra-21/movie-recommendation-system/blob/main/users.csv): account store · Flat-file user records used by the app. · `users.csv`

### Other components

- [Environment](https://github.com/mithra-21/movie-recommendation-system/blob/main/requirements.txt): deps and packaging · Python dependencies and packaging metadata for app and preprocessing. · `requirements.txt`
- [Package setup](https://github.com/mithra-21/movie-recommendation-system/blob/main/setup.py): build config · Project packaging and install configuration. · `setup.py`
- [Src package](https://github.com/mithra-21/movie-recommendation-system/blob/main/src/__init__.py): python package · Package namespace placeholder for shared code. · `src/__init__.py`

## Connections

- 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.
