Skip to content

Repository files navigation

Sentiment Analysis Web Application

A modern full-stack Sentiment Analysis application built using React, Flask, and Hugging Face Transformers. The application allows users to analyze individual sentences or batches of text, visualize sentiment distribution through interactive charts, and generate AI-enhanced summary reports.


Overview

This project combines a responsive React frontend with a Flask backend powered by a Transformer-based sentiment analysis model. Users can classify text in real time, analyze large collections of feedback, and explore insights through interactive visualizations.


Features

Single Sentence Analysis

  • Analyze individual sentences instantly.
  • Predicts:
    • Positive
    • Negative
  • Displays confidence score.

Batch Sentiment Analysis

Upload or paste multiple sentences to:

  • Analyze each sentence individually.
  • Group results into categories.
  • Count positive and negative sentiments.
  • View category-wise statistics.

AI Generated Summary Report

Generate a comprehensive report including:

  • Overall sentiment summary
  • Positive vs Negative percentages
  • Category-wise insights
  • Automatically generated narrative

Interactive Dashboard

Includes:

  • Responsive interface
  • Category filters
  • Interactive Bar Charts
  • Interactive Pie Charts
  • Sentence-wise result table
  • Loading animations
  • Theme selection
  • Axis/Grid visibility toggle

Production Ready

  • Flask WSGI support
  • CORS enabled
  • Easily deployable on:
    • Render
    • Railway
    • Heroku
    • Docker
    • VPS

Tech Stack

Layer Technology
Frontend React 19
Build Tool Vite 6
Styling Tailwind CSS
Animation Framer Motion
Charts Chart.js
Backend Flask
ML Framework Hugging Face Transformers
Deep Learning PyTorch
API REST
Deployment Gunicorn (WSGI)

Project Structure

Sentiment-Analysis/
│
├── README.md
├── package.json
├── vite.config.js
├── tailwind.config.js
├── eslint.config.js
├── index.html
├── wsgi.py
│
├── public/
│   └── vite.svg
│
├── src/
│   ├── main.jsx
│   ├── App.jsx
│   ├── App.css
│   ├── index.css
│   │
│   ├── Components/
│   │   ├── InputForm.jsx
│   │   ├── BarChart.jsx
│   │   ├── PieChart.jsx
│   │   ├── Report.jsx
│   │   ├── FilterDropdown.jsx
│   │   └── SentenceItem.jsx
│   │
│   ├── backend/
│   │   ├── app.py
│   │   ├── model.py
│   │   └── requirements.txt
│   │
│   └── assets/
│       └── react.svg
│
└── .gitignore

API Endpoints

1. Classify a Sentence

POST /classify

Request

{
    "text": "The product is amazing!"
}

Response

{
    "label": "Positive",
    "confidence": 0.998
}

2. Batch Analysis

POST /analyze

Request

{
    "sentences": [
        "Great service",
        "Very disappointing",
        "Loved it"
    ]
}

Response

{
    "results":[...],
    "summary":{
        "Positive":2,
        "Negative":1
    }
}

3. Generate Report

POST /generate-full-report

Returns an AI-generated narrative report summarizing:

  • Overall sentiment
  • Positive percentage
  • Negative percentage
  • Category-wise observations
  • Final conclusion

Installation

Clone Repository

git clone https://github.com/AdityaPanda0506/Sentimental-Analysis.git

cd Sentimental-Analysis

Frontend Setup

Install dependencies

npm install

Start development server

npm run dev

Frontend runs at

http://localhost:5173

Backend Setup

Create virtual environment (optional)

Windows

python -m venv venv

venv\Scripts\activate

Linux / macOS

python3 -m venv venv

source venv/bin/activate

Install Python dependencies

pip install -r src/backend/requirements.txt

Run Flask server

python src/backend/app.py

Backend runs at

http://localhost:5000

Production Build

Build React

npm run build

Run using Gunicorn

gunicorn wsgi:app

Workflow

User
   │
   ▼
React Frontend
   │
   ▼
Flask REST API
   │
   ▼
Transformer Model
(Hugging Face)
   │
   ▼
Prediction
   │
   ▼
JSON Response
   │
   ▼
Charts + Reports

How It Works

Step 1

The user enters a sentence or multiple feedback entries.

↓

Step 2

The React frontend sends a request to the Flask API.

↓

Step 3

The backend loads a pretrained Hugging Face Transformer model.

↓

Step 4

The model predicts:

  • Sentiment
  • Confidence Score

↓

Step 5

Results are returned as JSON.

↓

Step 6

React renders:

  • Bar Chart
  • Pie Chart
  • Sentence Table
  • AI Summary Report

Security

  • Flask-CORS enabled for local development.
  • Configure allowed origins before production deployment.
  • Store API keys using environment variables.
  • Never commit secrets to the repository.

Future Improvements

  • User authentication
  • PDF report export
  • CSV upload support
  • Dark mode
  • Model selection
  • Multi-language sentiment analysis
  • Emotion detection
  • Aspect-based sentiment analysis
  • Historical analytics dashboard

Deployment

This application can be deployed using:

  • Docker
  • Render
  • Railway
  • Heroku
  • AWS EC2
  • DigitalOcean
  • Azure App Service

Contributing

  1. Fork the repository.
  2. Create a new branch.
git checkout -b feature/new-feature
  1. Commit your changes.
git commit -m "Add new feature"
  1. Push your branch.
git push origin feature/new-feature
  1. Open a Pull Request.

License

This project is released for educational and research purposes.

Feel free to modify, extend, and use it with proper attribution.


Author

Aditya Panda

Built with

  • React
  • Flask
  • Hugging Face Transformers
  • PyTorch
  • Chart.js
  • Tailwind CSS

About

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages