# susovand/hotel-reviews-sentiment-analysis architecture

> Architecture diagram of the GitHub repository susovand/hotel-reviews-sentiment-analysis, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/susovand/hotel-reviews-sentiment-analysis
- Repository: https://github.com/susovand/hotel-reviews-sentiment-analysis

## Overview

##### Project Type and Purpose
- The project is focused on analyzing hotel reviews from Trip Advisor to derive sentiment insights. It is a data science / machine learning project that involves data ingestion, preprocessing, sentiment extraction using NLP libraries (VADER, TextBlob), and model training with PyCaret.
- Although the provided file tree is a bit minimal (with an EDA folder and data folder), the README description gives a fuller picture, including additional directories like raw, processed, notebooks, models, and src. This indicates a well-organized analysis pipeline.

##### Analyzing the File Structure
- Top-level files include .gitignore, EDA notebooks, data files (data.csv and final_model_data.csv), and requirements.txt.
- The README further details that the repository is structured with directories for raw data, processed data, notebooks (for detailed analysis), models (for saving the trained model), and source code (for data processing and training). There are separate scripts for data preprocessing (data_preprocessing.py) and model training (model_training.py).
- These clues suggest an architecture that partitions the workflow into clear stages: data ingestion, processing, exploratory analysis, sentiment derivation, and model training.

##### Components
a. Data Sources:
- Raw Data: Represent the raw dataset (e.g., files in the "raw" subdirectory, or the CSV files in the data folder).
- Processed Data: Indicate the processed version (files in "processed" or final_model_data.csv) which is used as the basis for analysis and model training.

b. Data Preprocessing:

c. Exploratory Data Analysis (EDA):

d. Sentiment Analysis Modules:

e. Model Training & Prediction:
- A component for model training (model_training.py). This part features the use of PyCaret to automatically train, evaluate, and select the best predictive model based on the enriched data.
- A note here for storage: models created are saved in the "models" directory after training.

f. Dependencies and Environment:
- A component referencing the requirements.txt, which indicates essential packages (pandas, numpy, pycaret, matplotlib, etc.) being used. This can also encompass the environmental aspects related to how the system ensures reproducibility.

##### Relationships and Data Flow
- That processed data feeds into both EDA and the sentiment analysis module.
- That feature extraction (from textual processing with VADER/TextBlob) along with ratings is combined to produce the final features used for model training.

##### Essential Architectural Patterns
- A modular, pipeline-based approach is used here where each step (from data ingestion, preprocessing, to modeling) is isolated, which improves maintainability and clarity.
- The separation between notebooks (exploratory/visualization) and scripts (automated data processing, training) should be clearly marked.
- The integration of domain-specific libraries (VADER, TextBlob, PyCaret) indicates that the design is built around leveraging pre-existing tools for NLP and machine learning.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Ingestion
    subgraph "Data Ingestion"
        RAW["Raw Data (data.csv)"]:::data
        PreProc["Data Preprocessing & Feature Engineering"]:::processing
        PROCD["Processed Data (final_model_data.csv)"]:::data
        RAW -->|"ingested"| PreProc
        PreProc -->|"generates"| PROCD
    end

    %% Dependencies and Environment
    DEPS["Dependencies (requirements.txt)"]:::dependency

    %% Sentiment Analysis Module
    SENT["Sentiment Extraction (VADER & TextBlob)"]:::processing

    %% EDA - Aggregated Results Node
    EDARes["EDA Results"]:::analysis

    %% Model Training Module
    MODEL["Model Training & Evaluation (PyCaret)"]:::training

    %% Main Data Flow
    PROCD -->|"feeds"| SENT
    PROCD -->|"feeds"| EDARes
    SENT -->|"informs"| MODEL
    EDARes -->|"informs"| MODEL

    %% Dependencies influence on Preprocessing and Model Training
    DEPS -->|"supports"| PreProc
    DEPS -->|"supports"| MODEL

    %% Exploratory Data Analysis Notebooks Subgraph
    subgraph "Exploratory Data Analysis (Notebooks)"
        EDA1["EDA Notebook"]:::eda
        EDA2["PyCaret Deployment Notebook"]:::eda
        EDA3["Log File"]:::eda
    end

    %% Link aggregated EDA results with individual notebook components (dashed lines)
    EDARes ---|"details"| EDA1
    EDARes ---|"details"| EDA2
    EDARes ---|"details"| EDA3

    %% Click Events
    click RAW "https://github.com/susovand/hotel-reviews-sentiment-analysis/blob/main/data/data.csv"
    click PROCD "https://github.com/susovand/hotel-reviews-sentiment-analysis/blob/main/data/final_model_data.csv"
    click EDA1 "https://github.com/susovand/hotel-reviews-sentiment-analysis/blob/main/EDA/eda.ipynb"
    click EDA2 "https://github.com/susovand/hotel-reviews-sentiment-analysis/blob/main/EDA/pycaret_automl_deployment.ipynb"
    click EDA3 "https://github.com/susovand/hotel-reviews-sentiment-analysis/blob/main/EDA/logs.log"
    click DEPS "https://github.com/susovand/hotel-reviews-sentiment-analysis/blob/main/requirements.txt"

    %% Styles
    classDef data fill:#FFF3CD,stroke:#856404,stroke-width:2px;
    classDef processing fill:#D1ECF1,stroke:#0C5460,stroke-width:2px;
    classDef analysis fill:#C3E6CB,stroke:#155724,stroke-width:2px;
    classDef training fill:#F5C6CB,stroke:#721C24,stroke-width:2px;
    classDef dependency fill:#E2E3E5,stroke:#6C757D,stroke-width:2px;
    classDef eda fill:#D4EDDA,stroke:#155724,stroke-width:2px;
```
