# zaeem-chaudry/twitter-sentiment-analysis-using-pyspark-in-big-data architecture

> Architecture diagram of the GitHub repository zaeem-chaudry/twitter-sentiment-analysis-using-pyspark-in-big-data, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/zaeem-chaudry/twitter-sentiment-analysis-using-pyspark-in-big-data
- Repository: https://github.com/zaeem-chaudry/twitter-sentiment-analysis-using-pyspark-in-big-data

## Overview

This repository is a PySpark Twitter sentiment-analysis application. Its primary workflow starts with a user-supplied CSV, cleans and weakly labels tweets, then reports sentiment counts and optionally saves labeled data or trains and evaluates a classifier. The README also documents an EMR/S3 analysis run, represented separately from the sampled CLI implementation. The source excerpts establish the CLI call flow and classifier internals; notebook internals were not sampled, so that documented capability is shown without inferred internal links.

Main entry points: [`src/run_pipeline.py`](https://github.com/zaeem-chaudry/twitter-sentiment-analysis-using-pyspark-in-big-data/blob/main/src/run_pipeline.py) (Pipeline CLI), [`src/pipeline.py`](https://github.com/zaeem-chaudry/twitter-sentiment-analysis-using-pyspark-in-big-data/blob/main/src/pipeline.py) (Distributed cleaning), [`src/train_classifier.py`](https://github.com/zaeem-chaudry/twitter-sentiment-analysis-using-pyspark-in-big-data/blob/main/src/train_classifier.py) (Classifier training), [`src/text_cleaning.py`](https://github.com/zaeem-chaudry/twitter-sentiment-analysis-using-pyspark-in-big-data/blob/main/src/text_cleaning.py) (Text rules)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingestion["Input and orchestration"]
  node_cli["Pipeline CLI<br/>[run_pipeline.py]"]
end

subgraph group_preparation["Cleaning and labeling"]
  node_clean["Distributed cleaning<br/>[pipeline.py]"]
  node_rules["Text rules<br/>[text_cleaning.py]"]
  node_label["Sentiment labeling<br/>[pipeline.py]"]
end

subgraph group_analysis["Analysis outputs"]
  node_counts["Sentiment counts<br/>[run_pipeline.py]"]
  node_output["Labeled CSV output<br/>[run_pipeline.py]"]
  node_exploration["Exploratory analysis"]
end

subgraph group_classification["Model training"]
  node_trainer["Classifier training"]
  node_metrics["Evaluation metrics"]
end

node_user(("Analyst"))
node_csv["Tweet CSV"]
node_textblob["TextBlob"]
node_s3[("Amazon S3")]

node_user -->|"runs"| node_cli
node_csv -->|"reads"| node_cli
node_cli -->|"calls"| node_clean
node_clean -->|"uses"| node_rules
node_cli -->|"calls"| node_label
node_label -->|"scores with"| node_textblob
node_cli -->|"groups by"| node_counts
node_cli -->|"writes"| node_output
node_cli -->|"optionally trains"| node_trainer
node_trainer -->|"evaluates"| node_metrics
node_s3 -->|"provides data"| node_exploration

click node_cli "https://github.com/zaeem-chaudry/twitter-sentiment-analysis-using-pyspark-in-big-data/blob/main/src/run_pipeline.py"
click node_clean "https://github.com/zaeem-chaudry/twitter-sentiment-analysis-using-pyspark-in-big-data/blob/main/src/pipeline.py"
click node_rules "https://github.com/zaeem-chaudry/twitter-sentiment-analysis-using-pyspark-in-big-data/blob/main/src/text_cleaning.py"
click node_label "https://github.com/zaeem-chaudry/twitter-sentiment-analysis-using-pyspark-in-big-data/blob/main/src/pipeline.py"
click node_counts "https://github.com/zaeem-chaudry/twitter-sentiment-analysis-using-pyspark-in-big-data/blob/main/src/run_pipeline.py"
click node_output "https://github.com/zaeem-chaudry/twitter-sentiment-analysis-using-pyspark-in-big-data/blob/main/src/run_pipeline.py"
click node_exploration "https://github.com/zaeem-chaudry/twitter-sentiment-analysis-using-pyspark-in-big-data/blob/main/notebooks/twitter_sentiment_analysis_emr.ipynb"
click node_trainer "https://github.com/zaeem-chaudry/twitter-sentiment-analysis-using-pyspark-in-big-data/blob/main/src/train_classifier.py"
click node_metrics "https://github.com/zaeem-chaudry/twitter-sentiment-analysis-using-pyspark-in-big-data/blob/main/src/train_classifier.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli toneBlue
class node_clean,node_rules,node_label,node_s3 toneAmber
class node_counts,node_output,node_exploration toneMint
class node_trainer,node_metrics toneRose
class node_user,node_csv,node_textblob toneIndigo
```

## Components

### Input and orchestration

- [Pipeline CLI](https://github.com/zaeem-chaudry/twitter-sentiment-analysis-using-pyspark-in-big-data/blob/main/src/run_pipeline.py): `src/run_pipeline.py`

### Cleaning and labeling

- [Distributed cleaning](https://github.com/zaeem-chaudry/twitter-sentiment-analysis-using-pyspark-in-big-data/blob/main/src/pipeline.py): `src/pipeline.py`
- [Text rules](https://github.com/zaeem-chaudry/twitter-sentiment-analysis-using-pyspark-in-big-data/blob/main/src/text_cleaning.py): `src/text_cleaning.py`
- [Sentiment labeling](https://github.com/zaeem-chaudry/twitter-sentiment-analysis-using-pyspark-in-big-data/blob/main/src/pipeline.py): `src/pipeline.py`

### Analysis outputs

- [Sentiment counts](https://github.com/zaeem-chaudry/twitter-sentiment-analysis-using-pyspark-in-big-data/blob/main/src/run_pipeline.py): `src/run_pipeline.py`
- [Labeled CSV output](https://github.com/zaeem-chaudry/twitter-sentiment-analysis-using-pyspark-in-big-data/blob/main/src/run_pipeline.py): `src/run_pipeline.py`
- [Exploratory analysis](https://github.com/zaeem-chaudry/twitter-sentiment-analysis-using-pyspark-in-big-data/blob/main/notebooks/twitter_sentiment_analysis_emr.ipynb): `notebooks/twitter_sentiment_analysis_emr.ipynb`

### Model training

- [Classifier training](https://github.com/zaeem-chaudry/twitter-sentiment-analysis-using-pyspark-in-big-data/blob/main/src/train_classifier.py): `src/train_classifier.py`
- [Evaluation metrics](https://github.com/zaeem-chaudry/twitter-sentiment-analysis-using-pyspark-in-big-data/blob/main/src/train_classifier.py): `src/train_classifier.py`

### Other components

- **Analyst**
- **Tweet CSV**
- **TextBlob**
- **Amazon S3**

## Connections

- Analyst → Pipeline CLI: runs (evidence: `src/run_pipeline.py`)
- Tweet CSV → Pipeline CLI: reads (evidence: `src/run_pipeline.py`)
- Pipeline CLI → Distributed cleaning: calls (evidence: `src/run_pipeline.py`)
- Distributed cleaning → Text rules: uses (evidence: `src/pipeline.py`)
- Pipeline CLI → Sentiment labeling: calls (evidence: `src/run_pipeline.py`)
- Sentiment labeling → TextBlob: scores with (evidence: `src/pipeline.py`)
- Pipeline CLI → Sentiment counts: groups by (evidence: `src/run_pipeline.py`)
- Pipeline CLI → Labeled CSV output: writes (evidence: `src/run_pipeline.py`)
- Pipeline CLI → Classifier training: optionally trains (evidence: `src/run_pipeline.py`)
- Classifier training → Evaluation metrics: evaluates (evidence: `src/train_classifier.py`)
- Amazon S3 → Exploratory analysis: provides data (evidence: `README.md`)
