How sidhant-1299/youtube-sentiment-analysis works
Project type and purpose
• This is a full-stack machine-learning–powered Chrome extension.
• Frontend: a YouTube plugin (JavaScript/HTML) that scrapes comments and displays sentiment results.
• Backend: a Dockerized Flask API serving a pretrained LightGBM sentiment model.
• Data/ML pipeline: implemented in src/ plus Jupyter notebooks and managed with DVC.
File structure
• Top level
• Dockerfile, .dockerignore: containerize the Flask API
• dvc.yaml, dvc.lock, .dvc/: version-control for datasets/models
• flask-requirements.txt, pyproject.toml: Python dependencies
• Frontend
• yt-chrome-plugin-frontend/: manifest.json, popup.js/html
• Backend API
• flask_api/app.py: Flask routes for /predict
• lgbm_model.pkl, tfidf_vectorizer.pkl: serialized model artifacts
• ML pipeline
• src/data: ingestion & preprocessing
• src/model: building, evaluation, registration
• src/config: parameter/config management
• notebooks/: exploratory experiments
• Lock files (uv.lock) ensure reproducible dev environment.
README
• Describes workflow: extension fetches comments → sends to Flask container (port 5555) → returns sentiment data → extension renders interactive pie chart.
• Usage instructions for Docker build/run and extension developer mode.
Components & interactions
a. Main components
• User’s Chrome browser with YouTube page
• Chrome extension (popup + content script)
• External YouTube site (source of comments)
• Docker container hosting Flask API
• Flask application (REST endpoint)
• Model artifacts: TF-IDF vectorizer + LightGBM model
• (Optional/training) ML pipeline & DVC store
b. Relationships & data flow
1. User navigates to YouTube, extension content script scrapes visible comments.
2. Extension issues HTTP POST to Flask /predict with comment text.
3. Docker network routes request to Flask server.
4. Flask loads vectorizer & model, transforms text → model.predict → JSON response.
5. Extension receives sentiment scores & displays chart on YouTube page.
6. (Training path) Data ingestion → preprocessing → model training (src/data → src/model) → register new model via DVC & update lgbm_model.pkl.
c. Architectural patterns/design principles
• Separation of concerns: Browser plugin vs. backend inference service
• Containerization for environment consistency
• Version-controlled data/model pipeline (DVC)
• Config management under src/config for reproducible parameters
d. Key technologies/frameworks
• Chrome Extension APIs (manifest.json, content scripts)
• Flask (flask_api/app.py)
• Docker
• DVC for data/model versioning
• LightGBM + scikit-learn TF-IDF
• Python project tooling (pyproject.toml)