Emotube fetches YouTube video metadata and top-level comments through the YouTube Data API, classifies comments with a pretrained Hugging Face sentiment model, and stores the results in PostgreSQL. A React interface displays video details, comment filters, and sentiment charts. YouTube is the only implemented platform; replies within comment threads are not fetched.
- π― Sentiment Classification - Positive, neutral, negative, and ambiguous labels with model scores
- π Charts - Sentiment counts over time with date-range selection
- π³ Docker Compose - Frontend, backend, and database services for local development
- β‘ Background Analysis - Comment fetching and classification through FastAPI background tasks; the frontend polls every 3 seconds
- π Comment Filters - Sentiment, author, minimum likes, text search, and sorting
- π Video Metrics - View, like, and comment counts plus derived engagement statistics
- π¨ Interface - React components styled with Tailwind CSS and ShadCN/UI
- π Charts - Sentiment visualization with Recharts
- π Filters - Comment filtering and sorting
- β‘ Progress Display - Periodic polling of analysis status
- π Theme Support - A theme provider with dark mode as the default
Docker Compose runs a React frontend, a FastAPI backend, and PostgreSQL. Analysis runs inside the backend process; there is no separate worker service or durable job queue.
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
- π Python 3.11 with FastAPI - API routes and background tasks
- π€ Transformers & PyTorch - Pretrained sentiment classifier
- ποΈ PostgreSQL + SQLModel - Database models and async sessions
- π‘ Google API Client - YouTube Data API integration
- β‘ Uvicorn - ASGI server with auto-reload
- βοΈ React 19 with TypeScript - Frontend components
- π¦ Bun - JavaScript runtime and package manager
- π§ TanStack Router - Type-safe routing with devtools
- π TanStack Query - API queries and polling
- π¨ Tailwind CSS - Utility-first styling framework
- π§© ShadCN/UI - UI components
- π Recharts - Responsive data visualization
- β‘ Vite - Development server and build tool
- π³ Docker & Docker Compose - Local service configuration
- π§ Environment Variables - API key, database connection, and service URLs
- π CORS-enabled API - Cross-origin resource sharing
- π Auto-generated API Docs - Interactive Swagger/OpenAPI
- π³ Docker and Docker Compose
- π YouTube Data API v3 Key (Get one here)
- Network access for dependencies, initial model downloads, and YouTube API requests; comment fetching uses your API quota.
git clone https://github.com/00200200/youtube-comment-sentiment-analyzer
cd youtube-comment-sentiment-analyzer# Copy environment template
cp .env.example .env
# Edit .env file with your configuration
nano .env # or use your preferred editorRequired 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
DATABASE_URL=postgresql+asyncpg://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}
# Frontend Configuration
VITE_BACKEND_URL=http://localhost:8000# Start all services
docker-compose up -d
# View logs (optional)
docker-compose logs -f- π Frontend: http://localhost:3000
- β‘ Backend API: http://localhost:8000
- π API Docs: http://localhost:8000/docs
- ποΈ Database:
localhost:5432
The supplied Compose setup uses Vite's development server, Uvicorn auto-reload, source mounts, and published database/API ports. The API has no authentication and allows all CORS origins. Treat this as a local development setup, not a production deployment template. Initial backend startup may take time to download and load the model.
- π± Navigate to the frontend application
- π Enter a YouTube video URL
- β‘ Watch analysis status update through periodic polling
- π Explore interactive charts and comment insights
- π Filter comments by sentiment, author, or keywords
- π View sentiment counts over time and video engagement metrics
GET /videos- List analyzed videos (paginated)GET /videos?url={youtube_url}- Analyze new video or get existing analysis
GET /comments?url={youtube_url}- Get stored comments with filtering:sentiment- Filter by sentiment (positive/negative/neutral/ambiguous)author- Filter by author namemin_likes- Minimum like countphrase- Text search within commentssort_by- Sort field (for example,published_at,like_count, orsentiment_label)sort_order- asc/desc
GET /chart-data?url={youtube_url}- Get visualization data
The only integration is backend/app/core/integrations/youtube/.
The routes, URL parsing, data models, and frontend are built around YouTube videos.
Supporting another platform would require implementation and testing across those parts of the application.
This setup requires Python 3.11 and Bun. Configure the root .env first. For processes outside Docker, use
localhost in DATABASE_URL instead of the Compose hostname db. The example below
uses the credentials shown above; replace them with your configured values.
# Backend development, from the repository root
docker-compose up -d db
cd backend
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt
DATABASE_URL=postgresql+asyncpg://emotube_user:secure_password_here@localhost:5432/emotube_db \
uvicorn app.main:app --reload --env-file ../.env
# Frontend development, in a separate terminal from the repository root
cd frontend
bun install
VITE_BACKEND_URL=http://localhost:8000 bun run start# 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# 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- π€ Model -
cardiffnlp/twitter-xlm-roberta-base-sentiment, configured inconfig.py - π― Scores - Stores the model's predicted label and score; scores below
0.6are labeledambiguous - π Processing - Fetches pages of top-level comments, then classifies and saves comments individually
- π Input Limit - Model inputs are truncated to 512 tokens
- π Timeline - Area charts of comment counts by sentiment and publication date
- π Comment View - Filtered comments, model scores, and sentiment totals
- π Video Details - Counts and derived engagement metrics; no word clouds or dislike-correlation analysis are implemented
- Analysis is an on-demand background pass, not a stream of new YouTube comments. Polling refreshes stored results and status.
- Model scores are predictions, not verified measurements of a commenter's intent. The repository does not report a sentiment-accuracy evaluation on YouTube comments.
- API availability, quota, comment volume, and local inference speed affect completion time. This project does not provide a real-time latency guarantee.





