# abhisheknishad23/sentiment-analysis architecture

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

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

## Overview

This Flask dashboard accepts either a CSV of reviews or one review, cleans the text, applies the saved TF-IDF vectorizer and sentiment model, then renders predictions. Batch analysis also reports sentiment counts and percentages and produces a pie chart; individual analysis returns a single Positive/Negative result. The README documents these capabilities, while the sampled backend shows the route-level calls and model loading. The template and stylesheet are represented from the tree and README; their internal wiring was not sampled.

Main entry points: [`main.py`](https://github.com/abhisheknishad23/sentiment-analysis/blob/main/main.py) (CSV analysis route), [`templates/index.html`](https://github.com/abhisheknishad23/sentiment-analysis/blob/main/templates/index.html) (Dashboard UI), [`tfidf_vectorizer.pkl`](https://github.com/abhisheknishad23/sentiment-analysis/blob/main/tfidf_vectorizer.pkl) (TF-IDF vectorizer), [`sentiment_model.pkl`](https://github.com/abhisheknishad23/sentiment-analysis/blob/main/sentiment_model.pkl) (Sentiment model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_flask["Flask app<br/>[main.py]"]
  node_dashboard["Dashboard UI<br/>[index.html]"]
  node_styles["Dashboard styling<br/>[style.css]"]
end

subgraph group_workflow["Analysis workflows"]
  node_batch["CSV analysis route<br/>[main.py]"]
  node_single["Single review route<br/>[main.py]"]
  node_csv["Uploaded CSV"]
end

subgraph group_ml["Sentiment engine"]
  node_clean["Text cleaning<br/>[main.py]"]
  node_vectorizer["TF-IDF vectorizer"]
  node_model["Sentiment model"]
end

subgraph group_analytics["Batch analytics"]
  node_metrics["Sentiment metrics<br/>[main.py]"]
  node_chart["Pie chart<br/>[main.py]"]
end

node_visitor(("Dashboard user"))

node_visitor -->|"uses"| node_dashboard
node_visitor -->|"uploads CSV"| node_batch
node_visitor -->|"submits review"| node_single
node_flask -->|"renders"| node_dashboard
node_dashboard -.->|"styled by"| node_styles
node_flask -->|"routes request"| node_batch
node_flask -->|"routes request"| node_single
node_csv -->|"supplies rows"| node_batch
node_batch -->|"cleans reviews"| node_clean
node_batch -->|"vectorizes text"| node_vectorizer
node_batch -->|"predicts labels"| node_model
node_batch -->|"counts labels"| node_metrics
node_batch -->|"generates chart"| node_chart
node_batch -->|"renders results"| node_dashboard
node_single -->|"cleans review"| node_clean
node_single -->|"vectorizes text"| node_vectorizer
node_single -->|"predicts label"| node_model
node_single -->|"renders result"| node_dashboard
node_flask -->|"loads model"| node_model
node_flask -->|"loads vectorizer"| node_vectorizer

click node_flask "https://github.com/abhisheknishad23/sentiment-analysis/blob/main/main.py"
click node_dashboard "https://github.com/abhisheknishad23/sentiment-analysis/blob/main/templates/index.html"
click node_styles "https://github.com/abhisheknishad23/sentiment-analysis/blob/main/static/style.css"
click node_batch "https://github.com/abhisheknishad23/sentiment-analysis/blob/main/main.py"
click node_single "https://github.com/abhisheknishad23/sentiment-analysis/blob/main/main.py"
click node_clean "https://github.com/abhisheknishad23/sentiment-analysis/blob/main/main.py"
click node_vectorizer "https://github.com/abhisheknishad23/sentiment-analysis/blob/main/tfidf_vectorizer.pkl"
click node_model "https://github.com/abhisheknishad23/sentiment-analysis/blob/main/sentiment_model.pkl"
click node_metrics "https://github.com/abhisheknishad23/sentiment-analysis/blob/main/main.py"
click node_chart "https://github.com/abhisheknishad23/sentiment-analysis/blob/main/main.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_flask,node_dashboard,node_styles,node_visitor toneBlue
class node_batch,node_single,node_csv toneAmber
class node_clean,node_vectorizer,node_model toneMint
class node_metrics,node_chart toneRose
```

## Components

### Web interface

- [Flask app](https://github.com/abhisheknishad23/sentiment-analysis/blob/main/main.py): `main.py`
- [Dashboard UI](https://github.com/abhisheknishad23/sentiment-analysis/blob/main/templates/index.html): `templates/index.html`
- [Dashboard styling](https://github.com/abhisheknishad23/sentiment-analysis/blob/main/static/style.css): `static/style.css`

### Analysis workflows

- [CSV analysis route](https://github.com/abhisheknishad23/sentiment-analysis/blob/main/main.py): `main.py`
- [Single review route](https://github.com/abhisheknishad23/sentiment-analysis/blob/main/main.py): `main.py`
- **Uploaded CSV**

### Sentiment engine

- [Text cleaning](https://github.com/abhisheknishad23/sentiment-analysis/blob/main/main.py): `main.py`
- [TF-IDF vectorizer](https://github.com/abhisheknishad23/sentiment-analysis/blob/main/tfidf_vectorizer.pkl): `tfidf_vectorizer.pkl`
- [Sentiment model](https://github.com/abhisheknishad23/sentiment-analysis/blob/main/sentiment_model.pkl): `sentiment_model.pkl`

### Batch analytics

- [Sentiment metrics](https://github.com/abhisheknishad23/sentiment-analysis/blob/main/main.py): `main.py`
- [Pie chart](https://github.com/abhisheknishad23/sentiment-analysis/blob/main/main.py): `main.py`

### Other components

- **Dashboard user**

## Connections

- Dashboard user → Dashboard UI: uses (evidence: `README.md`)
- Dashboard user → CSV analysis route: uploads CSV (evidence: `README.md`)
- Dashboard user → Single review route: submits review (evidence: `README.md`)
- Flask app → Dashboard UI: renders (evidence: `main.py`)
- Dashboard UI → Dashboard styling: styled by
- Flask app → CSV analysis route: routes request (evidence: `main.py`)
- Flask app → Single review route: routes request (evidence: `main.py`)
- Uploaded CSV → CSV analysis route: supplies rows (evidence: `main.py`)
- CSV analysis route → Text cleaning: cleans reviews (evidence: `main.py`)
- CSV analysis route → TF-IDF vectorizer: vectorizes text (evidence: `main.py`)
- CSV analysis route → Sentiment model: predicts labels (evidence: `main.py`)
- CSV analysis route → Sentiment metrics: counts labels (evidence: `main.py`)
- CSV analysis route → Pie chart: generates chart (evidence: `main.py`)
- CSV analysis route → Dashboard UI: renders results (evidence: `main.py`)
- Single review route → Text cleaning: cleans review (evidence: `main.py`)
- Single review route → TF-IDF vectorizer: vectorizes text (evidence: `main.py`)
- Single review route → Sentiment model: predicts label (evidence: `main.py`)
- Single review route → Dashboard UI: renders result (evidence: `main.py`)
- Flask app → Sentiment model: loads model (evidence: `main.py`)
- Flask app → TF-IDF vectorizer: loads vectorizer (evidence: `main.py`)
