# jaya19prakash72/sentiment-analysis architecture

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

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

## Overview

This is a Flask sentiment-analysis dashboard. Users submit text through the browser, the server classifies it with a trained Naive Bayes model, records results, and returns them for display; the dashboard also presents aggregate counts and recent history. Batch analysis and sample-data training are additional product capabilities. The source excerpts establish the server, model, storage, and browser request flow; page structure and styling roles are documented in the README, whose details are not independently verified against those files.

Main entry points: [`app.py`](https://github.com/jaya19prakash72/sentiment-analysis/blob/main/app.py) (API routes), [`static/js/app.js`](https://github.com/jaya19prakash72/sentiment-analysis/blob/main/static/js/app.js) (Browser interactions), [`model/sentiment_model.py`](https://github.com/jaya19prakash72/sentiment-analysis/blob/main/model/sentiment_model.py) (Model training), [`templates/index.html`](https://github.com/jaya19prakash72/sentiment-analysis/blob/main/templates/index.html) (Dashboard page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_presentation["Browser dashboard"]
  node_page["Dashboard page<br/>[index.html]"]
  node_styles["Dashboard styling<br/>[style.css]"]
  node_browser["Browser interactions<br/>[app.js]"]
end

subgraph group_server["Flask application"]
  node_routes["API routes<br/>[app.py]"]
  node_batch["Batch analysis<br/>[app.py]"]
  node_stats["Stats and history<br/>[app.py]"]
end

subgraph group_inference["Sentiment model"]
  node_tokenizer["Text tokenization<br/>[sentiment_model.py]"]
  node_training["Model training<br/>[sentiment_model.py]"]
  node_classifier["Sentiment prediction<br/>[sentiment_model.py]"]
end

subgraph group_persistence["CSV persistence"]
  node_samples["Training samples<br/>[sentiment_data.csv]"]
  node_history[("Analysis history")]
end

node_user(("Dashboard user"))

node_user -->|"submits text"| node_browser
node_page -->|"provides interface"| node_browser
node_styles -->|"styles"| node_page
node_browser -->|"posts analysis"| node_routes
node_routes -->|"renders"| node_page
node_routes -->|"trains at startup"| node_training
node_training -->|"reads samples"| node_samples
node_training -->|"tokenizes training text"| node_tokenizer
node_routes -->|"predicts text"| node_classifier
node_classifier -->|"tokenizes input"| node_tokenizer
node_routes -->|"appends results"| node_history
node_routes -->|"dispatches batch request"| node_batch
node_batch -->|"predicts each text"| node_classifier
node_batch -->|"appends results"| node_history
node_browser -->|"fetches stats"| node_stats
node_stats -->|"reads records"| node_history
node_stats -->|"returns counts and history"| node_browser
node_routes -->|"returns prediction"| node_browser

click node_page "https://github.com/jaya19prakash72/sentiment-analysis/blob/main/templates/index.html"
click node_styles "https://github.com/jaya19prakash72/sentiment-analysis/blob/main/static/css/style.css"
click node_browser "https://github.com/jaya19prakash72/sentiment-analysis/blob/main/static/js/app.js"
click node_routes "https://github.com/jaya19prakash72/sentiment-analysis/blob/main/app.py"
click node_batch "https://github.com/jaya19prakash72/sentiment-analysis/blob/main/app.py"
click node_stats "https://github.com/jaya19prakash72/sentiment-analysis/blob/main/app.py"
click node_tokenizer "https://github.com/jaya19prakash72/sentiment-analysis/blob/main/model/sentiment_model.py"
click node_training "https://github.com/jaya19prakash72/sentiment-analysis/blob/main/model/sentiment_model.py"
click node_classifier "https://github.com/jaya19prakash72/sentiment-analysis/blob/main/model/sentiment_model.py"
click node_samples "https://github.com/jaya19prakash72/sentiment-analysis/blob/main/data/sentiment_data.csv"
click node_history "https://github.com/jaya19prakash72/sentiment-analysis/blob/main/data/analysis_history.csv"

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_page,node_styles,node_browser,node_user toneBlue
class node_routes,node_batch,node_stats toneAmber
class node_tokenizer,node_training,node_classifier toneMint
class node_samples,node_history toneRose
```

## Components

### Browser dashboard

- [Dashboard page](https://github.com/jaya19prakash72/sentiment-analysis/blob/main/templates/index.html): `templates/index.html`
- [Dashboard styling](https://github.com/jaya19prakash72/sentiment-analysis/blob/main/static/css/style.css): `static/css/style.css`
- [Browser interactions](https://github.com/jaya19prakash72/sentiment-analysis/blob/main/static/js/app.js): `static/js/app.js`

### Flask application

- [API routes](https://github.com/jaya19prakash72/sentiment-analysis/blob/main/app.py): `app.py`
- [Batch analysis](https://github.com/jaya19prakash72/sentiment-analysis/blob/main/app.py): `app.py`
- [Stats and history](https://github.com/jaya19prakash72/sentiment-analysis/blob/main/app.py): `app.py`

### Sentiment model

- [Text tokenization](https://github.com/jaya19prakash72/sentiment-analysis/blob/main/model/sentiment_model.py): `model/sentiment_model.py`
- [Model training](https://github.com/jaya19prakash72/sentiment-analysis/blob/main/model/sentiment_model.py): `model/sentiment_model.py`
- [Sentiment prediction](https://github.com/jaya19prakash72/sentiment-analysis/blob/main/model/sentiment_model.py): `model/sentiment_model.py`

### CSV persistence

- [Training samples](https://github.com/jaya19prakash72/sentiment-analysis/blob/main/data/sentiment_data.csv): `data/sentiment_data.csv`
- [Analysis history](https://github.com/jaya19prakash72/sentiment-analysis/blob/main/data/analysis_history.csv): `data/analysis_history.csv`

### Other components

- **Dashboard user**

## Connections

- Dashboard user → Browser interactions: submits text (evidence: `README.txt`)
- Dashboard page → Browser interactions: provides interface (evidence: `README.txt`)
- Dashboard styling → Dashboard page: styles (evidence: `README.txt`)
- Browser interactions → API routes: posts analysis (evidence: `static/js/app.js`)
- API routes → Dashboard page: renders (evidence: `README.txt`)
- API routes → Model training: trains at startup (evidence: `app.py`)
- Model training → Training samples: reads samples
- Model training → Text tokenization: tokenizes training text (evidence: `model/sentiment_model.py`)
- API routes → Sentiment prediction: predicts text (evidence: `app.py`)
- Sentiment prediction → Text tokenization: tokenizes input (evidence: `model/sentiment_model.py`)
- API routes → Analysis history: appends results (evidence: `app.py`)
- API routes → Batch analysis: dispatches batch request (evidence: `app.py`)
- Batch analysis → Sentiment prediction: predicts each text (evidence: `app.py`)
- Batch analysis → Analysis history: appends results (evidence: `app.py`)
- Browser interactions → Stats and history: fetches stats (evidence: `static/js/app.js`)
- Stats and history → Analysis history: reads records (evidence: `app.py`)
- Stats and history → Browser interactions: returns counts and history (evidence: `static/js/app.js`)
- API routes → Browser interactions: returns prediction (evidence: `static/js/app.js`)
