# tuhintech1278/ai-sentiment-classifier architecture

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

- Interactive diagram: https://gitdiagram.com/tuhintech1278/ai-sentiment-classifier
- Repository: https://github.com/tuhintech1278/ai-sentiment-classifier

## Overview

The product is a local Flask sentiment-classification web app. A user submits text through the page; the Flask handler preprocesses it, applies the fitted TF-IDF representation and logistic-regression model, then renders the predicted class. The repository also includes a separate script for training, evaluating, and trying the classifier on sample sentences. The web and script implementations are shown separately because their wiring is distinct. The README documents the three sentiment classes and web workflow; sampled source confirms the implementation details.

Main entry points: [`app.py`](https://github.com/tuhintech1278/ai-sentiment-classifier/blob/main/app.py) (Flask application), [`templates/index.html`](https://github.com/tuhintech1278/ai-sentiment-classifier/blob/main/templates/index.html) (Input and result page), [`sentiment_classifier.py`](https://github.com/tuhintech1278/ai-sentiment-classifier/blob/main/sentiment_classifier.py) (Training and evaluation), [`sentiment_dataset.csv`](https://github.com/tuhintech1278/ai-sentiment-classifier/blob/main/sentiment_dataset.csv) (Sentiment dataset)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_web_app["Flask application<br/>[app.py]"]
  node_page["Input and result page<br/>[index.html]"]
end

subgraph group_classifier["Classification pipeline"]
  node_dataset["Sentiment dataset"]
  node_web_training["Load and train model<br/>[app.py]"]
  node_web_preprocess["Text preprocessing<br/>[app.py]"]
  node_web_vectorizer["TF-IDF vectorizer<br/>[app.py]"]
  node_web_model["Logistic regression<br/>[app.py]"]
end

subgraph group_analysis["Model analysis"]
  node_offline_script["Training and evaluation"]
end

node_user(("User"))

node_user -->|"enters text"| node_page
node_page -->|"submits form"| node_web_app
node_web_app -->|"renders result"| node_page
node_web_app -->|"cleans input"| node_web_preprocess
node_web_app -->|"transforms input"| node_web_vectorizer
node_web_app -->|"predicts class"| node_web_model
node_web_app -->|"initializes"| node_web_training
node_web_training -->|"reads rows"| node_dataset
node_web_training -->|"cleans training text"| node_web_preprocess
node_web_training -->|"fits features"| node_web_vectorizer
node_web_training -->|"fits model"| node_web_model
node_offline_script -->|"reads rows"| node_dataset
node_offline_script -.->|"uses same steps"| node_web_preprocess

click node_web_app "https://github.com/tuhintech1278/ai-sentiment-classifier/blob/main/app.py"
click node_page "https://github.com/tuhintech1278/ai-sentiment-classifier/blob/main/templates/index.html"
click node_dataset "https://github.com/tuhintech1278/ai-sentiment-classifier/blob/main/sentiment_dataset.csv"
click node_web_training "https://github.com/tuhintech1278/ai-sentiment-classifier/blob/main/app.py"
click node_web_preprocess "https://github.com/tuhintech1278/ai-sentiment-classifier/blob/main/app.py"
click node_web_vectorizer "https://github.com/tuhintech1278/ai-sentiment-classifier/blob/main/app.py"
click node_web_model "https://github.com/tuhintech1278/ai-sentiment-classifier/blob/main/app.py"
click node_offline_script "https://github.com/tuhintech1278/ai-sentiment-classifier/blob/main/sentiment_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_web_app,node_page,node_user toneBlue
class node_dataset,node_web_training,node_web_preprocess,node_web_vectorizer,node_web_model toneAmber
class node_offline_script toneMint
```

## Components

### Web interface

- [Flask application](https://github.com/tuhintech1278/ai-sentiment-classifier/blob/main/app.py): `app.py`
- [Input and result page](https://github.com/tuhintech1278/ai-sentiment-classifier/blob/main/templates/index.html): `templates/index.html`

### Classification pipeline

- [Sentiment dataset](https://github.com/tuhintech1278/ai-sentiment-classifier/blob/main/sentiment_dataset.csv): `sentiment_dataset.csv`
- [Load and train model](https://github.com/tuhintech1278/ai-sentiment-classifier/blob/main/app.py): `app.py`
- [Text preprocessing](https://github.com/tuhintech1278/ai-sentiment-classifier/blob/main/app.py): `app.py`
- [TF-IDF vectorizer](https://github.com/tuhintech1278/ai-sentiment-classifier/blob/main/app.py): `app.py`
- [Logistic regression](https://github.com/tuhintech1278/ai-sentiment-classifier/blob/main/app.py): `app.py`

### Model analysis

- [Training and evaluation](https://github.com/tuhintech1278/ai-sentiment-classifier/blob/main/sentiment_classifier.py): `sentiment_classifier.py`

### Other components

- **User**

## Connections

- User → Input and result page: enters text
- Input and result page → Flask application: submits form
- Flask application → Input and result page: renders result
- Flask application → Text preprocessing: cleans input
- Flask application → TF-IDF vectorizer: transforms input
- Flask application → Logistic regression: predicts class
- Flask application → Load and train model: initializes
- Load and train model → Sentiment dataset: reads rows
- Load and train model → Text preprocessing: cleans training text
- Load and train model → TF-IDF vectorizer: fits features
- Load and train model → Logistic regression: fits model
- Training and evaluation → Sentiment dataset: reads rows
- Training and evaluation → Text preprocessing: uses same steps
