# padmajaghute339-svg/twitter-sentiment architecture

> Architecture diagram of the GitHub repository padmajaghute339-svg/twitter-sentiment, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/padmajaghute339-svg/twitter-sentiment
- Repository: https://github.com/padmajaghute339-svg/twitter-sentiment

## Overview

This is a Twitter sentiment-analysis application: training data or demo text is cleaned, models are trained and compared, and the selected model is saved for prediction. In the web workflow, a user submits text, Flask cleans and classifies it, and the browser displays the result. Training also produces evaluation metrics for the dashboard. The source excerpts show training and web/API wiring; template and standalone-dashboard internals were not sampled, so their detailed connections are omitted.

Main entry points: [`twitter_sentiment_project/train.py`](https://github.com/padmajaghute339-svg/twitter-sentiment/blob/main/twitter_sentiment_project/train.py) (Training workflow), [`twitter_sentiment_project/app.py`](https://github.com/padmajaghute339-svg/twitter-sentiment/blob/main/twitter_sentiment_project/app.py) (Flask API), [`twitter_sentiment_project/static/js/app.js`](https://github.com/padmajaghute339-svg/twitter-sentiment/blob/main/twitter_sentiment_project/static/js/app.js) (Dashboard and controls), [`twitter_sentiment_project/templates/index.html`](https://github.com/padmajaghute339-svg/twitter-sentiment/blob/main/twitter_sentiment_project/templates/index.html) (Web interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_training["Training and evaluation"]
  node_trainer["Training workflow<br/>[train.py]"]
  node_cleaner["Text cleaning<br/>[preprocess.py]"]
  node_exploration["Data exploration<br/>[train.py]"]
  node_model_eval["Model comparison<br/>[train.py]"]
end

subgraph group_inference["Prediction runtime"]
  node_flask_app["Flask API<br/>[app.py]"]
end

subgraph group_web["Web experience"]
  node_web_ui["Web interface<br/>[index.html]"]
  node_browser_logic["Dashboard and controls<br/>[app.js]"]
  node_standalone_dashboard["Standalone dashboard<br/>[dashboard.html]"]
end

subgraph group_artifacts["Saved outputs"]
  node_saved_model["Best model<br/>[best_model.joblib]"]
  node_saved_results["Evaluation results<br/>[results.json]"]
end

node_cli_user(("CLI user"))
node_tweet_data["Tweet CSV"]
node_web_user(("Browser user"))

node_cli_user -->|"runs training"| node_trainer
node_tweet_data -->|"loads tweets"| node_trainer
node_trainer -->|"cleans text"| node_cleaner
node_trainer -->|"explores data"| node_exploration
node_trainer -->|"trains and evaluates"| node_model_eval
node_trainer -->|"saves model"| node_saved_model
node_trainer -->|"writes metrics"| node_saved_results
node_web_user -->|"opens page"| node_web_ui
node_web_ui -.->|"loads script"| node_browser_logic
node_browser_logic -->|"requests predictions"| node_flask_app
node_flask_app -->|"cleans input"| node_cleaner
node_flask_app -->|"loads and predicts"| node_saved_model
node_browser_logic -->|"fetches results"| node_flask_app
node_flask_app -->|"reads metrics"| node_saved_results

click node_trainer "https://github.com/padmajaghute339-svg/twitter-sentiment/blob/main/twitter_sentiment_project/train.py"
click node_cleaner "https://github.com/padmajaghute339-svg/twitter-sentiment/blob/main/twitter_sentiment_project/preprocess.py"
click node_exploration "https://github.com/padmajaghute339-svg/twitter-sentiment/blob/main/twitter_sentiment_project/train.py"
click node_model_eval "https://github.com/padmajaghute339-svg/twitter-sentiment/blob/main/twitter_sentiment_project/train.py"
click node_saved_model "https://github.com/padmajaghute339-svg/twitter-sentiment/blob/main/twitter_sentiment_project/models/best_model.joblib"
click node_saved_results "https://github.com/padmajaghute339-svg/twitter-sentiment/blob/main/twitter_sentiment_project/outputs/results.json"
click node_web_ui "https://github.com/padmajaghute339-svg/twitter-sentiment/blob/main/twitter_sentiment_project/templates/index.html"
click node_browser_logic "https://github.com/padmajaghute339-svg/twitter-sentiment/blob/main/twitter_sentiment_project/static/js/app.js"
click node_flask_app "https://github.com/padmajaghute339-svg/twitter-sentiment/blob/main/twitter_sentiment_project/app.py"
click node_standalone_dashboard "https://github.com/padmajaghute339-svg/twitter-sentiment/blob/main/twitter_sentiment_project/standalone/dashboard.html"

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_trainer,node_cleaner,node_exploration,node_model_eval,node_cli_user,node_web_user toneBlue
class node_flask_app toneAmber
class node_web_ui,node_browser_logic,node_standalone_dashboard toneMint
class node_saved_model,node_saved_results toneRose
class node_tweet_data toneIndigo
```

## Components

### Training and evaluation

- [Training workflow](https://github.com/padmajaghute339-svg/twitter-sentiment/blob/main/twitter_sentiment_project/train.py): `twitter_sentiment_project/train.py`
- [Text cleaning](https://github.com/padmajaghute339-svg/twitter-sentiment/blob/main/twitter_sentiment_project/preprocess.py): `twitter_sentiment_project/preprocess.py`
- [Data exploration](https://github.com/padmajaghute339-svg/twitter-sentiment/blob/main/twitter_sentiment_project/train.py): `twitter_sentiment_project/train.py`
- [Model comparison](https://github.com/padmajaghute339-svg/twitter-sentiment/blob/main/twitter_sentiment_project/train.py): `twitter_sentiment_project/train.py`

### Prediction runtime

- [Flask API](https://github.com/padmajaghute339-svg/twitter-sentiment/blob/main/twitter_sentiment_project/app.py): `twitter_sentiment_project/app.py`

### Web experience

- [Web interface](https://github.com/padmajaghute339-svg/twitter-sentiment/blob/main/twitter_sentiment_project/templates/index.html): `twitter_sentiment_project/templates/index.html`
- [Dashboard and controls](https://github.com/padmajaghute339-svg/twitter-sentiment/blob/main/twitter_sentiment_project/static/js/app.js): `twitter_sentiment_project/static/js/app.js`
- [Standalone dashboard](https://github.com/padmajaghute339-svg/twitter-sentiment/blob/main/twitter_sentiment_project/standalone/dashboard.html): `twitter_sentiment_project/standalone/dashboard.html`

### Saved outputs

- [Best model](https://github.com/padmajaghute339-svg/twitter-sentiment/blob/main/twitter_sentiment_project/models/best_model.joblib): `twitter_sentiment_project/models/best_model.joblib`
- [Evaluation results](https://github.com/padmajaghute339-svg/twitter-sentiment/blob/main/twitter_sentiment_project/outputs/results.json): `twitter_sentiment_project/outputs/results.json`

### Other components

- **CLI user**
- **Tweet CSV**
- **Browser user**

## Connections

- CLI user → Training workflow: runs training (evidence: `twitter_sentiment_project/train.py`)
- Tweet CSV → Training workflow: loads tweets (evidence: `twitter_sentiment_project/train.py`)
- Training workflow → Text cleaning: cleans text (evidence: `twitter_sentiment_project/train.py`)
- Training workflow → Data exploration: explores data (evidence: `twitter_sentiment_project/train.py`)
- Training workflow → Model comparison: trains and evaluates (evidence: `twitter_sentiment_project/train.py`)
- Training workflow → Best model: saves model (evidence: `twitter_sentiment_project/train.py`)
- Training workflow → Evaluation results: writes metrics (evidence: `twitter_sentiment_project/train.py`)
- Browser user → Web interface: opens page
- Web interface → Dashboard and controls: loads script
- Dashboard and controls → Flask API: requests predictions (evidence: `twitter_sentiment_project/static/js/app.js`)
- Flask API → Text cleaning: cleans input (evidence: `twitter_sentiment_project/app.py`)
- Flask API → Best model: loads and predicts (evidence: `twitter_sentiment_project/app.py`)
- Dashboard and controls → Flask API: fetches results (evidence: `twitter_sentiment_project/static/js/app.js`)
- Flask API → Evaluation results: reads metrics (evidence: `twitter_sentiment_project/app.py`)
