# pf1cha/film-recommendation architecture

> Architecture diagram of the GitHub repository pf1cha/film-recommendation, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/pf1cha/film-recommendation
- Repository: https://github.com/pf1cha/film-recommendation

## Overview

##### Main Components

A. User Interface Layer
- PyQt/Tkinter-based UI components (evident from ui/windows/)
- Login, Registration, and Search windows
- Use rectangles with rounded corners for UI components

B. Data Processing Layer
- Data Clearing Module (data_clearing/)
- Data Preparation Module (model/data_preparation.py)
- Utils Module for helper functions

C. Model Layer
- Movie Recommendation Model (model/model_build.py)
- Movie Embeddings Storage (model/movie2movie_embeddings.npy)
- Model Functions (model/functions.py)

D. Data Layer
- Database Module (database/)
- Raw Data Storage (data/*.csv files)
- Database Operations (database/database.py)

##### Component Relationships

- User → UI Layer (User interaction)
- UI Layer → Database Layer (User authentication, movie queries)
- UI Layer → Model Layer (Recommendation requests)
- Data Layer → Model Layer (Training data flow)
- Data Clearing → Data Layer (Data preprocessing flow)

##### Specific Implementation Details

A. Data Flow:
1. Raw data (CSV files) → Data Clearing → Database
2. Database → Model Training → Embeddings
3. User Interface → Database (queries)
4. User Interface → Model (recommendation requests)

B. Key Components:
- Movie embeddings storage
- Recommendation model
- Database connections
- User authentication flow

##### Additional Elements

Supporting components:
- Configuration management
- Testing framework integration
- Data pipeline flow
- Authentication flow

##### Technical Details

- Database schema references
- Model architecture summary
- Data preprocessing steps
- API endpoints between layers

Remember to:
- Version information
- Notes about scalability points
- Critical paths in the recommendation flow
- Security boundaries

## Diagram (Mermaid)

```mermaid
%%{init: {'theme': 'base', 'themeVariables': { 'fontSize': '16px'}}}%%

flowchart TB
    classDef ui fill:#b3d9ff,stroke:#333,stroke-width:2px
    classDef data fill:#d9b3ff,stroke:#333,stroke-width:2px
    classDef model fill:#ffdb99,stroke:#333,stroke-width:2px
    classDef processing fill:#99ff99,stroke:#333,stroke-width:2px
    classDef database fill:#ff9999,stroke:#333,stroke-width:2px
    classDef testing fill:#e6e6e6,stroke:#333,stroke-width:2px
    classDef external fill:#c2c2c2,stroke:#333,stroke-width:2px

    User(("User"))

    subgraph UI["User Interface Layer"]
        Login["Login Window"]:::ui
        Register["Registration Window"]:::ui
        Search["Search Window"]:::ui
        MainUI["Main UI Interface"]:::ui
    end

    subgraph Processing["Data Processing Layer"]
        DataClearing["Data Clearing"]:::processing
        DataPrep["Data Preparation"]:::processing
        Utils["Utilities"]:::processing
    end

    subgraph ML["Model Layer"]
        RecModel["Movie Recommendation Model"]:::model
        Embeddings["Movie Embeddings"]:::model
        ModelFuncs["Model Functions"]:::model
    end

    subgraph Data["Data Layer"]
        DB["Database Operations"]:::database
        DBConfig["Database Config"]:::database
        RawData["Raw Data Storage"]:::database
        DBCreation["Database Creation"]:::database
        DatasetDB["Dataset DB Integration"]:::database
    end

    subgraph Testing["Testing Framework"]
        UITest["UI Testing"]:::testing
        RegTest["Registration Testing"]:::testing
    end

    User --> Login
    User --> Register
    User --> Search
    User --> MainUI

    Login --> DB
    Register --> DB
    Search --> RecModel
    MainUI --> RecModel

    RawData --> DataClearing
    DataClearing --> DB
    DB --> DataPrep
    DataPrep --> RecModel
    RecModel --> Embeddings
    ModelFuncs --> RecModel

    Utils --> DataClearing
    Utils --> DataPrep

    UITest --> MainUI
    RegTest --> Register

    click Login "https://github.com/pf1cha/film-recommendation/blob/main/ui/windows/login.py"
    click Register "https://github.com/pf1cha/film-recommendation/blob/main/ui/windows/registration.py"
    click Search "https://github.com/pf1cha/film-recommendation/blob/main/ui/windows/search.py"
    click MainUI "https://github.com/pf1cha/film-recommendation/blob/main/ui/windows/user_interface.py"
    click DataClearing "https://github.com/pf1cha/film-recommendation/blob/main/data_clearing/data_clear.py"
    click DataPrep "https://github.com/pf1cha/film-recommendation/blob/main/model/data_preparation.py"
    click Utils "https://github.com/pf1cha/film-recommendation/blob/main/utils/utils.py"
    click RecModel "https://github.com/pf1cha/film-recommendation/blob/main/model/model_build.py"
    click Embeddings "https://github.com/pf1cha/film-recommendation/blob/main/model/movie2movie_embeddings.npy"
    click ModelFuncs "https://github.com/pf1cha/film-recommendation/blob/main/model/functions.py"
    click DB "https://github.com/pf1cha/film-recommendation/blob/main/database/database.py"
    click DBConfig "https://github.com/pf1cha/film-recommendation/blob/main/database/database_info.py"
    click RawData "https://github.com/pf1cha/film-recommendation/blob/main/data/films_merged.csv"
    click DBCreation "https://github.com/pf1cha/film-recommendation/blob/main/database/local_database_creation.py"
    click DatasetDB "https://github.com/pf1cha/film-recommendation/blob/main/database/dataset_to_db.py"
    click UITest "https://github.com/pf1cha/film-recommendation/blob/main/tests/test_main_window.py"
    click RegTest "https://github.com/pf1cha/film-recommendation/blob/main/tests/test_registration.py"

    %% Legend
    subgraph Legend
        UI_L["UI Component"]:::ui
        Data_L["Data Component"]:::data
        Model_L["Model Component"]:::model
        Process_L["Processing Component"]:::processing
        DB_L["Database Component"]:::database
        Test_L["Testing Component"]:::testing
    end
```
