# chitikesisiddharth04/bilingual-movie-review-sentiment-analysis-using-nlp architecture

> Architecture diagram of the GitHub repository chitikesisiddharth04/bilingual-movie-review-sentiment-analysis-using-nlp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/chitikesisiddharth04/bilingual-movie-review-sentiment-analysis-using-nlp
- Repository: https://github.com/chitikesisiddharth04/bilingual-movie-review-sentiment-analysis-using-nlp

## Overview

#### Purpose and entry points
This is a Flask-served bilingual movie-review sentiment classifier. Users submit English or Telugu text through a single browser UI; the backend selects the corresponding trained Bag-of-Words/Bernoulli Naive Bayes pipeline and returns Positive or Negative sentiment. Runtime entry point: `app.py`; browser entry template: `templates/index.html`.

#### Web application boundary
`app.py` owns HTTP routing, request handling, language selection, model invocation, and response generation. `templates/index.html` is the unified client interface, including language switching and review submission. The app runs locally with Flask and is intended for Gunicorn in production (`gunicorn app:app`).

#### English inference pipeline
English review processing and training logic are centered in `english/MRA.py`. Its deployed artifacts are the fitted classifier `english/model1.pkl` and fitted vocabulary/vectorizer `english/bow.pkl`. The expected flow is raw English text → preprocessing/tokenization/stopword removal/stemming → vectorization → BernoulliNB prediction → sentiment result.

#### Telugu inference pipeline
Telugu has an independent language-specific pipeline in `telugu/telugu_MRA.py`, allowing Unicode-aware text normalization, Telugu tokenization, and custom stopword handling without coupling to English rules. Deployed model artifacts are `telugu/telugu_model.pkl` and `telugu/telugu_vectorizer.pkl`. Flow mirrors English: Telugu review → Telugu preprocessing → vectorization → BernoulliNB prediction → sentiment result.

#### Model artifact contract
The Flask layer depends on each language model and its matching vectorizer being loaded together: English paths are `english/model1.pkl` plus `english/bow.pkl`; Telugu paths are `telugu/telugu_model.pkl` plus `telugu/telugu_vectorizer.pkl`. Vectorizer feature spaces are model-specific and must not be interchanged. Training scripts regenerate these serializable artifacts for serving.

#### Training versus serving boundary
Training is offline/manual rather than part of normal application startup. `english/MRA.py` is intended to train from an IMDB review dataset supplied externally; `telugu/telugu_MRA.py` trains from a supplied Telugu dataset. Serving uses committed pre-trained `.pkl` files only, keeping request-time work limited to preprocessing, feature extraction, and inference.

#### Runtime and deployment
Material runtime dependencies are Python 3.8+, Flask, NLTK, scikit-learn, and Pandas, declared in `requirements.txt`. `render-build.sh` provides the Render build-stage integration; production deployment targets Render with Gunicorn. External data sources are Kaggle/IMDB data for optional English retraining and a separately supplied Telugu dataset; neither dataset is present in the supplied file tree.

Main entry points: [`english/MRA.py`](https://github.com/chitikesisiddharth04/bilingual-movie-review-sentiment-analysis-using-nlp/blob/main/english/MRA.py) (English inference), [`telugu/telugu_MRA.py`](https://github.com/chitikesisiddharth04/bilingual-movie-review-sentiment-analysis-using-nlp/blob/main/telugu/telugu_MRA.py) (Telugu inference), [`app.py`](https://github.com/chitikesisiddharth04/bilingual-movie-review-sentiment-analysis-using-nlp/blob/main/app.py) (Flask application), [`templates/index.html`](https://github.com/chitikesisiddharth04/bilingual-movie-review-sentiment-analysis-using-nlp/blob/main/templates/index.html) (Unified review UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web Serving"]
  node_browser(("Browser<br/>client"))
  node_template["Unified review UI<br/>Flask template<br/>[index.html]"]
  node_app["Flask application<br/>HTTP server<br/>[app.py]"]
end

subgraph group_english["English Pipeline"]
  node_english_runtime["English inference<br/>text pipeline<br/>[MRA.py]"]
  node_english_vectorizer["English vectorizer<br/>serialized BoW<br/>[bow.pkl]"]
  node_english_model["English BernoulliNB<br/>serialized model<br/>[model1.pkl]"]
  node_english_data[("IMDB training data<br/>external dataset")]
end

subgraph group_telugu["Telugu Pipeline"]
  node_telugu_runtime["Telugu inference<br/>text pipeline<br/>[telugu_MRA.py]"]
  node_telugu_vectorizer["Telugu vectorizer<br/>serialized BoW"]
  node_telugu_model["Telugu BernoulliNB<br/>serialized model<br/>[telugu_model.pkl]"]
  node_telugu_data[("Telugu training data<br/>external dataset")]
end

subgraph group_deploy["Deployment"]
  node_requirements["Python dependencies<br/>dependency manifest<br/>[requirements.txt]"]
  node_render_build["Render build stage<br/>build script<br/>[render-build.sh]"]
  node_gunicorn{{"Gunicorn on Render<br/>production runtime"}}
end

node_browser -->|"loads UI"| node_template
node_template -->|"submits review + language"| node_app
node_app -->|"English request"| node_english_runtime
node_app -->|"Telugu request"| node_telugu_runtime
node_english_vectorizer -->|"vectorizes text"| node_english_runtime
node_english_model -->|"predicts sentiment"| node_english_runtime
node_telugu_vectorizer -->|"vectorizes text"| node_telugu_runtime
node_telugu_model -->|"predicts sentiment"| node_telugu_runtime
node_english_data -.->|"offline training input"| node_english_runtime
node_english_runtime -.->|"regenerates offline"| node_english_vectorizer
node_english_runtime -.->|"regenerates offline"| node_english_model
node_telugu_data -.->|"offline training input"| node_telugu_runtime
node_telugu_runtime -.->|"regenerates offline"| node_telugu_vectorizer
node_telugu_runtime -.->|"regenerates offline"| node_telugu_model
node_render_build -->|"installs"| node_requirements
node_gunicorn -->|"serves"| node_app
node_requirements -->|"runtime dependencies"| node_gunicorn

click node_template "https://github.com/chitikesisiddharth04/bilingual-movie-review-sentiment-analysis-using-nlp/blob/main/templates/index.html"
click node_app "https://github.com/chitikesisiddharth04/bilingual-movie-review-sentiment-analysis-using-nlp/blob/main/app.py"
click node_english_runtime "https://github.com/chitikesisiddharth04/bilingual-movie-review-sentiment-analysis-using-nlp/blob/main/english/MRA.py"
click node_english_vectorizer "https://github.com/chitikesisiddharth04/bilingual-movie-review-sentiment-analysis-using-nlp/blob/main/english/bow.pkl"
click node_english_model "https://github.com/chitikesisiddharth04/bilingual-movie-review-sentiment-analysis-using-nlp/blob/main/english/model1.pkl"
click node_telugu_runtime "https://github.com/chitikesisiddharth04/bilingual-movie-review-sentiment-analysis-using-nlp/blob/main/telugu/telugu_MRA.py"
click node_telugu_vectorizer "https://github.com/chitikesisiddharth04/bilingual-movie-review-sentiment-analysis-using-nlp/blob/main/telugu/telugu_vectorizer.pkl"
click node_telugu_model "https://github.com/chitikesisiddharth04/bilingual-movie-review-sentiment-analysis-using-nlp/blob/main/telugu/telugu_model.pkl"
click node_requirements "https://github.com/chitikesisiddharth04/bilingual-movie-review-sentiment-analysis-using-nlp/blob/main/requirements.txt"
click node_render_build "https://github.com/chitikesisiddharth04/bilingual-movie-review-sentiment-analysis-using-nlp/blob/main/render-build.sh"

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_browser,node_template,node_app toneBlue
class node_english_runtime,node_english_vectorizer,node_english_model,node_english_data toneAmber
class node_telugu_runtime,node_telugu_vectorizer,node_telugu_model,node_telugu_data toneMint
class node_requirements,node_render_build,node_gunicorn toneRose
```

## Components

### Web Serving

- **Browser**: client · Users submit a review and choose a language.
- [Unified review UI](https://github.com/chitikesisiddharth04/bilingual-movie-review-sentiment-analysis-using-nlp/blob/main/templates/index.html): Flask template · Language switching and review submission interface. · `templates/index.html`
- [Flask application](https://github.com/chitikesisiddharth04/bilingual-movie-review-sentiment-analysis-using-nlp/blob/main/app.py): HTTP server · Routes requests, selects a language pipeline, and returns sentiment. · `app.py`

### English Pipeline

- [English inference](https://github.com/chitikesisiddharth04/bilingual-movie-review-sentiment-analysis-using-nlp/blob/main/english/MRA.py): text pipeline · Preprocesses English text, vectorizes it, and predicts sentiment. · `english/MRA.py`
- [English vectorizer](https://github.com/chitikesisiddharth04/bilingual-movie-review-sentiment-analysis-using-nlp/blob/main/english/bow.pkl): serialized BoW · Feature space paired only with the English classifier. · `english/bow.pkl`
- [English BernoulliNB](https://github.com/chitikesisiddharth04/bilingual-movie-review-sentiment-analysis-using-nlp/blob/main/english/model1.pkl): serialized model · `english/model1.pkl`
- **IMDB training data**: external dataset · Optional external Kaggle/IMDB source for offline retraining.

### Telugu Pipeline

- [Telugu inference](https://github.com/chitikesisiddharth04/bilingual-movie-review-sentiment-analysis-using-nlp/blob/main/telugu/telugu_MRA.py): text pipeline · Uses Unicode-aware normalization, Telugu tokenization, and custom stopwords. · `telugu/telugu_MRA.py`
- [Telugu vectorizer](https://github.com/chitikesisiddharth04/bilingual-movie-review-sentiment-analysis-using-nlp/blob/main/telugu/telugu_vectorizer.pkl): serialized BoW · Feature space paired only with the Telugu classifier. · `telugu/telugu_vectorizer.pkl`
- [Telugu BernoulliNB](https://github.com/chitikesisiddharth04/bilingual-movie-review-sentiment-analysis-using-nlp/blob/main/telugu/telugu_model.pkl): serialized model · `telugu/telugu_model.pkl`
- **Telugu training data**: external dataset · Supplied externally for offline retraining.

### Deployment

- [Python dependencies](https://github.com/chitikesisiddharth04/bilingual-movie-review-sentiment-analysis-using-nlp/blob/main/requirements.txt): dependency manifest · Declares Flask, NLTK, scikit-learn, Pandas, and Python requirements. · `requirements.txt`
- [Render build stage](https://github.com/chitikesisiddharth04/bilingual-movie-review-sentiment-analysis-using-nlp/blob/main/render-build.sh): build script · `render-build.sh`
- **Gunicorn on Render**: production runtime · Serves the Flask app using gunicorn app:app.

## Connections

- Browser → Unified review UI: loads UI
- Unified review UI → Flask application: submits review + language
- Flask application → English inference: English request
- Flask application → Telugu inference: Telugu request
- English vectorizer → English inference: vectorizes text
- English BernoulliNB → English inference: predicts sentiment
- Telugu vectorizer → Telugu inference: vectorizes text
- Telugu BernoulliNB → Telugu inference: predicts sentiment
- IMDB training data → English inference: offline training input
- English inference → English vectorizer: regenerates offline
- English inference → English BernoulliNB: regenerates offline
- Telugu training data → Telugu inference: offline training input
- Telugu inference → Telugu vectorizer: regenerates offline
- Telugu inference → Telugu BernoulliNB: regenerates offline
- Render build stage → Python dependencies: installs
- Gunicorn on Render → Flask application: serves
- Python dependencies → Gunicorn on Render: runtime dependencies
