# vsancnaj/hybrid-recommendation-system architecture

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

- Interactive diagram: https://gitdiagram.com/vsancnaj/hybrid-recommendation-system
- Repository: https://github.com/vsancnaj/hybrid-recommendation-system

## Overview

##### Main Components
- Data Layer:
- Raw Data Repository (“data/” directory containing CSV files like product_info.csv and various reviews datasets).
- Processed Data/Metadata (“metadata/” directory, e.g., products.csv and hybrid_similarity.pkl).
- Model and Processing:
- Jupyter Notebook (model.ipynb) used for training and evaluating the recommendation models and generating precomputed similarity metrics.
- The hybrid recommendation engine that integrates both item-based collaborative filtering and content-based filtering.
- Service Layer:
- Flask API (api.py): Exposes recommendation endpoints (e.g. http://127.0.0.1:5000/recommend) that process user requests and return tailored recommendations.
- Streamlit Web App (app.py): Provides a user-friendly interface enabling users to select products and view recommendations.
- Environment/Infrastructure:
- Virtual Environment (skincare/ directory) and dependency management via requirements.txt.

##### Relationships and Interactions
- Data Flow:
- The raw data in the “data/” directory is processed (likely in model.ipynb) to produce a clean dataset and a similarity matrix stored in the “metadata/” directory.
- The recommendation model takes these processed inputs to compute hybrid recommendations.
- Cross-Component Communication:
- The Flask API, using the processed model outputs (from “metadata/”), provides endpoints that return recommendations upon HTTP requests.
- The Streamlit application acts as a client to the API, allowing users to interact with the system.

##### Architectural Patterns and Design Principles
- Separation of Concerns: Different components are clearly divided by functionality (data ingestion/processing, model training, API service, front-end interface).
- Modularity: By having separate modules (Flask for API and Streamlit for UI), the system supports independent improvement, troubleshooting, or scaling.
- Hybrid Recommendation Logic: Emphasizes the integration of collaborative filtering and content-based methods, which could be annotated as part of the model component.

##### Relevant Technologies & Frameworks
- Python-based development (indicated by .py files and Jupyter Notebook).
- Flask for building RESTful API services.
- Streamlit for a rapid web-based interface.
- Data processing libraries (likely pandas, possibly scikit-learn or NLP libraries for handling text features) as mentioned in the README.

##### Detailing the Essential Architectural Elements
- Individual modules and their interactions. For instance:
- That the Flask API is the middleware that bridges the data/model outputs with user interactions, and that the Streamlit web app is built on top of this API.
- Two-pronged approach of recommendations (item-based vs. content-based) by adding side notes or sub-components under the “Recommendation Model”.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Data Layer"
        RawData["Raw Data (data/ CSV files)"]
        ProcessedData["Processed Data/Metadata (metadata/ directory)"]
    end

    subgraph "Model & Processing"
        RecModel["Recommendation Model (Hybrid: Collaborative+Content-Based)"]
    end

    subgraph "Service Layer"
        FlaskAPI["Flask API (api.py)"]
        StreamlitUI["Streamlit Web Interface (app.py)"]
    end

    subgraph "Environment & Infrastructure"
        VirtualEnv["Virtual Environment (skincare/)"]
        Dependencies["Dependencies (requirements.txt)"]
    end

    RawData -->|"preprocessed"| ProcessedData
    ProcessedData -->|"generate_similarity_metrics"| RecModel
    RecModel -->|"serve_recommendations"| FlaskAPI
    FlaskAPI -->|"API_calls"| StreamlitUI

    VirtualEnv ---|"supports"| FlaskAPI
    VirtualEnv ---|"supports"| StreamlitUI
    Dependencies ---|"dependencies"| RecModel
    Dependencies ---|"dependencies"| FlaskAPI
    Dependencies ---|"dependencies"| StreamlitUI

    click RecModel "https://github.com/vsancnaj/hybrid-recommendation-system/blob/main/model.ipynb"
    click FlaskAPI "https://github.com/vsancnaj/hybrid-recommendation-system/blob/main/api.py"
    click StreamlitUI "https://github.com/vsancnaj/hybrid-recommendation-system/blob/main/app.py"
    click Dependencies "https://github.com/vsancnaj/hybrid-recommendation-system/blob/main/requirements.txt"

    class RawData,ProcessedData dataLayer
    class RecModel processingLayer
    class FlaskAPI,StreamlitUI serviceLayer
    class VirtualEnv,Dependencies envLayer

    classDef dataLayer fill:#ffd580,stroke:#ff9900,stroke-width:2px;
    classDef processingLayer fill:#ccf2ff,stroke:#3399ff,stroke-width:2px;
    classDef serviceLayer fill:#d4f7d4,stroke:#33cc33,stroke-width:2px;
    classDef envLayer fill:#fcd5d8,stroke:#ff3366,stroke-width:2px;
```
