# jonathandika/llm-recommender-system architecture

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

- Interactive diagram: https://gitdiagram.com/jonathandika/llm-recommender-system
- Repository: https://github.com/jonathandika/llm-recommender-system

## Overview

##### Main Components
- User Interface Layer: Represent two entry points – one via app.py (for the content-based, parallel variant) and another via app_RL.py (for the RL variant). Label these as “Streamlit UI – Content-Based” and “Streamlit UI – RL-based.”
- Data Handling & Storage: Show the “data” component that holds preprocessed datasets (e.g., .parquet files). Indicate that the system retrieves raw and cleaned user ratings and book data from this component.
- RAG and LLM Integration: Include modules like RAG.py and RAG_llm_as_recsys.py that integrate the Retrieval Augmented Generation approach.
- Parallel Processing: Illustrate both “modules/parallel” and “modules/original” components to capture different approaches in data preprocessing and recommendation generation – emphasize the parallelized operations that boost efficiency.
- Reinforcement Learning: Detail the “modules/reinforcement_learning” folder (containing RAG_RL.py and recommendation_system_RL.py) plus the “modules/helper/DQNAgent.py” to indicate the DDQN algorithm and feedback-loop mechanism.
- Helper/Utility Modules: Include “modules/helper” components such as indexing vector embeddings, Pinecone integrations, and a predictor for ratings. These are the underlying libraries and utilities that support the data retrieval, embedding generation, and similarity computations.

##### Relationships and Interactions
- Within the Core Processing Modules, indicate communication between the RAG components, parallel processing routines, and reinforcement learning feedback loops.

##### Architectural Patterns and Key Technologies
- That the project leverages parallel computing to optimize processing speeds – illustrate separation/branching between sequential (“original”) and parallelized (“parallel”) workflows.
- Use of a RAG model for integrating external LLM capabilities with recommendation logic.
- For the RL variant, clearly mark how the DDQN algorithm (found in modules/helper/DQNAgent.py) adapts to user interactions.
- Annotations should mention that the project uses streamlit for deploying its user interface.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI Layer
    UI_CB["Streamlit UI – Content-Based"]:::frontend
    UI_RL["Streamlit UI – RL-based"]:::frontend

    %% Data Handling
    DATA["Data Handling & Storage"]:::data

    %% Modules Subgraph
    subgraph "Modules"
        %% RAG and LLM Integration
        subgraph "RAG & LLM"
            RAG["RAG.py"]:::processing
            RAGLLM["RAG_llm_as_recsys.py"]:::processing
        end

        %% Parallel Processing Branches
        subgraph "Parallel Processing"
            PARALLEL["Parallel Processing Modules"]:::processing
        end
        subgraph "Original Processing"
            ORIGINAL["Original Processing Modules"]:::processing
        end

        %% Reinforcement Learning Branch
        subgraph "Reinforcement Learning"
            RL_CORE["RL Recsys"]:::RL
            RL_AGENT["DQNAgent.py"]:::RL
        end
    end

    %% Helper/Utility Module (outside Modules for clarity)
    HELPER["Helper/Utility Modules"]:::helper

    %% UI to Modules Connections
    UI_CB -->|"triggers"| RAG
    UI_CB -->|"triggers"| PARALLEL
    UI_CB -->|"triggers"| ORIGINAL
    UI_RL -->|"triggers"| RL_CORE

    %% Data Flow to Modules
    DATA -->|"provides data"| RAG
    DATA -->|"provides data"| PARALLEL
    DATA -->|"provides data"| ORIGINAL
    DATA -->|"provides data"| RL_CORE

    %% Internal Module Interactions
    RAG -->|"uses"| HELPER
    RAGLLM -->|"uses"| HELPER
    PARALLEL -->|"uses"| HELPER
    ORIGINAL -->|"uses"| HELPER
    RL_AGENT -->|"uses"| HELPER

    %% Reinforcement Learning Feedback Loop
    RL_CORE -->|"feedback"| RL_AGENT
    RL_AGENT -->|"updates"| RL_CORE

    %% Click Events
    click UI_CB "https://github.com/jonathandika/llm-recommender-system/blob/master/app.py"
    click UI_RL "https://github.com/jonathandika/llm-recommender-system/blob/master/app_RL.py"
    click DATA "https://github.com/jonathandika/llm-recommender-system/tree/master/data/"
    click RAG "https://github.com/jonathandika/llm-recommender-system/blob/master/modules/RAG.py"
    click RAGLLM "https://github.com/jonathandika/llm-recommender-system/blob/master/modules/RAG_llm_as_recsys.py"
    click PARALLEL "https://github.com/jonathandika/llm-recommender-system/tree/master/modules/parallel/"
    click ORIGINAL "https://github.com/jonathandika/llm-recommender-system/tree/master/modules/original/"
    click RL_CORE "https://github.com/jonathandika/llm-recommender-system/tree/master/modules/reinforcement_learning/"
    click RL_AGENT "https://github.com/jonathandika/llm-recommender-system/blob/master/modules/helper/DQNAgent.py"
    click HELPER "https://github.com/jonathandika/llm-recommender-system/tree/master/modules/helper/"

    %% Styles
    classDef frontend fill:#ffcccc,stroke:#333,stroke-width:2px;
    classDef data fill:#ccffcc,stroke:#333,stroke-width:2px;
    classDef processing fill:#cce5ff,stroke:#333,stroke-width:2px;
    classDef RL fill:#e6ffe6,stroke:#333,stroke-width:2px;
    classDef helper fill:#fff2cc,stroke:#333,stroke-width:2px;
```
