How andy-techen/better-social-media works
Project type and purpose
• This is a full-stack application combining a Chrome extension (frontend) with a Flask-based RESTful API (backend) that hosts pre-trained machine-learning models for text classification.
• Purpose: filter a user’s Twitter feed in real time for toxicity, profanity, depressiveness, and sexual explicitness by whiting out tweets whose predicted scores exceed user-adjustable thresholds.
File structure
• Top-level:
• dist/ – Compiled Chrome extension (HTML, CSS, JS, manifest.json, images)
• data/ModelAPI/ – Flask app code (api.py, Procfile, requirements.txt), model artifacts (pickled XGBoost models & TF-IDF vectorizers)
• data/GitBucketData/ & data/PerspectiveAPI/ – Jupyter notebooks and raw CSV datasets used for offline model training
• package.json & package-lock.json – frontend build/config (if using Node tooling)
• requirements.txt – Python dependencies (Flask, XGBoost, NLTK, etc.)
• Architectural pattern: clear separation of concerns—UI and client logic in the extension vs. ML inference/service layer in the Flask API.
Key insights from README
• The Chrome extension injects UI controls (sliders) into Twitter’s DOM, observes tweets via content scripts, and makes POST requests to two endpoints (/api/depressive and /api/toxicity-profane-sexually).
• The backend loads pickled TF-IDF vectorizers and XGBoost classifiers at startup and returns JSON scores.
• Models were trained offline in Jupyter notebooks on two datasets (self-annotated tweets & PerspectiveAPI-scored Reddit comments) and packaged into .pickle files.
Diagramming recommendations
• Use clear labels for each component (e.g., “Content Script,” “Flask Inference Engine”).
• UI → content script → background → API request
• API response → background → content script → UI updates
– Extension UI & scripts (e.g., blue)
– Backend service & artifacts (e.g., green)
• External dependencies (Heroku, Perspective API used offline).