# sthirani/sentiment-analysis architecture

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

- Interactive diagram: https://gitdiagram.com/sthirani/sentiment-analysis
- Repository: https://github.com/sthirani/sentiment-analysis

## Overview

##### Main Components
a. Twitter Data Collection:
- Twitter API as an external service that the system interacts with.
- A component (labeled “Twitter.py”) that handles authentication and fetching tweets using the Twitter API.
b. Data Cleaning and Preprocessing:
- “CleanData.py” module which preprocesses raw tweet data by removing special characters, stopwords, and punctuation.
- Optionally, indicate “DisableSSL.py” as a utility used to manage SSL issues during resource downloads (such as NLTK modules).
c. Sentiment Analysis:
- “SentimentData.py” module where the sentiment analysis takes place using NLTK’s VADER.
- Use of NLP techniques and possible tokenization and cleaning performed before analysis.
d. Data Persistence & Storage:
- CSV files (e.g., “clean_sentences_nike.csv”) where the cleaned data and perhaps analysis results are stored.
e. Visualization:
- Generation of word clouds with the WordCloud module as a separate step after analysis.
f. Dependencies & Libraries:

##### Relationships and Interactions
- Process flow from Twitter.py –> CleanData.py –> SentimentData.py as well as a separate branch towards visualization (WordCloud generation).
- That the data flows into CSV storage (clean_sentences_nike.csv) after cleaning, either as an intermediate step or output of the pipeline.

##### Architectural Patterns & Design Principles
- Pipeline nature of the design (data ingestion – preprocessing – analysis – visualization).
- Separation of concerns: one module handles data collection (Twitter.py), another is responsible for cleaning (CleanData.py), and a third manages analysis (SentimentData.py).
- That this is essentially a single-service, script-based pipeline rather than a distributed or microservices architecture.

##### Details
- Major functional modules and any utility scripts, even if they appear as support (e.g., DisableSSL.py), to fully document the architecture.

## Diagram (Mermaid)

```mermaid
flowchart TD
    TAPI["Twitter API"]:::external

    subgraph "Data Collection & Preprocessing Pipeline"
        TwitterModule["Twitter.py module"]:::module
        CleanData["CleanData.py module"]:::module
        DisableSSL["DisableSSL.py Utility"]:::utility
        SentimentModule["SentimentData.py module"]:::module
    end

    subgraph "Output Components"
        CSVnode["CSV Storage [clean_sentences_nike.csv]"]:::storage
        WordCloud["WordCloud Visualization"]:::visualization
    end

    %% External to Data Collection
    TAPI -->|"Authentication&FetchTweets"| TwitterModule

    %% Pipeline Flow
    TwitterModule -->|"RawTweetData"| CleanData
    CleanData -->|"CleanedTextData"| SentimentModule
    DisableSSL -->|"InitializeNLTK"| SentimentModule
    SentimentModule -->|"AnalysisResults"| CSVnode
    SentimentModule -->|"AnalysisResults"| WordCloud

    %% Click Events
    click TwitterModule "https://github.com/sthirani/sentiment-analysis/blob/main/Twitter.py"
    click CleanData "https://github.com/sthirani/sentiment-analysis/blob/main/CleanData.py"
    click DisableSSL "https://github.com/sthirani/sentiment-analysis/blob/main/DisableSSL.py"
    click SentimentModule "https://github.com/sthirani/sentiment-analysis/blob/main/SentimentData.py"
    click CSVnode "https://github.com/sthirani/sentiment-analysis/blob/main/clean_sentences_nike.csv"

    %% Styles
    classDef external fill:#AED6F1,stroke:#2471A3,stroke-width:2px;
    classDef module fill:#ABEBC6,stroke:#239B56,stroke-width:2px;
    classDef utility fill:#F5CBA7,stroke:#D35400,stroke-width:2px;
    classDef storage fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef visualization fill:#FAD7A0,stroke:#E67E22,stroke-width:2px;
```
