# nethbotheju/movie-prediction architecture

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

- Interactive diagram: https://gitdiagram.com/nethbotheju/movie-prediction
- Repository: https://github.com/nethbotheju/movie-prediction

## Overview

##### Project Type and Purpose
- This is a full-stack machine-learning web application that predicts movie information based on user-provided summaries.
- It consists of four major phases: data preparation (Dataset), model training (Model), model serving (Backend), and user interaction via a web UI (Frontend).

##### Main Components
a. Dataset Layer
- Jupyter notebooks under `dataset/` and `model/clean_data.ipynb`
- Original CSVs: `dataset/original_datasets/*.csv`
- Cleaned outputs: `dataset/created_datasets/*.csv`
b. Model Training Layer
- Training script: `model/train_model.py`
- Fine-tuned Sentence-Transformers model under `model/fine_tuned_model/`
- Embedding generation: `movie_embeddings.npy`, FAISS index `movie_index.faiss`, metadata `movie_metadata.csv`
c. Model Serving Layer (Backend)
- Flask app entrypoint: `backend/app.py`
- Environment definition: `backend/environment.yml`
- Loads fine-tuned model and FAISS index, exposes REST endpoints for prediction
d. Frontend Layer
- Vue.js single page app under `frontend/src/`
- Entrypoint: `frontend/index.html` + `main.ts`
- Components: `Window.vue` for UI, CSS under `style.css`
- Build config: `package.json`, `vite.config.ts`

##### Relationships and Data Flows
- Data Ingestion Flow:
dataset/original_datasets → data cleaning notebook → created_datasets
↓
`train_model.py` reads cleaned data → fine-tuned model + embeddings + index
- Serving Flow:
REST API (Flask) loads model artifacts → user query inbound via HTTP → compute embeddings → FAISS search → send back predictions
- UI Flow:
User’s browser → Vue.js app (HTTP GET/POST) → Flask backend → returns JSON → Vue displays results

##### Architectural Patterns and Key Technologies
- Layered architecture separating Data, Model, API, and UI
- Model-View-Controller concept applied loosely: Flask handles “Controller,” model artifacts act as “Model,” Vue.js is the “View.”
- Technologies:
- Python, Conda, PyTorch/sentence-transformers
- FAISS for approximate nearest neighbors
- Flask for REST API
- Vue.js + Vite + TypeScript for frontend

- Dataset Ingestion & Cleaning (notebooks, CSVs)
- Model Training Service (script, fine-tuned model, embeddings, FAISS index)
- Model Serving API (Flask app)
- Web Client (Vue.js SPA)
- External user actor (Browser)
- From original CSV → cleaning → cleaned CSV
- From cleaned CSV → training → model artifacts
- From model artifacts → loaded by backend
- From user → HTTP request → Flask → FAISS search → HTTP response → frontend
d. Labels:
- Technology stacks next to components (e.g., “Vue.js + TypeScript”).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Actor
    Browser["User’s Browser"]:::external

    %% Dataset Layer
    subgraph "Dataset Layer"
        direction TB
        Orig1["imdb.csv"]:::data
        Orig2["plot.csv"]:::data
        Orig3["wikipedia.csv"]:::data
        NB1["imdb.ipynb"]:::data
        NB2["wikipedia.ipynb"]:::data
        NB3["dataset.ipynb"]:::data
        Clean1["imdb_clean.csv"]:::data
        Clean2["wikipedia_clean.csv"]:::data
    end

    %% Model Training Layer
    subgraph "Model Training Layer"
        direction TB
        Train["train_model.py"]:::ml
        EnvTrain["environment.yml"]:::ml
        ModelDir["fine_tuned_model"]:::ml
        Embeddings["movie_embeddings.npy"]:::ml
        Index["movie_index.faiss"]:::ml
        Metadata["movie_metadata.csv"]:::ml
    end

    %% Model Serving Layer
    subgraph "Model Serving Layer"
        direction TB
        Flask["Flask API: app.py"]:::api
        EnvServe["environment.yml"]:::api
        ReqTxt["requirments.txt"]:::api
        ModelDirServe["fine_tuned_model"]:::api
        EmbServe["movie_embeddings.npy"]:::api
        IndexServe["movie_index.faiss"]:::api
        MetadataServe["movie_metadata.csv"]:::api
    end

    %% Frontend Layer
    subgraph "Frontend Layer"
        direction TB
        IndexHtml["index.html"]:::frontend
        MainTS["main.ts"]:::frontend
        AppVue["App.vue"]:::frontend
        WindowVue["Window.vue"]:::frontend
        Style["style.css"]:::frontend
        Package["package.json"]:::frontend
        ViteCfg["vite.config.ts"]:::frontend
    end

    %% Data Flows - Dataset to Training
    Orig1 --> NB1 --> Clean1
    Orig2 --> NB3
    Orig3 --> NB2 --> Clean2
    NB3 --> Clean1
    NB3 --> Clean2
    Clean1 --> Train
    Clean2 --> Train

    %% Training Outputs
    Train --> ModelDir
    Train --> Embeddings
    Train --> Index
    Train --> Metadata

    %% Training to Serving
    ModelDir --> ModelDirServe
    Embeddings --> EmbServe
    Index --> IndexServe
    Metadata --> MetadataServe

    %% User Interaction Flow
    Browser --> IndexHtml
    Browser -->|HTTP GET/POST| Flask
    Flask -->|JSON Response| AppVue
    AppVue --> Browser

    %% Frontend Internal Flow
    IndexHtml --> MainTS --> AppVue
    AppVue --> WindowVue
    AppVue --> Style
    ViteCfg --> Package

    %% Click Events - Dataset
    click NB1 "https://github.com/nethbotheju/movie-prediction/blob/main/dataset/imdb.ipynb"
    click NB2 "https://github.com/nethbotheju/movie-prediction/blob/main/dataset/wikipedia.ipynb"
    click NB3 "https://github.com/nethbotheju/movie-prediction/blob/main/dataset/dataset.ipynb"
    click Orig1 "https://github.com/nethbotheju/movie-prediction/blob/main/dataset/original_datasets/imdb.csv"
    click Orig2 "https://github.com/nethbotheju/movie-prediction/blob/main/dataset/original_datasets/plot.csv"
    click Orig3 "https://github.com/nethbotheju/movie-prediction/blob/main/dataset/original_datasets/wikipedia.csv"
    click Clean1 "https://github.com/nethbotheju/movie-prediction/blob/main/dataset/created_datasets/imdb_clean.csv"
    click Clean2 "https://github.com/nethbotheju/movie-prediction/blob/main/dataset/created_datasets/wikipedia_clean.csv"

    %% Click Events - Model Training
    click Train "https://github.com/nethbotheju/movie-prediction/blob/main/model/train_model.py"
    click EnvTrain "https://github.com/nethbotheju/movie-prediction/blob/main/model/environment.yml"
    click ModelDir "https://github.com/nethbotheju/movie-prediction/tree/main/model/fine_tuned_model/"
    click Embeddings "https://github.com/nethbotheju/movie-prediction/blob/main/model/movie_embeddings.npy"
    click Index "https://github.com/nethbotheju/movie-prediction/blob/main/model/movie_index.faiss"
    click Metadata "https://github.com/nethbotheju/movie-prediction/blob/main/model/movie_metadata.csv"

    %% Click Events - Model Serving
    click Flask "https://github.com/nethbotheju/movie-prediction/blob/main/backend/app.py"
    click EnvServe "https://github.com/nethbotheju/movie-prediction/blob/main/backend/environment.yml"
    click ReqTxt "https://github.com/nethbotheju/movie-prediction/blob/main/backend/requirments.txt"
    click ModelDirServe "https://github.com/nethbotheju/movie-prediction/tree/main/backend/fine_tuned_model/"
    click EmbServe "https://github.com/nethbotheju/movie-prediction/blob/main/backend/movie_embeddings.npy"
    click IndexServe "https://github.com/nethbotheju/movie-prediction/blob/main/backend/movie_index.faiss"
    click MetadataServe "https://github.com/nethbotheju/movie-prediction/blob/main/backend/movie_metadata.csv"

    %% Click Events - Frontend
    click IndexHtml "https://github.com/nethbotheju/movie-prediction/blob/main/frontend/index.html"
    click MainTS "https://github.com/nethbotheju/movie-prediction/blob/main/frontend/src/main.ts"
    click AppVue "https://github.com/nethbotheju/movie-prediction/blob/main/frontend/src/App.vue"
    click WindowVue "https://github.com/nethbotheju/movie-prediction/blob/main/frontend/src/components/Window.vue"
    click Style "https://github.com/nethbotheju/movie-prediction/blob/main/frontend/src/style.css"
    click Package "https://github.com/nethbotheju/movie-prediction/blob/main/frontend/package.json"
    click ViteCfg "https://github.com/nethbotheju/movie-prediction/blob/main/frontend/vite.config.ts"

    %% Styles
    classDef data fill:#D0EBFF,stroke:#74C0FC
    classDef ml fill:#D3F9D8,stroke:#69DB7C
    classDef api fill:#FFE3B8,stroke:#FFA94D
    classDef frontend fill:#E5DBFF,stroke:#B197FC
    classDef external fill:#F1F3F5,stroke:#ADB5BD,stroke-dasharray: 5 5,nodeShape:cloud
```
