# anujtiwari1427/sentiment-analysis-project architecture

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

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

## Overview

This repository analyzes survey responses about local brands, trains a sentiment classifier, and presents survey and prediction insights in a Streamlit dashboard. The main user flow is comment entry → hybrid sentiment inference → dashboard results. Offline, survey text is normalized and weakly labeled before TF-IDF training and model evaluation; a separate EDA branch produces survey dictionaries and visualizations. The dashboard and training stages are excerpted, but some artifact-loading and visualization wiring is documented only in the README, so those links cite it.

Main entry points: [`src/predict.py`](https://github.com/anujtiwari1427/sentiment-analysis-project/blob/main/src/predict.py) (Hybrid inference), [`app.py`](https://github.com/anujtiwari1427/sentiment-analysis-project/blob/main/app.py) (Streamlit dashboard), [`src/analyze_data.py`](https://github.com/anujtiwari1427/sentiment-analysis-project/blob/main/src/analyze_data.py) (Survey EDA), [`src/train_model.py`](https://github.com/anujtiwari1427/sentiment-analysis-project/blob/main/src/train_model.py) (Training pipeline)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_analysis["Survey analysis"]
  node_survey["Survey responses"]
  node_eda["Survey EDA<br/>[analyze_data.py]"]
  node_visuals["Survey visualizations"]
end

subgraph group_nlp["Sentiment modeling"]
  node_prep["Text preparation<br/>[sentiment_utils.py]"]
  node_training["Training pipeline<br/>[train_model.py]"]
  node_features["TF-IDF features<br/>[train_model.py]"]
  node_classifier["Sentiment classifier<br/>[train_model.py]"]
end

subgraph group_serving["Prediction and dashboard"]
  node_inference["Hybrid inference<br/>[predict.py]"]
  node_dashboard["Streamlit dashboard<br/>[app.py]"]
end

subgraph group_artifacts["Persisted outputs"]
  node_model_files["Model artifacts"]
  node_training_outputs["Training results"]
end

node_user(("Dashboard user"))

node_survey -->|"reads survey"| node_eda
node_survey -->|"loads responses"| node_training
node_eda -->|"uses normalization"| node_prep
node_training -->|"uses preprocessing"| node_prep
node_training -->|"extracts features"| node_features
node_features -->|"fits classifier"| node_classifier
node_classifier -->|"serializes model"| node_model_files
node_classifier -->|"exports metrics"| node_training_outputs
node_eda -->|"generates charts"| node_visuals
node_user -->|"enters comment"| node_dashboard
node_dashboard -->|"requests prediction"| node_inference
node_inference -->|"normalizes text"| node_prep
node_inference -->|"loads model assets"| node_model_files
node_inference -->|"returns prediction"| node_dashboard
node_visuals -->|"displays survey visuals"| node_dashboard

click node_survey "https://github.com/anujtiwari1427/sentiment-analysis-project/blob/main/data/survey_responses.xlsx"
click node_eda "https://github.com/anujtiwari1427/sentiment-analysis-project/blob/main/src/analyze_data.py"
click node_visuals "https://github.com/anujtiwari1427/sentiment-analysis-project/tree/main/outputs"
click node_prep "https://github.com/anujtiwari1427/sentiment-analysis-project/blob/main/src/sentiment_utils.py"
click node_training "https://github.com/anujtiwari1427/sentiment-analysis-project/blob/main/src/train_model.py"
click node_features "https://github.com/anujtiwari1427/sentiment-analysis-project/blob/main/src/train_model.py"
click node_classifier "https://github.com/anujtiwari1427/sentiment-analysis-project/blob/main/src/train_model.py"
click node_inference "https://github.com/anujtiwari1427/sentiment-analysis-project/blob/main/src/predict.py"
click node_dashboard "https://github.com/anujtiwari1427/sentiment-analysis-project/blob/main/app.py"
click node_model_files "https://github.com/anujtiwari1427/sentiment-analysis-project/tree/main/models"
click node_training_outputs "https://github.com/anujtiwari1427/sentiment-analysis-project/tree/main/outputs"

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_survey,node_eda,node_visuals,node_user toneBlue
class node_prep,node_training,node_features,node_classifier toneAmber
class node_inference,node_dashboard toneMint
class node_model_files,node_training_outputs toneRose
```

## Components

### Survey analysis

- [Survey responses](https://github.com/anujtiwari1427/sentiment-analysis-project/blob/main/data/survey_responses.xlsx): `data/survey_responses.xlsx`
- [Survey EDA](https://github.com/anujtiwari1427/sentiment-analysis-project/blob/main/src/analyze_data.py): `src/analyze_data.py`
- [Survey visualizations](https://github.com/anujtiwari1427/sentiment-analysis-project/tree/main/outputs): `outputs`

### Sentiment modeling

- [Text preparation](https://github.com/anujtiwari1427/sentiment-analysis-project/blob/main/src/sentiment_utils.py): `src/sentiment_utils.py`
- [Training pipeline](https://github.com/anujtiwari1427/sentiment-analysis-project/blob/main/src/train_model.py): `src/train_model.py`
- [TF-IDF features](https://github.com/anujtiwari1427/sentiment-analysis-project/blob/main/src/train_model.py): `src/train_model.py`
- [Sentiment classifier](https://github.com/anujtiwari1427/sentiment-analysis-project/blob/main/src/train_model.py): `src/train_model.py`

### Prediction and dashboard

- [Hybrid inference](https://github.com/anujtiwari1427/sentiment-analysis-project/blob/main/src/predict.py): `src/predict.py`
- [Streamlit dashboard](https://github.com/anujtiwari1427/sentiment-analysis-project/blob/main/app.py): `app.py`

### Persisted outputs

- [Model artifacts](https://github.com/anujtiwari1427/sentiment-analysis-project/tree/main/models): `models`
- [Training results](https://github.com/anujtiwari1427/sentiment-analysis-project/tree/main/outputs): `outputs`

### Other components

- **Dashboard user**

## Connections

- Survey responses → Survey EDA: reads survey (evidence: `src/analyze_data.py`)
- Survey responses → Training pipeline: loads responses (evidence: `src/train_model.py`)
- Survey EDA → Text preparation: uses normalization (evidence: `src/analyze_data.py`)
- Training pipeline → Text preparation: uses preprocessing (evidence: `src/train_model.py`)
- Training pipeline → TF-IDF features: extracts features (evidence: `README.md`)
- TF-IDF features → Sentiment classifier: fits classifier (evidence: `README.md`)
- Sentiment classifier → Model artifacts: serializes model (evidence: `src/train_model.py`)
- Sentiment classifier → Training results: exports metrics (evidence: `src/train_model.py`)
- Survey EDA → Survey visualizations: generates charts (evidence: `README.md`)
- Dashboard user → Streamlit dashboard: enters comment (evidence: `README.md`)
- Streamlit dashboard → Hybrid inference: requests prediction (evidence: `app.py`)
- Hybrid inference → Text preparation: normalizes text (evidence: `src/predict.py`)
- Hybrid inference → Model artifacts: loads model assets (evidence: `README.md`)
- Hybrid inference → Streamlit dashboard: returns prediction (evidence: `README.md`)
- Survey visualizations → Streamlit dashboard: displays survey visuals (evidence: `README.md`)
