# fuongfotfet/movie-recommendation-system architecture

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

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

## Overview

##### Project Type and Purpose
- This is a full-fledged movie recommendation platform that integrates multiple recommendation algorithms:
– Neural Collaborative Filtering (NCF)
– KNN + FAISS (Approximate Nearest Neighbors)
– Content-based Filtering
- Besides the recommendation algorithms and data processing, a web-based prototype is provided for user interactions, allowing users to select genres, pick movies, and receive real-time recommendations.

##### Analyzing the File Structure
- The project is structured to separate different recommendation approaches into their own directories:
– “Neural Collaborative Filtering” contains notebooks, scripts, and saved model checkpoints.
– “Collaborative Filtering – KNN and ANN” includes a FAISS-based implementation as well as KNN scripts and accompanying Jupyter notebooks.
– “Content-Based Filtering” contains the content-based implementation.
- The “web” directory is dedicated to the front-end and back-end components:
– The “web/main/frontend” directory houses the HTML, CSS, and JavaScript files that form the user interface prototype.
- Data used by different modules is located within “data” directories across several modules – these include CSV files with user data, movie metadata, ratings, etc.
- Other accompanying directories and files (e.g., “document” with a Report PDF) provide complementary documentation and reports.

A. Data Sources:
– Files in various “data” folders (CSV files like u_data.csv, u_genre.csv, train/test splits for NCF, etc.)
– Movie metadata (possibly extended via TMDB integration)
B. Recommendation Engines:
– Neural Collaborative Filtering: Modules (NCF.ipynb, NCF.py, & trained models) representing deep learning-based recommendations.
– KNN + FAISS: Modules (faiss_final.py, knn.py, and their corresponding notebooks) handling high-dimensional vector similarity searches.
– Content-based Filtering: Scripts (content_based.ipynb and content_based.py) analyzing movie metadata for similarity.
C. Web Application Layer:
– Backend: Flask/Python app (app.py) tying in recommendation logic.
- Contains submodules for the different recommendation approaches within “web/main/backend”.
- Additional backend scripts for obtaining movie posters, trending items, top genres or ratings.
– Frontend: User interfaces in “web/main/frontend” that allow users to select genres, choose movies, and view recommendations.
D. External Integrations and Dependencies:
– FAISS library for conducting fast approximate nearest-neighbor searches.
– TensorFlow (for Neural Collaborative Filtering).
– Python libraries such as numpy, pandas, and scikit-learn.
– Optional integration with TMDB for enhanced movie metadata.

##### Elements
- Clear labels for each component, for example:
– “Data Source – CSV files”
– “Neural Collaborative Filtering Engine”
– “KNN + FAISS Engine”
– “Content-Based Filtering Engine”
– “Flask Application (API & Routing)”
– “Frontend: Select Genres, Movie Selection, Recommendation Display”
– Inputs to processing engines, outputs from engines routed back to API layers, and then to the UI.
- Annotations or notes to indicate dependencies and technology stacks (e.g., “FAISS” next to the KNN module, “TensorFlow” with NCF).

Happy diagramming!

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Sources
    Data_NCF("NCF Data (CSV)"):::data
    Data_CF("Collaborative Filtering Data (CSV)"):::data

    %% External Dependencies
    External("External Dependencies: FAISS, TensorFlow, TMDB, numpy, pandas, scikit-learn"):::external

    %% Recommendation Engines
    subgraph "Neural Collaborative Filtering Engine"
        ncfNotebook("NCF Notebook"):::engine
        ncfScript("NCF Script"):::engine
        ncfModel("Trained Model Checkpoint"):::engine
    end

    subgraph "KNN + FAISS Engine"
        subgraph "FAISS Module"
            faissNotebook("FAISS Notebook"):::engine
            faissScript("FAISS Script"):::engine
        end
        subgraph "KNN Module"
            knnNotebook("KNN Notebook"):::engine
            knnScript("KNN Script"):::engine
        end
        knnOut("KNN+FAISS Output")
    end

    subgraph "Content-Based Filtering Engine"
        contentBasedNotebook("Content-Based Notebook"):::engine
        contentBasedScript("Content-Based Script"):::engine
        getSimilar("Get Similar Module"):::engine
        contentOut("Content-Based Output")
    end

    %% Intermediate Output node for NCF
    ncfOut("NCF Output"):::engine

    %% Web Application Layer
    Flask_API("Flask API (Web Service)"):::api

    %% Frontend Layer
    Frontend_UI("Frontend UI"):::frontend

    %% Data Flow Connections
    Data_NCF -->|"input"| ncfNotebook
    Data_CF -->|"input"| faissNotebook
    Data_CF -->|"input"| contentBasedNotebook

    %% External Dependencies Connections
    External -->|"TensorFlow"| ncfNotebook
    External -->|"FAISS"| faissNotebook
    External -->|"TMDB"| contentBasedNotebook

    %% Neural Collaborative Filtering Flow
    ncfNotebook --> ncfScript
    ncfScript --> ncfModel
    ncfModel --> ncfOut

    %% KNN + FAISS Flow
    faissNotebook --> faissScript
    faissScript --> knnOut
    knnNotebook --> knnScript
    knnScript --> knnOut

    %% Content-Based Filtering Flow
    contentBasedNotebook --> contentBasedScript
    contentBasedScript --> getSimilar
    getSimilar --> contentOut

    %% Combine Recommendation Outputs to Web API
    ncfOut --> Flask_API
    knnOut --> Flask_API
    contentOut --> Flask_API

    %% Web API to Frontend
    Flask_API --> Frontend_UI

    %% Styling Classes
    class Data_NCF,Data_CF data;
    class ncfNotebook,ncfScript,ncfModel,ncfOut,faissNotebook,faissScript,knnNotebook,knnScript,knnOut,contentBasedNotebook,contentBasedScript,getSimilar,contentOut engine;
    class Flask_API api;
    class Frontend_UI frontend;
    class External external;

    %% Click Events
    click ncfNotebook "https://github.com/fuongfotfet/movie-recommendation-system/blob/main/Neural Collaborative Filtering/NCF.ipynb"
    click ncfScript "https://github.com/fuongfotfet/movie-recommendation-system/blob/main/Neural Collaborative Filtering/NCF.py"
    click ncfModel "https://github.com/fuongfotfet/movie-recommendation-system/tree/main/Neural Collaborative Filtering/NeuMF_trained_model1"
    click faissNotebook "https://github.com/fuongfotfet/movie-recommendation-system/blob/main/Collaborative Filtering - KNN and ANN/FAISS/faiss_final.ipynb"
    click faissScript "https://github.com/fuongfotfet/movie-recommendation-system/blob/main/Collaborative Filtering - KNN and ANN/FAISS/faiss_final.py"
    click knnNotebook "https://github.com/fuongfotfet/movie-recommendation-system/blob/main/Collaborative Filtering - KNN and ANN/KNN/knn.ipynb"
    click knnScript "https://github.com/fuongfotfet/movie-recommendation-system/blob/main/Collaborative Filtering - KNN and ANN/KNN/knn.py"
    click contentBasedNotebook "https://github.com/fuongfotfet/movie-recommendation-system/blob/main/Content-Based Filtering/content_based.ipynb"
    click contentBasedScript "https://github.com/fuongfotfet/movie-recommendation-system/blob/main/web/main/backend/content_based/content_based.py"
    click getSimilar "https://github.com/fuongfotfet/movie-recommendation-system/blob/main/web/main/backend/content_based/get_similar.py"
    click Data_CF "https://github.com/fuongfotfet/movie-recommendation-system/tree/main/Collaborative Filtering - KNN and ANN/data"
    click Data_NCF "https://github.com/fuongfotfet/movie-recommendation-system/tree/main/Neural Collaborative Filtering/data"
    click Flask_API "https://github.com/fuongfotfet/movie-recommendation-system/blob/main/web/main/app.py"
    click Frontend_UI "https://github.com/fuongfotfet/movie-recommendation-system/tree/main/web/main/frontend"
```
