# khalidllogic/sentiment-analysis-app architecture

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

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

## Overview

This is a Streamlit movie-review sentiment application with single-review inference, CSV batch prediction, and saved-prediction history, alongside a documented model-training and exploration notebook. The main runtime flow loads serialized model artifacts, cleans review text, predicts sentiment, and optionally logs results to SQLite. Training stages and exploratory capabilities are documented in the README; notebook internals were not sampled, so those links reflect documentation rather than inspected calls.

Main entry points: [`app.py`](https://github.com/khalidllogic/sentiment-analysis-app/blob/main/app.py) (Batch Analysis), [`train_model.ipynb`](https://github.com/khalidllogic/sentiment-analysis-app/blob/main/train_model.ipynb) (Training Lab), [`database_manager.py`](https://github.com/khalidllogic/sentiment-analysis-app/blob/main/database_manager.py) (Database Manager), [`sentiment_model.pkl`](https://github.com/khalidllogic/sentiment-analysis-app/blob/main/sentiment_model.pkl) (Classifier Artifact)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Application Runtime"]
  node_app["Streamlit App<br/>[app.py]"]
  node_single["Single Review<br/>[app.py]"]
  node_preprocessor["Text Preprocessor<br/>[app.py]"]
  node_predictor["Sentiment Predictor<br/>[app.py]"]
  node_classifier["Classifier Artifact"]
  node_vectorizer["Vectorizer Artifact<br/>[vectorizer.pkl]"]
  node_batch["Batch Analysis<br/>[app.py]"]
end

subgraph group_training["Model Training"]
  node_training["Training Lab<br/>[train_model.ipynb]"]
  node_nlp["NLP Pipeline<br/>[train_model.ipynb]"]
  node_features["TF-IDF Features<br/>[train_model.ipynb]"]
  node_tuning["Classifier Tuning<br/>[train_model.ipynb]"]
  node_evaluation["Model Evaluation<br/>[train_model.ipynb]"]
  node_eda["Exploratory Analysis<br/>[train_model.ipynb]"]
end

subgraph group_persistence["Prediction History"]
  node_history["History Analytics<br/>[app.py]"]
  node_manager["Database Manager"]
  node_sqlite[("SQLite History")]
end

node_reviewer(("Reviewer"))
node_csv["CSV Upload / Results"]
node_dataset["IMDB Dataset"]

node_reviewer -->|"uses"| node_app
node_app -->|"routes mode"| node_single
node_single -->|"predicts with"| node_predictor
node_predictor -->|"cleans text"| node_preprocessor
node_predictor -->|"transforms with"| node_vectorizer
node_predictor -->|"predicts with"| node_classifier
node_single -->|"saves prediction"| node_manager
node_app -->|"routes mode"| node_batch
node_batch -->|"cleans reviews"| node_preprocessor
node_batch -->|"transforms reviews"| node_vectorizer
node_batch -->|"classifies batch"| node_classifier
node_csv -->|"uploads data"| node_batch
node_batch -->|"offers results"| node_csv
node_app -->|"routes mode"| node_history
node_history -->|"loads history"| node_manager
node_manager -->|"reads and writes"| node_sqlite
node_dataset -->|"provides data"| node_training
node_training -->|"runs pipeline"| node_nlp
node_nlp -->|"normalizes text for"| node_features
node_features -->|"supplies features"| node_tuning
node_training -->|"tunes classifier"| node_tuning
node_training -->|"evaluates model"| node_evaluation
node_training -->|"explores data"| node_eda
node_tuning -.->|"produces model"| node_classifier
node_features -.->|"produces artifact"| node_vectorizer

click node_app "https://github.com/khalidllogic/sentiment-analysis-app/blob/main/app.py"
click node_single "https://github.com/khalidllogic/sentiment-analysis-app/blob/main/app.py"
click node_preprocessor "https://github.com/khalidllogic/sentiment-analysis-app/blob/main/app.py"
click node_predictor "https://github.com/khalidllogic/sentiment-analysis-app/blob/main/app.py"
click node_classifier "https://github.com/khalidllogic/sentiment-analysis-app/blob/main/sentiment_model.pkl"
click node_vectorizer "https://github.com/khalidllogic/sentiment-analysis-app/blob/main/vectorizer.pkl"
click node_batch "https://github.com/khalidllogic/sentiment-analysis-app/blob/main/app.py"
click node_history "https://github.com/khalidllogic/sentiment-analysis-app/blob/main/app.py"
click node_manager "https://github.com/khalidllogic/sentiment-analysis-app/blob/main/database_manager.py"
click node_training "https://github.com/khalidllogic/sentiment-analysis-app/blob/main/train_model.ipynb"
click node_nlp "https://github.com/khalidllogic/sentiment-analysis-app/blob/main/train_model.ipynb"
click node_features "https://github.com/khalidllogic/sentiment-analysis-app/blob/main/train_model.ipynb"
click node_tuning "https://github.com/khalidllogic/sentiment-analysis-app/blob/main/train_model.ipynb"
click node_evaluation "https://github.com/khalidllogic/sentiment-analysis-app/blob/main/train_model.ipynb"
click node_eda "https://github.com/khalidllogic/sentiment-analysis-app/blob/main/train_model.ipynb"

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_app,node_single,node_preprocessor,node_predictor,node_classifier,node_vectorizer,node_batch,node_reviewer toneBlue
class node_training,node_nlp,node_features,node_tuning,node_evaluation,node_eda toneAmber
class node_history,node_manager,node_sqlite toneMint
class node_csv,node_dataset toneIndigo
```

## Components

### Application Runtime

- [Streamlit App](https://github.com/khalidllogic/sentiment-analysis-app/blob/main/app.py): `app.py`
- [Single Review](https://github.com/khalidllogic/sentiment-analysis-app/blob/main/app.py): `app.py`
- [Text Preprocessor](https://github.com/khalidllogic/sentiment-analysis-app/blob/main/app.py): `app.py`
- [Sentiment Predictor](https://github.com/khalidllogic/sentiment-analysis-app/blob/main/app.py): `app.py`
- [Classifier Artifact](https://github.com/khalidllogic/sentiment-analysis-app/blob/main/sentiment_model.pkl): `sentiment_model.pkl`
- [Vectorizer Artifact](https://github.com/khalidllogic/sentiment-analysis-app/blob/main/vectorizer.pkl): `vectorizer.pkl`
- [Batch Analysis](https://github.com/khalidllogic/sentiment-analysis-app/blob/main/app.py): `app.py`

### Model Training

- [Training Lab](https://github.com/khalidllogic/sentiment-analysis-app/blob/main/train_model.ipynb): `train_model.ipynb`
- [NLP Pipeline](https://github.com/khalidllogic/sentiment-analysis-app/blob/main/train_model.ipynb): `train_model.ipynb`
- [TF-IDF Features](https://github.com/khalidllogic/sentiment-analysis-app/blob/main/train_model.ipynb): `train_model.ipynb`
- [Classifier Tuning](https://github.com/khalidllogic/sentiment-analysis-app/blob/main/train_model.ipynb): `train_model.ipynb`
- [Model Evaluation](https://github.com/khalidllogic/sentiment-analysis-app/blob/main/train_model.ipynb): `train_model.ipynb`
- [Exploratory Analysis](https://github.com/khalidllogic/sentiment-analysis-app/blob/main/train_model.ipynb): `train_model.ipynb`

### Prediction History

- [History Analytics](https://github.com/khalidllogic/sentiment-analysis-app/blob/main/app.py): `app.py`
- [Database Manager](https://github.com/khalidllogic/sentiment-analysis-app/blob/main/database_manager.py): `database_manager.py`
- **SQLite History**

### Other components

- **Reviewer**
- **CSV Upload / Results**
- **IMDB Dataset**

## Connections

- Reviewer → Streamlit App: uses (evidence: `README.md`)
- Streamlit App → Single Review: routes mode (evidence: `app.py`)
- Single Review → Sentiment Predictor: predicts with (evidence: `app.py`)
- Sentiment Predictor → Text Preprocessor: cleans text (evidence: `app.py`)
- Sentiment Predictor → Vectorizer Artifact: transforms with (evidence: `app.py`)
- Sentiment Predictor → Classifier Artifact: predicts with (evidence: `app.py`)
- Single Review → Database Manager: saves prediction (evidence: `app.py`)
- Streamlit App → Batch Analysis: routes mode (evidence: `app.py`)
- Batch Analysis → Text Preprocessor: cleans reviews (evidence: `app.py`)
- Batch Analysis → Vectorizer Artifact: transforms reviews (evidence: `app.py`)
- Batch Analysis → Classifier Artifact: classifies batch (evidence: `app.py`)
- CSV Upload / Results → Batch Analysis: uploads data (evidence: `app.py`)
- Batch Analysis → CSV Upload / Results: offers results (evidence: `app.py`)
- Streamlit App → History Analytics: routes mode (evidence: `app.py`)
- History Analytics → Database Manager: loads history (evidence: `app.py`)
- Database Manager → SQLite History: reads and writes (evidence: `database_manager.py`)
- IMDB Dataset → Training Lab: provides data (evidence: `README.md`)
- Training Lab → NLP Pipeline: runs pipeline (evidence: `README.md`)
- NLP Pipeline → TF-IDF Features: normalizes text for (evidence: `README.md`)
- TF-IDF Features → Classifier Tuning: supplies features (evidence: `README.md`)
- Training Lab → Classifier Tuning: tunes classifier (evidence: `README.md`)
- Training Lab → Model Evaluation: evaluates model (evidence: `README.md`)
- Training Lab → Exploratory Analysis: explores data (evidence: `README.md`)
- Classifier Tuning → Classifier Artifact: produces model (evidence: `README.md`)
- TF-IDF Features → Vectorizer Artifact: produces artifact (evidence: `README.md`)
