Skip to content

00200200/youtube-comment-sentiment-analyzer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

36 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🎭 Emotube: Advanced Social Media Sentiment Analyzer

Emotube Banner

A powerful, containerized web application for analyzing sentiment in social media comments

FastAPI React TypeScript Docker PostgreSQL


🌟 Overview

Emotube is a cutting-edge sentiment analysis platform that transforms social media engagement data into actionable insights. Currently featuring YouTube comment analysis, the platform is designed with extensibility in mind to support multiple social media platforms including Facebook, Reddit, Twitter, Instagram, and TikTok.

✨ Key Features

  • 🎯 Real-time Sentiment Analysis - Advanced ML-powered sentiment classification
  • πŸ“Š Interactive Dashboards - Beautiful, responsive data visualizations
  • 🐳 Dockerized Architecture - Full containerization for easy deployment
  • ⚑ Async Processing - Background comment analysis with live progress updates
  • πŸ” Advanced Filtering - Filter by sentiment, author, engagement metrics, and keywords
  • πŸ“ˆ Comprehensive Analytics - Detailed metrics and trend analysis
  • 🌐 Multi-platform Ready - Extensible architecture for additional social media platforms

πŸ–₯️ User Interface Showcase

🏠 Home Page & Video Analysis

Landing Page with Clean, Modern Design Home Page

YouTube URL Input and Analysis Initiation Video URL Query

πŸ’¬ Comment Analysis Interface

Comprehensive Video Information Display Video Header

Interactive Sentiment Analysis Charts Sentiment Charts

Advanced Chart Filtering with Time Period Selection Chart Period Filtering

Detailed Comment Sentiment Analysis with Advanced Filtering Comments Analysis

✨ Key UI Features

  • 🎨 Modern Design - Clean, responsive interface built with Tailwind CSS and ShadCN/UI
  • πŸ“Š Interactive Charts - Real-time sentiment visualization with Recharts
  • πŸ” Advanced Filtering - Multi-criteria comment filtering and sorting
  • ⚑ Real-time Updates - Live progress tracking during analysis
  • πŸ“± Responsive Layout - Optimized for desktop and mobile devices
  • πŸŒ™ Dark Mode Ready - Consistent theming across all components

πŸ—οΈ Architecture

The project follows a modern microservices architecture with complete Docker containerization:

Emotube/
β”œβ”€β”€ 🐳 docker-compose.yml           # Multi-service orchestration
β”œβ”€β”€ πŸ”§ .env.example                 # Environment configuration template
β”œβ”€β”€ 🌐 frontend/                    # React TypeScript Frontend
β”‚   β”œβ”€β”€ 🐳 Dockerfile               # Frontend container config
β”‚   β”œβ”€β”€ πŸ“¦ package.json             # Dependencies (Bun runtime)
β”‚   β”œβ”€β”€ βš™οΈ vite.config.js           # Build configuration
β”‚   └── πŸ“ src/
β”‚       β”œβ”€β”€ 🎨 components/          # React components
β”‚       β”‚   β”œβ”€β”€ ui/                 # ShadCN UI components
β”‚       β”‚   β”œβ”€β”€ VideoDetails.tsx    # Video metadata display
β”‚       β”‚   β”œβ”€β”€ CommentSection.tsx  # Comment analysis interface
β”‚       β”‚   β”œβ”€β”€ CommentCharts.tsx   # Data visualization charts
β”‚       β”‚   └── AnalyzedVideoList.tsx # Video history
β”‚       β”œβ”€β”€ 🚦 routes/              # TanStack Router pages
β”‚       β”œβ”€β”€ πŸ”— services/            # API service layer
β”‚       β”œβ”€β”€ 🎯 hooks/               # Custom React hooks
β”‚       └── πŸ“ types/               # TypeScript definitions
β”œβ”€β”€ ⚑ backend/                     # FastAPI Python Backend
β”‚   β”œβ”€β”€ 🐳 Dockerfile               # Backend container config
β”‚   β”œβ”€β”€ πŸ“‹ requirements.txt         # Python dependencies
β”‚   β”œβ”€β”€ πŸ“š overview.md              # Detailed backend documentation
β”‚   └── πŸ“ app/
β”‚       β”œβ”€β”€ πŸš€ main.py              # FastAPI application entry
β”‚       β”œβ”€β”€ 🌐 api/
β”‚       β”‚   β”œβ”€β”€ routes/             # API endpoints
β”‚       β”‚   β”‚   β”œβ”€β”€ videos.py       # Video analysis endpoints
β”‚       β”‚   β”‚   β”œβ”€β”€ comments.py     # Comment retrieval & filtering
β”‚       β”‚   β”‚   └── chart_data.py   # Analytics data endpoints
β”‚       β”‚   └── logic/              # Business logic layer
β”‚       β”œβ”€β”€ βš™οΈ core/
β”‚       β”‚   β”œβ”€β”€ config.py           # Application configuration
β”‚       β”‚   β”œβ”€β”€ sentiment/          # Sentiment analysis engine
β”‚       β”‚   └── integrations/       # Social media platform integrations
β”‚       β”‚       └── youtube/        # YouTube API integration
β”‚       β”œβ”€β”€ πŸ—„οΈ db/
β”‚       β”‚   β”œβ”€β”€ session.py          # Database session management
β”‚       β”‚   └── init_db.py          # Database initialization
β”‚       β”œβ”€β”€ πŸ“Š models/              # SQLModel database models
β”‚       β”œβ”€β”€ πŸ“ schemas/             # Pydantic API schemas
β”‚       β”œβ”€β”€ πŸ”§ crud/                # Database operations
β”‚       └── πŸ› οΈ utils/               # Utility functions
└── πŸ—„οΈ PostgreSQL Database         # Persistent data storage

πŸš€ Tech Stack

Backend

  • 🐍 Python 3.11 with FastAPI - High-performance async API framework
  • πŸ€– Transformers & PyTorch - Advanced sentiment analysis models
  • πŸ—„οΈ PostgreSQL + SQLModel - Robust database with async ORM
  • πŸ“‘ Google API Client - YouTube Data API integration
  • ⚑ Uvicorn - ASGI server with auto-reload

Frontend

  • βš›οΈ React 19 with TypeScript - Modern UI framework
  • πŸ¦„ Bun - Ultra-fast JavaScript runtime and package manager
  • 🧭 TanStack Router - Type-safe routing with devtools
  • πŸ”„ TanStack Query - Powerful async state management
  • 🎨 Tailwind CSS - Utility-first styling framework
  • 🧩 ShadCN/UI - Beautiful, accessible component library
  • πŸ“Š Recharts - Responsive data visualization
  • ⚑ Vite - Lightning-fast build tool

Infrastructure

  • 🐳 Docker & Docker Compose - Complete containerization
  • πŸ”’ Environment-based Configuration - Secure secrets management
  • 🌐 CORS-enabled API - Cross-origin resource sharing
  • πŸ“ Auto-generated API Docs - Interactive Swagger/OpenAPI

πŸš€ Quick Start

Prerequisites

  • 🐳 Docker and Docker Compose
  • πŸ”‘ YouTube Data API v3 Key (Get one here)

1. Clone the Repository

git clone https://github.com/00200200/youtube-comment-sentiment-analyzer
cd emotube

2. Environment Setup

# Copy environment template
cp .env.example .env

# Edit .env file with your configuration
nano .env  # or use your preferred editor

Required environment variables:

# YouTube API Configuration
YOUTUBE_API_KEY=your_youtube_api_key_here

# Service Configuration
HOST=0.0.0.0
BACKEND_PORT=8000
FRONTEND_PORT=3000

# Database Configuration
POSTGRES_USER=emotube_user
POSTGRES_PASSWORD=secure_password_here
POSTGRES_DB=emotube_db
POSTGRES_HOST=db
POSTGRES_PORT=5432

# Frontend Configuration
VITE_BACKEND_URL=http://localhost:8000

3. Launch with Docker

# Start all services
docker-compose up -d

# View logs (optional)
docker-compose logs -f

4. Access the Application


🎯 Usage

Analyzing YouTube Videos

  1. πŸ“± Navigate to the frontend application
  2. πŸ”— Enter a YouTube video URL
  3. ⚑ Watch real-time sentiment analysis progress
  4. πŸ“Š Explore interactive charts and comment insights
  5. πŸ” Filter comments by sentiment, author, or keywords
  6. πŸ“ˆ View comprehensive analytics and trends

API Endpoints

Videos

  • GET /videos - List analyzed videos (paginated)
  • GET /videos?url={youtube_url} - Analyze new video or get existing analysis

Comments

  • GET /comments?url={youtube_url} - Get comments with advanced filtering:
    • sentiment - Filter by sentiment (positive/negative/neutral)
    • author - Filter by author name
    • min_likes - Minimum like count
    • phrase - Text search within comments
    • sort_by - Sort field (published_at, like_count, sentiment)
    • sort_order - asc/desc

Analytics

  • GET /chart-data?url={youtube_url} - Get visualization data

🌐 Platform Extensibility

Emotube is architected for easy expansion to additional social media platforms:

πŸ”„ Currently Supported

  • πŸ“Ί YouTube - Complete comment sentiment analysis

πŸš€ Ready for Integration

The modular architecture supports adding:

  • πŸ“˜ Facebook - Posts and comment analysis
  • πŸ”΄ Reddit - Subreddit and thread sentiment
  • 🐦 Twitter/X - Tweet and reply analysis
  • πŸ“· Instagram - Comment sentiment on posts and reels
  • 🎡 TikTok - Video comment analysis
  • πŸ’Ό LinkedIn - Professional content engagement
  • πŸ“± Discord - Server message sentiment

πŸ› οΈ Adding New Platforms

  1. Create Integration Module:

    # backend/app/core/integrations/platform_name/
    β”œβ”€β”€ client.py          # Platform API client
    β”œβ”€β”€ models.py          # Platform-specific data models
    └── sentiment.py       # Platform-specific processing
  2. Extend API Routes:

    # Add new endpoints in backend/app/api/routes/
    @router.get("/platform_name/analyze")
    async def analyze_platform_content(url: str):
        # Implementation
  3. Update Frontend:

    // Add platform-specific components and services
    // Extend URL parsing and validation

πŸ› οΈ Development

Local Development Setup

# Backend development
cd backend
python -m venv venv
source venv/bin/activate  # Windows: venv\Scripts\activate
pip install -r requirements.txt
uvicorn app.main:app --reload

# Frontend development
cd frontend
bun install
bun run start

Docker Development

# Rebuild and restart services
docker-compose down
docker-compose up --build

# View service logs
docker-compose logs backend
docker-compose logs frontend
docker-compose logs db

Database Management

# Access PostgreSQL
docker-compose exec db psql -U emotube_user -d emotube_db

# Backup database
docker-compose exec db pg_dump -U emotube_user emotube_db > backup.sql

# View database logs
docker-compose logs db

πŸ“Š Features Deep Dive

Sentiment Analysis Engine

  • πŸ€– Multi-model Support - Hugging Face Transformers integration
  • ⚑ Async Processing - Background analysis with progress tracking
  • 🎯 Confidence Scoring - Sentiment confidence metrics
  • πŸ”„ Batch Processing - Efficient comment processing in chunks

Data Visualization

  • πŸ“ˆ Sentiment Distribution - Pie charts and bar graphs
  • πŸ“Š Timeline Analysis - Sentiment trends over time
  • πŸ”₯ Engagement Metrics - Like/dislike correlation analysis
  • ☁️ Word Clouds - Popular terms and phrases

Performance Features

  • ⚑ Lazy Loading - Progressive data loading
  • πŸ”„ Real-time Updates - Live analysis progress
  • πŸ’Ύ Persistent Storage - PostgreSQL with proper indexing
  • πŸš€ Caching Strategy - Optimized data retrieval

Releases

No releases published

Packages

 
 
 

Contributors