# musabellur/moviecomments-sentimentanalysis-chatbot architecture

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

- Interactive diagram: https://gitdiagram.com/musabellur/moviecomments-sentimentanalysis-chatbot
- Repository: https://github.com/musabellur/moviecomments-sentimentanalysis-chatbot

## Overview

This is a Flask chatbot for classifying Turkish film comments as positive or negative. The main flow is comment submission, text cleaning, TF-IDF transformation, Logistic Regression prediction, confidence-to-star conversion, and a JSON response; the app also serves a browser page. A separate script trains and evaluates a model from the spreadsheet. The README documents dark mode and emoji-based sentiment presentation, but the template and stylesheet were not excerpted, so their internal behavior and browser-to-endpoint wiring remain unverified.

Main entry points: [`chatbot.py`](https://github.com/musabellur/moviecomments-sentimentanalysis-chatbot/blob/main/chatbot.py) (Flask routes), [`istatistic.py`](https://github.com/musabellur/moviecomments-sentimentanalysis-chatbot/blob/main/istatistic.py) (Training and evaluation), [`templates/index.html`](https://github.com/musabellur/moviecomments-sentimentanalysis-chatbot/blob/main/templates/index.html) (Chat interface), [`tfidf_vectorizer.pkl`](https://github.com/musabellur/moviecomments-sentimentanalysis-chatbot/blob/main/tfidf_vectorizer.pkl) (TF-IDF vectorizer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Chatbot web app"]
  node_flask["Flask routes<br/>[chatbot.py]"]
  node_page["Chat interface<br/>[index.html]"]
  node_styles["Dark-mode styling<br/>[style.css]"]
end

subgraph group_inference["Sentiment inference"]
  node_cleaner["Text preprocessing<br/>[chatbot.py]"]
  node_vectorizer["TF-IDF vectorizer"]
  node_classifier["Logistic Regression"]
  node_rating["Confidence and stars<br/>[chatbot.py]"]
end

subgraph group_training["Model preparation"]
  node_dataset[("Labeled comments<br/>[dataset.xlsx]")]
  node_trainer["Training and evaluation<br/>[istatistic.py]"]
  node_app_training["App model training<br/>[chatbot.py]"]
end

node_visitor(("Browser user"))

node_visitor -->|"opens app"| node_flask
node_flask -->|"renders"| node_page
node_visitor -->|"uses interface"| node_page
node_page -.->|"submits comment"| node_flask
node_flask -->|"cleans input"| node_cleaner
node_flask -->|"transforms text"| node_vectorizer
node_flask -->|"predicts sentiment"| node_classifier
node_flask -->|"calculates stars"| node_rating
node_flask -->|"returns JSON"| node_visitor
node_app_training -->|"reads comments"| node_dataset
node_app_training -->|"cleans training text"| node_cleaner
node_app_training -->|"trains and saves"| node_classifier
node_app_training -->|"fits and saves"| node_vectorizer
node_trainer -->|"reads comments"| node_dataset
node_trainer -->|"trains and evaluates"| node_classifier
node_trainer -->|"fits and saves"| node_vectorizer

click node_flask "https://github.com/musabellur/moviecomments-sentimentanalysis-chatbot/blob/main/chatbot.py"
click node_page "https://github.com/musabellur/moviecomments-sentimentanalysis-chatbot/blob/main/templates/index.html"
click node_styles "https://github.com/musabellur/moviecomments-sentimentanalysis-chatbot/blob/main/static/style.css"
click node_cleaner "https://github.com/musabellur/moviecomments-sentimentanalysis-chatbot/blob/main/chatbot.py"
click node_vectorizer "https://github.com/musabellur/moviecomments-sentimentanalysis-chatbot/blob/main/tfidf_vectorizer.pkl"
click node_classifier "https://github.com/musabellur/moviecomments-sentimentanalysis-chatbot/blob/main/logistic_regression_model.pkl"
click node_rating "https://github.com/musabellur/moviecomments-sentimentanalysis-chatbot/blob/main/chatbot.py"
click node_dataset "https://github.com/musabellur/moviecomments-sentimentanalysis-chatbot/blob/main/dataset.xlsx"
click node_trainer "https://github.com/musabellur/moviecomments-sentimentanalysis-chatbot/blob/main/istatistic.py"
click node_app_training "https://github.com/musabellur/moviecomments-sentimentanalysis-chatbot/blob/main/chatbot.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_page,node_styles,node_visitor toneBlue
class node_cleaner,node_vectorizer,node_classifier,node_rating toneAmber
class node_dataset,node_trainer,node_app_training toneMint
```

## Components

### Chatbot web app

- [Flask routes](https://github.com/musabellur/moviecomments-sentimentanalysis-chatbot/blob/main/chatbot.py): `chatbot.py`
- [Chat interface](https://github.com/musabellur/moviecomments-sentimentanalysis-chatbot/blob/main/templates/index.html): `templates/index.html`
- [Dark-mode styling](https://github.com/musabellur/moviecomments-sentimentanalysis-chatbot/blob/main/static/style.css): `static/style.css`

### Sentiment inference

- [Text preprocessing](https://github.com/musabellur/moviecomments-sentimentanalysis-chatbot/blob/main/chatbot.py): `chatbot.py`
- [TF-IDF vectorizer](https://github.com/musabellur/moviecomments-sentimentanalysis-chatbot/blob/main/tfidf_vectorizer.pkl): `tfidf_vectorizer.pkl`
- [Logistic Regression](https://github.com/musabellur/moviecomments-sentimentanalysis-chatbot/blob/main/logistic_regression_model.pkl): `logistic_regression_model.pkl`
- [Confidence and stars](https://github.com/musabellur/moviecomments-sentimentanalysis-chatbot/blob/main/chatbot.py): `chatbot.py`

### Model preparation

- [Labeled comments](https://github.com/musabellur/moviecomments-sentimentanalysis-chatbot/blob/main/dataset.xlsx): `dataset.xlsx`
- [Training and evaluation](https://github.com/musabellur/moviecomments-sentimentanalysis-chatbot/blob/main/istatistic.py): `istatistic.py`
- [App model training](https://github.com/musabellur/moviecomments-sentimentanalysis-chatbot/blob/main/chatbot.py): `chatbot.py`

### Other components

- **Browser user**

## Connections

- Browser user → Flask routes: opens app (evidence: `README.md`)
- Flask routes → Chat interface: renders (evidence: `chatbot.py`)
- Browser user → Chat interface: uses interface (evidence: `README.md`)
- Chat interface → Flask routes: submits comment
- Flask routes → Text preprocessing: cleans input (evidence: `chatbot.py`)
- Flask routes → TF-IDF vectorizer: transforms text (evidence: `chatbot.py`)
- Flask routes → Logistic Regression: predicts sentiment (evidence: `chatbot.py`)
- Flask routes → Confidence and stars: calculates stars (evidence: `chatbot.py`)
- Flask routes → Browser user: returns JSON (evidence: `chatbot.py`)
- App model training → Labeled comments: reads comments (evidence: `chatbot.py`)
- App model training → Text preprocessing: cleans training text (evidence: `chatbot.py`)
- App model training → Logistic Regression: trains and saves (evidence: `chatbot.py`)
- App model training → TF-IDF vectorizer: fits and saves (evidence: `chatbot.py`)
- Training and evaluation → Labeled comments: reads comments (evidence: `istatistic.py`)
- Training and evaluation → Logistic Regression: trains and evaluates (evidence: `istatistic.py`)
- Training and evaluation → TF-IDF vectorizer: fits and saves (evidence: `istatistic.py`)
