Skip to content

UtkarsHMer05/sentiment-analysis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

27 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🎭 Multimodal Sentiment Analysis Platform

Platform Banner

Next.js TypeScript Python FastAPI AWS Stripe License

Enterprise-grade AI platform for real-time multimodal sentiment analysis combining video, audio, text, and document processing with live emotion detection, summary generation, and word cloud visualization.

πŸš€ Quick Start β€’ πŸ“– Documentation β€’ 🎯 Use Cases β€’ πŸ› Report Bug β€’ πŸ’‘ Request Feature


πŸ“Έ Platform Screenshots

🏠 Landing Page

Landing Page

πŸ” Authentication

Login Signup

πŸ“Š Dashboard & Analysis Results

Dashboard Results 1 Results 2 Results 3 Results 4

πŸ“Ή Live Detection & Real-time Results

Live Detection Live Results 1 Live Results 2 Live Results 3 Live Results 4


πŸ“š Table of Contents


🌟 Overview

The Multimodal Sentiment Analysis Platform is a comprehensive AI-powered solution designed to analyze sentiments, emotions, and feedback from multiple modalities including:

  • πŸ“„ Documents (PDF, Excel) - Stakeholder feedback, comments, surveys
  • πŸ“Ή Video - Facial expressions, body language, visual cues
  • πŸŽ™οΈ Audio - Voice tone, prosodic patterns, emotional speech
  • πŸ“ Text - Written comments, suggestions, observations

🎯 Problem We Solve

Traditional sentiment analysis tools only process text, missing crucial emotional cues from voice tone, facial expressions, and body language. Large volumes of feedback (such as public consultation comments) often risk being inadequately analyzed or overlooked.

This platform bridges this gap by:

Challenge Our Solution
Analyzing large volumes of stakeholder comments Batch PDF/Excel processing with individual line analysis
Understanding emotional context beyond text Multimodal fusion (video + audio + text)
Summarizing lengthy feedback AI-powered abstractive summarization
Identifying key themes Word cloud visualization & entity extraction
Processing in real-time WebSocket-based live emotion detection

πŸ“Š Performance Metrics

Metric Score
Emotion Recognition Accuracy 78.4%
Sentiment Classification 85.2%
Real-time Latency < 1 second
Supported Emotions 7 Classes
Document Processing PDF, XLSX, XLS

🎯 Real-World Use Case: eConsultation Module

Government Use Case: Ministry of Corporate Affairs (MoCA)

πŸ“‹ Problem Statement

The eConsultation module is an online platform where proposed amendments and draft legislations are posted on the MCA website. External users can submit their comments and suggestions through the MCA21 portal.

The Challenge

When a substantial volume of comments is received on draft legislation:

  • ❌ Certain observations may be inadvertently overlooked
  • ❌ Feedback may be inadequately analyzed
  • ❌ Manual review of thousands of comments is time-consuming
  • ❌ Identifying the overall sentiment across all feedback is difficult
  • ❌ Understanding key themes and frequently mentioned topics is challenging

βœ… How This Platform Solves It

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     eConsultation Feedback Analysis Flow                     β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                              β”‚
β”‚  πŸ“₯ Upload Comments        β†’  πŸ€– AI Analysis         β†’  πŸ“Š Results          β”‚
β”‚  (PDF/Excel file with         (Automated processing      (Dashboard with    β”‚
β”‚   stakeholder feedback)        of each comment)           insights)          β”‚
β”‚                                                                              β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                              OUTPUT INCLUDES:                                β”‚
β”‚                                                                              β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”             β”‚
β”‚  β”‚ πŸ“ˆ Sentiment    β”‚  β”‚ πŸ“ Summaries    β”‚  β”‚ ☁️ Word Cloud   β”‚             β”‚
β”‚  β”‚    Analysis     β”‚  β”‚    Per Comment  β”‚  β”‚    Keywords     β”‚             β”‚
β”‚  β”‚                 β”‚  β”‚                 β”‚  β”‚                 β”‚             β”‚
β”‚  β”‚ β€’ Positive      β”‚  β”‚ β€’ Concise       β”‚  β”‚ β€’ Visual        β”‚             β”‚
β”‚  β”‚ β€’ Negative      β”‚  β”‚   meaning       β”‚  β”‚   representationβ”‚             β”‚
β”‚  β”‚ β€’ Neutral       β”‚  β”‚ β€’ Key points    β”‚  β”‚ β€’ Density map   β”‚             β”‚
β”‚  β”‚   for EACH line β”‚  β”‚   extracted     β”‚  β”‚   of themes     β”‚             β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜             β”‚
β”‚                                                                              β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”             β”‚
β”‚  β”‚ 🏷️ Named Entity β”‚  β”‚ πŸ“Š Overall      β”‚  β”‚ πŸ“ Export       β”‚             β”‚
β”‚  β”‚    Recognition  β”‚  β”‚    Statistics   β”‚  β”‚    Options      β”‚             β”‚
β”‚  β”‚                 β”‚  β”‚                 β”‚  β”‚                 β”‚             β”‚
β”‚  β”‚ β€’ Organizations β”‚  β”‚ β€’ Total commentsβ”‚  β”‚ β€’ JSON          β”‚             β”‚
β”‚  β”‚ β€’ Persons       β”‚  β”‚ β€’ Distribution  β”‚  β”‚ β€’ Download      β”‚             β”‚
β”‚  β”‚ β€’ Locations     β”‚  β”‚ β€’ Page-by-page  β”‚  β”‚   results       β”‚             β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜             β”‚
β”‚                                                                              β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

🎯 Expected Outcomes Delivered

Requirement Platform Feature
Sentiment Analysis βœ… Legal-BERT based zero-shot classification for positive/negative/neutral sentiment on each comment
Summary Generation βœ… DistilBART abstractive summarization to convey meaning precisely
Word Cloud βœ… Visual density representation of keywords used by stakeholders
Reduce Analysis Effort βœ… Automated batch processing of entire documents
Individual & Overall βœ… Both per-line analysis AND combined document analysis

πŸ’‘ Example Workflow

  1. Upload the Excel/PDF export of eConsultation comments
  2. Automatic Processing - Each line is analyzed individually for:
    • Sentiment (positive/negative/neutral)
    • AI-generated summary
    • Named entities (organizations, persons, locations mentioned)
  3. Combined Analysis - Overall document analysis generates:
    • Sentiment distribution chart
    • Word cloud of all keywords
    • Top mentioned entities
  4. Export Results - Download complete analysis as JSON

✨ Complete Feature Set

πŸ€– AI & Machine Learning

πŸ“„ Document Analysis (PDF/Excel)

  • Legal-BERT zero-shot classification for sentiment
  • DistilBART abstractive summarization
  • spaCy NER for entity extraction
  • Word Cloud generation with keyword density
  • Line-by-line AND combined analysis modes
  • Supports PDF, XLSX, XLS formats
  • Max file size: 50MB

πŸ“Ή Video Analysis

  • 7 Emotion Classes: Joy, Sadness, Anger, Fear, Surprise, Disgust, Neutral
  • 3D CNN with temporal modeling for facial expressions
  • Real-time WebSocket streaming
  • Frame-by-frame analysis
  • Confidence scores for each detection

πŸŽ™οΈ Audio Analysis

  • Mel-Spectrogram CNN for voice analysis
  • Whisper (OpenAI) for transcription
  • Prosodic pattern detection
  • Vocal intensity analysis
  • 16kHz sampling with 128 mel filters

πŸ”— Multimodal Fusion

  • Attention-based cross-modal fusion
  • Multi-head attention with learned weights
  • Combined emotion + sentiment scoring
  • 78.4% emotion accuracy
  • 85.2% sentiment accuracy

πŸŽ₯ Live Emotion Detection

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    Live Detection System                      β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                               β”‚
β”‚  πŸ“Ή Camera Input  ──→  πŸ”„ WebSocket Server  ──→  πŸ“Š Results  β”‚
β”‚                         (Port 8080)                           β”‚
β”‚                                                               β”‚
β”‚  Features:                                                    β”‚
β”‚  β€’ Real-time emotion detection                                β”‚
β”‚  β€’ JWT-authenticated connections                              β”‚
β”‚  β€’ Video frame processing                                     β”‚
β”‚  β€’ Audio chunk analysis                                       β”‚
β”‚  β€’ Text input sentiment                                       β”‚
β”‚  β€’ Periodic analysis updates (every 2 seconds)                β”‚
β”‚  β€’ Upload recorded sessions for batch analysis                β”‚
β”‚                                                               β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ’Ό Enterprise Features

Feature Description
πŸ” Authentication NextAuth.js with secure password hashing (BCrypt)
πŸ”‘ API Key Management Generate, revoke, and manage API keys (sa_live_* format)
πŸ“Š Quota System Track usage with per-operation costs (2 points each for sentiment, live detection, PDF analysis)
πŸ’³ Stripe Payments Subscription management with quota stacking
πŸ“ˆ Usage Analytics Real-time quota tracking and billing
πŸ”„ Auto-Upload Automatic session upload after live detection

πŸ’° Pricing Plans

Plan Price Quota Features
Basic $9.99/mo 30 requests Standard processing, Email support
Pro $29.99/mo 100 requests Priority processing, API access
Premium $99.99/mo 1000 requests Unlimited features, Priority support
Enterprise Contact Sales Custom SLA, Custom integrations, Dedicated manager

🎨 User Experience

  • Responsive Design - Mobile-first with Tailwind CSS
  • Animated UI - Smooth transitions with Framer Motion
  • Real-time Dashboard - Live analytics and processing status
  • Progress Tracking - Visual feedback for long-running processes
  • Interactive Results - Expandable analysis cards, sentiment charts

πŸ› οΈ Tech Stack

🎨 Frontend βš™οΈ Backend πŸ€– AI/ML ☁️ Infrastructure
  • Next.js 15.0.1
  • TypeScript 5.5.3
  • Tailwind CSS 3.4.3
  • Framer Motion 11.18
  • React Hook Form
  • Radix UI Components
  • Lucide Icons
  • Node.js API Routes
  • FastAPI (Python)
  • Prisma ORM 5.14
  • NextAuth.js 5.0.0
  • WebSocket (ws 8.18)
  • BCrypt.js 2.4.3
  • Zod Validation
  • Legal-BERT (sentiment)
  • DistilBART (summary)
  • spaCy (NER)
  • PyTorch 2.5.1
  • Transformers 4.46
  • OpenCV 4.10
  • Whisper (OpenAI)
  • WordCloud
  • AWS SageMaker
  • AWS S3
  • AWS EC2/IAM
  • Stripe Payments
  • PostgreSQL/SQLite
  • Vercel/Docker

πŸ—οΈ System Architecture

High-Level Overview

flowchart TB
    subgraph Client["πŸ–₯️ Client Layer"]
        Browser[Web Browser]
        Camera[πŸ“Ή Camera]
        Mic[πŸŽ™οΈ Microphone]
    end

    subgraph NextJS["⚑ Next.js Application (Port 3000)"]
        Pages[React Pages & Components]
        API[API Routes]
        Auth[NextAuth.js]
    end

    subgraph WebSocket["πŸ”„ WebSocket Server (Port 8080)"]
        LiveServer[Live Analysis Server]
        JWT[JWT Authentication]
    end

    subgraph Python["🐍 FastAPI Service (Port 8001)"]
        PDFAnalyzer[PDF/Excel Analyzer]
        LegalBERT[Legal-BERT Classifier]
        Summarizer[DistilBART Summarizer]
        NER[spaCy NER]
        WordCloud[Word Cloud Generator]
    end

    subgraph Database["πŸ—„οΈ Database Layer"]
        Prisma[(Prisma ORM)]
        PostgreSQL[(PostgreSQL/SQLite)]
    end

    subgraph External["☁️ External Services"]
        S3[(AWS S3)]
        SageMaker[AWS SageMaker]
        Stripe[Stripe API]
    end

    Browser --> Pages
    Camera --> LiveServer
    Mic --> LiveServer
    
    Pages --> API
    API --> Auth
    API --> Prisma
    API --> PDFAnalyzer
    API --> S3
    API --> Stripe
    
    LiveServer --> JWT
    LiveServer --> SageMaker
    
    PDFAnalyzer --> LegalBERT
    PDFAnalyzer --> Summarizer
    PDFAnalyzer --> NER
    PDFAnalyzer --> WordCloud
    
    Prisma --> PostgreSQL
Loading

Core Services

Service Port Description
Next.js Frontend + API 3000 Marketing site, dashboard, REST APIs, NextAuth, Prisma
WebSocket Live Analysis 8080 Real-time emotion streaming (JWT protected)
FastAPI PDF Analyzer 8001 Document extraction, sentiment, summarization, NER, word cloud
Stripe Webhooks 3000 Subscription events at /api/stripe/webhooks

Database Schema

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚     User     β”‚   β”‚   ApiQuota   β”‚   β”‚   Purchase   β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€   β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€   β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ id           │◄──│ userId       β”‚   β”‚ id           β”‚
β”‚ name         β”‚   β”‚ requestsUsed β”‚   β”‚ userId       β”‚
β”‚ email        β”‚   β”‚ maxRequests  β”‚   β”‚ stripeSessionβ”‚
β”‚ password     β”‚   β”‚ resetDate    β”‚   β”‚ amount       β”‚
β”‚ stripeId     β”‚   β”‚ secretKey    β”‚   β”‚ planType     β”‚
β”‚ isActive     β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚ requestsGrantβ”‚
β”‚ subscriptionId                       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        β”‚
        β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  VideoFile   β”‚   β”‚   Session    β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€   β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ id           β”‚   β”‚ id           β”‚
β”‚ userId       β”‚   β”‚ sessionToken β”‚
β”‚ key          β”‚   β”‚ userId       β”‚
β”‚ analyzed     β”‚   β”‚ expires      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

⚑ Quick Start

Prerequisites

# Verify installations
node --version    # v18+ required
python3 --version # v3.10+ required
npm --version     # v10.2.4+

One-Command Setup

# Clone and enter directory
git clone https://github.com/UtkarsHMer05/sentiment-analysis.git && cd sentiment-analysis

# Install dependencies
npm install

# Configure environment
cp .env.example .env.local
echo "AUTH_SECRET=\"$(openssl rand -base64 32)\"" >> .env.local
echo "NEXTAUTH_URL=\"http://localhost:3000\"" >> .env.local
echo "DATABASE_URL=\"file:./dev.db\"" >> .env.local

# Setup database
npm run db:push

# Setup Python service
cd pdf-analyzer-service && chmod +x setup.sh && ./setup.sh && cd ..

# Start everything
npm run dev:full

πŸŽ‰ Open http://localhost:3000

Quick Verification

  1. Open http://localhost:3000
  2. Click Sign Up β†’ Create account
  3. Navigate to Dashboard
  4. Test PDF Analysis or Live Detection

πŸ“– Complete Setup Guide

πŸ”§ Prerequisites

Software Version Download
Node.js v18+ nodejs.org
Python v3.10+ python.org
Git Latest git-scm.com

πŸ“₯ Step-by-Step Installation

Step 1: Clone & Install Node Dependencies
git clone https://github.com/UtkarsHMer05/sentiment-analysis.git
cd sentiment-analysis
npm install

Expected output:

added 500+ packages
βœ” Generated Prisma Client
Step 2: Configure Environment Variables
cp .env.example .env.local

Edit .env.local:

# Database (SQLite for dev, PostgreSQL for production)
DATABASE_URL="file:./dev.db"

# Authentication (generate with: openssl rand -base64 32)
AUTH_SECRET="your-secret-here"
NEXTAUTH_URL="http://localhost:3000"

# AWS (Optional - for video analysis)
AWS_REGION="us-east-1"
AWS_ACCESS_KEY_ID="your-key"
AWS_SECRET_ACCESS_KEY="your-secret"
AWS_INFERENCE_BUCKET="your-bucket"
AWS_ENDPOINT_NAME="your-endpoint"

# Stripe (Optional - for payments)
STRIPE_PUBLIC_KEY="pk_test_..."
STRIPE_SECRET_KEY="sk_test_..."
STRIPE_WEBHOOK_SECRET="whsec_..."

# Python Backend
PYTHON_BACKEND_URL="http://localhost:8001"
Step 3: Setup Database
npm run db:push

# View database (optional)
npm run db:studio
Step 4: Setup Python Backend
cd pdf-analyzer-service
chmod +x setup.sh
./setup.sh
cd ..

This installs:

  • FastAPI & Uvicorn
  • PyTorch & Transformers
  • Legal-BERT, DistilBART models
  • spaCy with en_core_web_sm
  • WordCloud, pdfplumber, openpyxl
Step 5: Start All Services
# Full development mode (Next.js + WebSocket)
npm run dev:full

# Or run separately:
npm run dev          # Terminal 1: Next.js (port 3000)
npm run websocket    # Terminal 2: WebSocket (port 8080)
cd pdf-analyzer-service && source venv/bin/activate && python main.py  # Terminal 3: Python (port 8001)

πŸ”Œ API Documentation

Authentication

All protected endpoints require:

Authorization: Bearer sa_live_your_api_key_here

REST Endpoints

Route Method Description Auth
/api/upload-url POST Generate S3 presigned URL for video upload API Key
/api/sentiment-inference POST Trigger SageMaker video analysis API Key
/api/pdf-analysis POST Analyze PDF/Excel document Session
/api/live-emotion POST Process live recording session Session
/api/live-recording-upload POST Upload live-recorded media chunks API Key
/api/user/api-key POST/DELETE Create or revoke API keys Session
/api/user/quota GET Get quota status Session
/api/stripe/checkout POST Create Stripe checkout session Session
/api/stripe/webhooks POST Handle Stripe subscription events Stripe

PDF Analysis API

# Analyze PDF document
curl -X POST "http://localhost:8001/analyze-document" \
  -F "file=@feedback.pdf" \
  -F "analysis_type=both"

# Response includes:
# - individual_analysis: Array of per-line results
# - combined_analysis: Overall document analysis with word cloud

WebSocket Events

Connect: ws://localhost:8080?token=<jwt>

Send:

{
  "type": "start_analysis" | "stop_analysis" | "video_frame" | "audio_chunk" | "text_input",
  "data": {},
  "timestamp": 1734882712345
}

Receive:

{
  "type": "video_analysis",
  "data": {
    "emotion": "joy",
    "sentiment": "positive",
    "confidence": 0.92,
    "keywords": ["happy", "excited"]
  },
  "timestamp": 1734882712345
}

🎯 Feature Deep Dive

Document Analysis Pipeline

                              PDF/Excel Upload
                                    β”‚
                                    β–Ό
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚      Text Extraction          β”‚
                    β”‚   (pdfplumber / openpyxl)     β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β”‚
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β–Ό                     β–Ό                     β–Ό
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚  Legal-BERT     β”‚   β”‚  DistilBART     β”‚   β”‚   spaCy NER     β”‚
    β”‚  Zero-Shot      β”‚   β”‚  Summarization  β”‚   β”‚   Entities      β”‚
    β”‚  Classification β”‚   β”‚                 β”‚   β”‚                 β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
              β”‚                     β”‚                     β”‚
              β”‚           β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”             β”‚
              β”‚           β”‚   Word Cloud    β”‚             β”‚
              β”‚           β”‚   Generation    β”‚             β”‚
              β”‚           β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜             β”‚
              β”‚                     β”‚                     β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β–Ό
                          Analysis Results JSON

Quota Cost System

Operation Cost Description
sentiment_analysis 2 points Video sentiment analysis
live_detection 2 points Live emotion detection session
pdf_analysis 2 points PDF/Excel document analysis

πŸ”§ Troubleshooting

Database Issues
# Reset database
rm prisma/dev.db
npm run db:push

# Regenerate Prisma client
npx prisma generate
Port Conflicts
# Kill process on port
lsof -ti:3000 | xargs kill -9
lsof -ti:8001 | xargs kill -9
lsof -ti:8080 | xargs kill -9
Python Backend Issues
cd pdf-analyzer-service
source venv/bin/activate
pip install -r requirements.txt
python -m spacy download en_core_web_sm
Reset Everything
rm -rf node_modules .next prisma/dev.db
npm install
npm run db:push
npm run dev:full

πŸš€ Deployment

Vercel (Web Application)

  1. Connect repository to Vercel
  2. Set environment variables
  3. Use Vercel Postgres or Neon for database
  4. Deploy WebSocket server separately (AWS ECS, Cloud Run, or Render)

Docker

FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
RUN npm run build
EXPOSE 3000
CMD ["npm", "start"]
docker build -t sentiment-app .
docker run -p 3000:3000 sentiment-app

πŸ“‹ Quick Reference

Common Commands

# Development
npm run dev:full     # Start all services
npm run dev          # Next.js only
npm run websocket    # WebSocket only

# Database
npm run db:push      # Apply schema
npm run db:studio    # Visual editor

# Code Quality
npm run lint         # Check linting
npm run lint:fix     # Fix issues
npm run typecheck    # Type checking
npm run format:write # Format code

# Production
npm run build        # Build app
npm run start        # Start production

Port Reference

Service Port URL
Next.js 3000 http://localhost:3000
WebSocket 8080 ws://localhost:8080
Python API 8001 http://localhost:8001
Prisma Studio 5555 http://localhost:5555

Project Structure

sentiment-analysis/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ api/              # API routes
β”‚   β”‚   β”œβ”€β”€ dashboard/        # Main dashboard
β”‚   β”‚   β”œβ”€β”€ live-detection/   # Live emotion capture
β”‚   β”‚   β”œβ”€β”€ live-results/     # Live analysis results
β”‚   β”‚   └── pdf-analysis/     # Document analysis
β”‚   β”œβ”€β”€ components/           # React components
β”‚   β”‚   β”œβ”€β”€ LiveEmotionCapture.tsx
β”‚   β”‚   β”œβ”€β”€ PdfAnalysisCapture.tsx
β”‚   β”‚   β”œβ”€β”€ PdfAnalysisResults.tsx
β”‚   β”‚   └── AnalysisResultsModal.tsx
β”‚   β”œβ”€β”€ lib/
β”‚   β”‚   β”œβ”€β”€ quota.ts          # Quota management
β”‚   β”‚   └── stripe.ts         # Stripe config
β”‚   β”œβ”€β”€ server/
β”‚   β”‚   β”œβ”€β”€ auth/             # NextAuth config
β”‚   β”‚   └── websocket/        # Live analysis server
β”‚   └── sections/             # Landing page sections
β”œβ”€β”€ pdf-analyzer-service/     # Python FastAPI backend
β”‚   β”œβ”€β”€ main.py               # API & ML models
β”‚   β”œβ”€β”€ requirements.txt
β”‚   └── setup.sh
β”œβ”€β”€ prisma/
β”‚   └── schema.prisma         # Database schema
└── package.json

πŸ›£οΈ Roadmap

  • Modern dashboard UI
  • Live emotion detection
  • PDF/Excel sentiment analysis
  • Word cloud generation
  • Summary generation
  • Named entity recognition
  • Quota & billing system
  • API key management
  • Mobile app (React Native)
  • GraphQL API
  • Multi-language support
  • Video conference integration
  • Batch processing queue
  • Advanced analytics dashboard

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feat/amazing-feature
  3. Commit changes: git commit -m "feat: add amazing feature"
  4. Run checks: npm run check
  5. Submit a pull request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ“ž Support


Made with ❀️ by Utkarsh Khajuria

A comprehensive AI solution for analyzing stakeholder feedback, public consultations, and multimodal sentiment detection.

About

Full Working Sentiment Analysis Workflow with Live Website

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published