# gokulakrishnan-1/sentiment-analysis-project-on-amazon-reviews architecture

> Architecture diagram of the GitHub repository gokulakrishnan-1/sentiment-analysis-project-on-amazon-reviews, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gokulakrishnan-1/sentiment-analysis-project-on-amazon-reviews
- Repository: https://github.com/gokulakrishnan-1/sentiment-analysis-project-on-amazon-reviews

## Overview

##### Project type and purpose
- This is a data-analysis mini-project written in R. Its purpose is to perform sentiment analysis on Amazon reviews for the book “The Psychology of Money” and display the emotional distribution in a bar plot.

##### File structure
- Top-level:
- Amazon Review Sentiment Analysis.R — the single R script containing the entire analysis pipeline
- README.md — project overview and instructions
- No separate directories for data, modules, or outputs—everything is in one script.

##### README for additional insights
- Data ingestion via read.csv
- Text converted and analyzed using the Syuzhet package and NRC lexicon
- Output is a bar plot of emotional categories (positive, negative, anger, joy, etc.)

a. Main components:
1. Data Source
– Input CSV file of Amazon reviews
2. Data Ingestion Module
– R’s read.csv
3. Text Preprocessing Module
– Lower-casing, punctuation removal, tokenization
4. Sentiment Analysis Module
– Syuzhet functions + NRC Word-Emotion Lexicon
5. Aggregation & Scoring Module
– Compute counts/scores per emotion category
6. Visualization Module
– ggplot2 or base R bar plot
7. Output
– Final bar plot PNG or display
8. Environment & Dependencies
– R interpreter, Syuzhet library, NRC lexicon data

b. Relationships and data flow
- From Ingestion → Preprocessing → Sentiment Analysis → Aggregation → Visualization → Output

c. Architectural patterns & principles
– Linear data-pipeline pattern: stepwise transformation
– Modularity: each step is a logical component, even if implemented in one script
– Dependency injection: external lexicon and package

d. Key technologies/frameworks
– R language
– Syuzhet package
– NRC Word-Emotion Association Lexicon
– ggplot2 or base graphics (depending on implementation)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Data Pipeline
    DataSource["Amazon Reviews CSV"]:::dataStore
    Ingestion["Data Ingestion Module<br/>(read.csv)"]:::processing
    Preprocessing["Text Preprocessing Module<br/>(lowercase, remove punctuation, tokenization)"]:::processing
    Sentiment["Sentiment Analysis Module<br/>(Syuzhet v1.0.4, NRC Lexicon)"]:::processing
    Aggregation["Aggregation & Scoring Module<br/>(counts per emotion)"]:::processing
    Visualization["Visualization Module<br/>(ggplot2/base R)"]:::visualization
    Output["Bar Plot Output (PNG)"]:::output

    %% Dependencies
    subgraph "Dependencies"
        direction TB
        Renv["R Interpreter"]:::dependency
        SyuzhetDep["Syuzhet Package"]:::dependency
        NRCDep["NRC Lexicon Data"]:::dependency
        GGplot2["ggplot2 Package"]:::dependency
    end

    %% README
    README["Project Overview & Instructions<br/>(README.md)"]:::dataStore

    %% Data Flow
    DataSource -->|"raw reviews"| Ingestion
    Ingestion -->|"raw text"| Preprocessing
    Preprocessing -->|"clean tokens"| Sentiment
    Sentiment -->|"sentiment scores"| Aggregation
    Aggregation -->|"score dataset"| Visualization
    Visualization -->|"bar plot"| Output

    %% Dependency Links
    Renv -.-> Ingestion
    Renv -.-> Preprocessing
    Renv -.-> Sentiment
    Renv -.-> Aggregation
    Renv -.-> Visualization
    SyuzhetDep -.-> Sentiment
    NRCDep -.-> Sentiment
    GGplot2 -.-> Visualization
    README -.-> Renv

    %% Click Events
    click Ingestion "https://github.com/gokulakrishnan-1/sentiment-analysis-project-on-amazon-reviews/blob/main/Amazon Review Sentiment Analysis.R"
    click Preprocessing "https://github.com/gokulakrishnan-1/sentiment-analysis-project-on-amazon-reviews/blob/main/Amazon Review Sentiment Analysis.R"
    click Sentiment "https://github.com/gokulakrishnan-1/sentiment-analysis-project-on-amazon-reviews/blob/main/Amazon Review Sentiment Analysis.R"
    click Aggregation "https://github.com/gokulakrishnan-1/sentiment-analysis-project-on-amazon-reviews/blob/main/Amazon Review Sentiment Analysis.R"
    click Visualization "https://github.com/gokulakrishnan-1/sentiment-analysis-project-on-amazon-reviews/blob/main/Amazon Review Sentiment Analysis.R"
    click SyuzhetDep "https://github.com/gokulakrishnan-1/sentiment-analysis-project-on-amazon-reviews/blob/main/Amazon Review Sentiment Analysis.R"
    click NRCDep "https://github.com/gokulakrishnan-1/sentiment-analysis-project-on-amazon-reviews/blob/main/Amazon Review Sentiment Analysis.R"
    click GGplot2 "https://github.com/gokulakrishnan-1/sentiment-analysis-project-on-amazon-reviews/blob/main/Amazon Review Sentiment Analysis.R"
    click README "https://github.com/gokulakrishnan-1/sentiment-analysis-project-on-amazon-reviews/blob/main/README.md"

    %% Styles
    classDef dataStore fill:#AED6F1,stroke:#1F618D,color:#1F618D;
    classDef processing fill:#A9DFBF,stroke:#196F3D,color:#196F3D;
    classDef visualization fill:#F9E79F,stroke:#B7950B,color:#B7950B;
    classDef output fill:#F5B7B1,stroke:#C0392B,color:#C0392B;
    classDef dependency fill:#D7DBDD,stroke:#7B7D7D,color:#7B7D7D;
```
