# harrish8248/sentiment-analysis-nlp architecture

> Architecture diagram of the GitHub repository harrish8248/sentiment-analysis-nlp, 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/harrish8248/sentiment-analysis-nlp
- Repository: https://github.com/harrish8248/sentiment-analysis-nlp

## Overview

This repository classifies movie reviews as positive or negative through two execution paths: an interactive Streamlit app and a CLI training script. Both train a pipeline over the NLTK movie-review corpus using text cleaning, TF-IDF features, and Logistic Regression. The app accepts typed or templated reviews and presents predictions and metrics; the CLI also evaluates the model and generates diagnostic plots. Source excerpts show the CLI pipeline in detail, while the app excerpt omits parts of its training and prediction logic; documented behavior supplements those relationships.

Main entry points: [`sentiment-analysis-nlp/sentiment_analysis.py`](https://github.com/harrish8248/sentiment-analysis-nlp/blob/main/sentiment-analysis-nlp/sentiment_analysis.py) (CLI training pipeline), [`sentiment-analysis-nlp/app.py`](https://github.com/harrish8248/sentiment-analysis-nlp/blob/main/sentiment-analysis-nlp/app.py) (Cached app training), [`sentiment-analysis-nlp/outputs`](https://github.com/harrish8248/sentiment-analysis-nlp/tree/main/sentiment-analysis-nlp/outputs) (Diagnostic plots)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_streamlit_app["Review app<br/>[app.py]"]
  node_review_input["Review input<br/>[app.py]"]
  node_prediction_view["Prediction view<br/>[app.py]"]
  node_diagnostic_dashboard["Chart dashboard<br/>[app.py]"]
end

subgraph group_model["Sentiment modeling"]
  node_nltk_corpus[("NLTK reviews")]
  node_app_training["Cached app training<br/>[app.py]"]
  node_text_cleaning["Text cleaning"]
  node_tfidf_features["TF-IDF features"]
  node_logistic_model["Logistic classifier"]
end

subgraph group_cli["CLI diagnostics"]
  node_chart_outputs["Diagnostic plots"]
  node_cli_pipeline["CLI training pipeline"]
  node_evaluation["Model evaluation"]
  node_visualizations["Plot generation"]
  node_sample_demo["Sample predictions"]
end

node_reviewer(("Reviewer"))

node_reviewer -->|"uses"| node_streamlit_app
node_streamlit_app -->|"loads model"| node_app_training
node_reviewer -->|"enters review"| node_review_input
node_review_input -->|"requests analysis"| node_prediction_view
node_app_training -->|"loads reviews"| node_nltk_corpus
node_app_training -->|"cleans text"| node_text_cleaning
node_app_training -->|"fits features"| node_tfidf_features
node_app_training -->|"trains model"| node_logistic_model
node_prediction_view -->|"also displays"| node_diagnostic_dashboard
node_diagnostic_dashboard -->|"reads plots"| node_chart_outputs
node_cli_pipeline -->|"loads reviews"| node_nltk_corpus
node_cli_pipeline -->|"cleans corpus"| node_text_cleaning
node_cli_pipeline -->|"fits features"| node_tfidf_features
node_cli_pipeline -->|"trains model"| node_logistic_model
node_cli_pipeline -->|"evaluates model"| node_evaluation
node_cli_pipeline -->|"generates plots"| node_visualizations
node_visualizations -->|"writes plots"| node_chart_outputs
node_cli_pipeline -->|"runs examples"| node_sample_demo

click node_streamlit_app "https://github.com/harrish8248/sentiment-analysis-nlp/blob/main/sentiment-analysis-nlp/app.py"
click node_review_input "https://github.com/harrish8248/sentiment-analysis-nlp/blob/main/sentiment-analysis-nlp/app.py"
click node_prediction_view "https://github.com/harrish8248/sentiment-analysis-nlp/blob/main/sentiment-analysis-nlp/app.py"
click node_diagnostic_dashboard "https://github.com/harrish8248/sentiment-analysis-nlp/blob/main/sentiment-analysis-nlp/app.py"
click node_chart_outputs "https://github.com/harrish8248/sentiment-analysis-nlp/tree/main/sentiment-analysis-nlp/outputs"
click node_app_training "https://github.com/harrish8248/sentiment-analysis-nlp/blob/main/sentiment-analysis-nlp/app.py"
click node_cli_pipeline "https://github.com/harrish8248/sentiment-analysis-nlp/blob/main/sentiment-analysis-nlp/sentiment_analysis.py"
click node_text_cleaning "https://github.com/harrish8248/sentiment-analysis-nlp/blob/main/sentiment-analysis-nlp/sentiment_analysis.py"
click node_tfidf_features "https://github.com/harrish8248/sentiment-analysis-nlp/blob/main/sentiment-analysis-nlp/sentiment_analysis.py"
click node_logistic_model "https://github.com/harrish8248/sentiment-analysis-nlp/blob/main/sentiment-analysis-nlp/sentiment_analysis.py"
click node_evaluation "https://github.com/harrish8248/sentiment-analysis-nlp/blob/main/sentiment-analysis-nlp/sentiment_analysis.py"
click node_visualizations "https://github.com/harrish8248/sentiment-analysis-nlp/blob/main/sentiment-analysis-nlp/sentiment_analysis.py"
click node_sample_demo "https://github.com/harrish8248/sentiment-analysis-nlp/blob/main/sentiment-analysis-nlp/sentiment_analysis.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_streamlit_app,node_review_input,node_prediction_view,node_diagnostic_dashboard,node_reviewer toneBlue
class node_nltk_corpus,node_app_training,node_text_cleaning,node_tfidf_features,node_logistic_model toneAmber
class node_chart_outputs,node_cli_pipeline,node_evaluation,node_visualizations,node_sample_demo toneMint
```

## Components

### Web experience

- [Review app](https://github.com/harrish8248/sentiment-analysis-nlp/blob/main/sentiment-analysis-nlp/app.py): `sentiment-analysis-nlp/app.py`
- [Review input](https://github.com/harrish8248/sentiment-analysis-nlp/blob/main/sentiment-analysis-nlp/app.py): `sentiment-analysis-nlp/app.py`
- [Prediction view](https://github.com/harrish8248/sentiment-analysis-nlp/blob/main/sentiment-analysis-nlp/app.py): `sentiment-analysis-nlp/app.py`
- [Chart dashboard](https://github.com/harrish8248/sentiment-analysis-nlp/blob/main/sentiment-analysis-nlp/app.py): `sentiment-analysis-nlp/app.py`

### Sentiment modeling

- **NLTK reviews**
- [Cached app training](https://github.com/harrish8248/sentiment-analysis-nlp/blob/main/sentiment-analysis-nlp/app.py): `sentiment-analysis-nlp/app.py`
- [Text cleaning](https://github.com/harrish8248/sentiment-analysis-nlp/blob/main/sentiment-analysis-nlp/sentiment_analysis.py): `sentiment-analysis-nlp/sentiment_analysis.py`
- [TF-IDF features](https://github.com/harrish8248/sentiment-analysis-nlp/blob/main/sentiment-analysis-nlp/sentiment_analysis.py): `sentiment-analysis-nlp/sentiment_analysis.py`
- [Logistic classifier](https://github.com/harrish8248/sentiment-analysis-nlp/blob/main/sentiment-analysis-nlp/sentiment_analysis.py): `sentiment-analysis-nlp/sentiment_analysis.py`

### CLI diagnostics

- [Diagnostic plots](https://github.com/harrish8248/sentiment-analysis-nlp/tree/main/sentiment-analysis-nlp/outputs): `sentiment-analysis-nlp/outputs`
- [CLI training pipeline](https://github.com/harrish8248/sentiment-analysis-nlp/blob/main/sentiment-analysis-nlp/sentiment_analysis.py): `sentiment-analysis-nlp/sentiment_analysis.py`
- [Model evaluation](https://github.com/harrish8248/sentiment-analysis-nlp/blob/main/sentiment-analysis-nlp/sentiment_analysis.py): `sentiment-analysis-nlp/sentiment_analysis.py`
- [Plot generation](https://github.com/harrish8248/sentiment-analysis-nlp/blob/main/sentiment-analysis-nlp/sentiment_analysis.py): `sentiment-analysis-nlp/sentiment_analysis.py`
- [Sample predictions](https://github.com/harrish8248/sentiment-analysis-nlp/blob/main/sentiment-analysis-nlp/sentiment_analysis.py): `sentiment-analysis-nlp/sentiment_analysis.py`

### Other components

- **Reviewer**

## Connections

- Reviewer → Review app: uses
- Review app → Cached app training: loads model (evidence: `sentiment-analysis-nlp/app.py`)
- Reviewer → Review input: enters review
- Review input → Prediction view: requests analysis (evidence: `sentiment-analysis-nlp/app.py`)
- Cached app training → NLTK reviews: loads reviews
- Cached app training → Text cleaning: cleans text (evidence: `sentiment-analysis-nlp/app.py`)
- Cached app training → TF-IDF features: fits features (evidence: `sentiment-analysis-nlp/app.py`)
- Cached app training → Logistic classifier: trains model (evidence: `sentiment-analysis-nlp/app.py`)
- Prediction view → Chart dashboard: also displays (evidence: `sentiment-analysis-nlp/app.py`)
- Chart dashboard → Diagnostic plots: reads plots (evidence: `sentiment-analysis-nlp/app.py`)
- CLI training pipeline → NLTK reviews: loads reviews (evidence: `sentiment-analysis-nlp/sentiment_analysis.py`)
- CLI training pipeline → Text cleaning: cleans corpus (evidence: `sentiment-analysis-nlp/sentiment_analysis.py`)
- CLI training pipeline → TF-IDF features: fits features (evidence: `sentiment-analysis-nlp/sentiment_analysis.py`)
- CLI training pipeline → Logistic classifier: trains model (evidence: `sentiment-analysis-nlp/sentiment_analysis.py`)
- CLI training pipeline → Model evaluation: evaluates model (evidence: `sentiment-analysis-nlp/sentiment_analysis.py`)
- CLI training pipeline → Plot generation: generates plots (evidence: `sentiment-analysis-nlp/sentiment_analysis.py`)
- Plot generation → Diagnostic plots: writes plots (evidence: `sentiment-analysis-nlp/sentiment_analysis.py`)
- CLI training pipeline → Sample predictions: runs examples (evidence: `sentiment-analysis-nlp/sentiment_analysis.py`)
