# vlarjun20/sentiment-analysis-of-product-reviews-using-streamlit-and-flask architecture

> Architecture diagram of the GitHub repository vlarjun20/sentiment-analysis-of-product-reviews-using-streamlit-and-flask, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vlarjun20/sentiment-analysis-of-product-reviews-using-streamlit-and-flask
- Repository: https://github.com/vlarjun20/sentiment-analysis-of-product-reviews-using-streamlit-and-flask

## Overview

##### Project type and purpose
- This is a web-based, full-stack sentiment-analysis tool.
- Key purpose: capture product-review text in a Flask UI, forward it to a Streamlit “model server,” run inference on a ROBERTa base model, and render the result (gauge/speedometer graph).

##### File structure
- Top-level files:
- `app.py` (Flask application)
- `streamlit.py` (Streamlit application with ML model)
- `templates/index.html` (Flask form UI)
- `positive review.txt` / `negative review.txt` (sample data)
- `requirements.txt` (deps: Flask, Streamlit, transformers, etc.)
- Pattern: two separate web services (Flask + Jinja UI, Streamlit model server).
- No database—model is loaded in-memory by Streamlit.

##### Extract key points from the README
- Flask app collects user input and “requests” the Streamlit localhost page.
- Streamlit loads the ROBERTa model, runs sentiment inference, and displays an interactive gauge chart.

##### Main components and their interactions
a. Components
1. User’s Web Browser
2. Flask Service (app.py + Jinja template)
3. Streamlit Service (streamlit.py + ML model)
4. ROBERTa Base Model (Torch/Transformers library)
5. Static sample-data files
b. Relationships / Data flows
- Browser → HTTP POST → Flask Service
- Flask Service → Internal HTTP GET/POST → Streamlit Service
- Streamlit Service → loads ROBERTa → performs inference → generates visualization
- Streamlit Service → HTTP response → Browser (gauge chart)
c. Architectural patterns/principles
- Client-Server separation (Browser ↔ Flask / Streamlit)
- Microservices-style split (Flask for UI, Streamlit for ML-inference)
- Single responsibility per service
d. Key technologies/libraries
- Python 3.x, Flask, Jinja2 (templates/index.html)
- Streamlit, Plotly or Streamlit’s built-in chart functions
- Transformers (ROBERTa base model), Torch
- HTTP / REST calls between Flask and Streamlit

## Diagram (Mermaid)

```mermaid
graph TD
    Browser["User Web Browser"]:::webui

    subgraph "Flask Service"
        direction TB
        FlaskApp["Flask Service (app.py)"]:::service
        Template["UI Template (templates/index.html)"]:::service
    end

    subgraph "Streamlit Service"
        direction TB
        StreamlitApp["Streamlit Service (streamlit.py + ROBERTa model)"]:::ml
        LoadModel["Load ROBERTa (transformers, Torch)"]:::ml
        Inference["Run Inference"]:::ml
        Render["Render Gauge Chart"]:::ml
    end

    NegData["negative review.txt"]:::data
    PosData["positive review.txt"]:::data
    Requirements["requirements.txt"]:::data
    Doc["README.md"]:::data

    Browser -->|"POST review"| FlaskApp
    Browser -->|"GET form page"| Template
    FlaskApp -->|"HTTP request"| StreamlitApp
    StreamlitApp --> LoadModel
    LoadModel --> Inference
    Inference --> Render
    Render -->|"Response with chart"| Browser

    NegData --> FlaskApp
    PosData --> FlaskApp
    Requirements --> FlaskApp
    Requirements --> StreamlitApp

    click FlaskApp "https://github.com/vlarjun20/sentiment-analysis-of-product-reviews-using-streamlit-and-flask/blob/main/app.py"
    click Template "https://github.com/vlarjun20/sentiment-analysis-of-product-reviews-using-streamlit-and-flask/blob/main/templates/index.html"
    click StreamlitApp "https://github.com/vlarjun20/sentiment-analysis-of-product-reviews-using-streamlit-and-flask/blob/main/streamlit.py"
    click NegData "https://github.com/vlarjun20/sentiment-analysis-of-product-reviews-using-streamlit-and-flask/blob/main/negative review.txt"
    click PosData "https://github.com/vlarjun20/sentiment-analysis-of-product-reviews-using-streamlit-and-flask/blob/main/positive review.txt"
    click Requirements "https://github.com/vlarjun20/sentiment-analysis-of-product-reviews-using-streamlit-and-flask/blob/main/requirements.txt"
    click Doc "https://github.com/vlarjun20/sentiment-analysis-of-product-reviews-using-streamlit-and-flask/blob/main/README.md"

    classDef webui fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef service fill:#90EE90,stroke:#000,stroke-width:1px
    classDef ml fill:#FFA500,stroke:#000,stroke-width:1px
    classDef data fill:#FFFFE0,stroke:#000,stroke-width:1px
```
