How aarayann/catch-bait works
1. Repository shape
- This repo is split into three clear boundaries: data extraction, model training, and serving.
- The pipeline is mostly offline/batch until the final app/ folder, which is the only user-facing runtime.
2. Data acquisition boundary: dataset_extraction/
- This is the ETL layer that builds the supervised dataset from YouTube.
- It interacts with external YouTube sources to collect video metadata, thumbnails, transcripts, and channel/video manifests.
- The reusable logic lives in dataset_extraction/clickbait_pipeline/, with modules for API access, transcript fetching, thumbnail handling, JSONL I/O, schema definitions, and summaries.
3. Extraction workflow
- The numbered scripts 01_... through 09_... show the intended end-to-end flow:
1. collect videos,
2. download thumbnails,
3. fetch transcripts,
4. generate heuristic auto-labels,
5. merge labels,
6. assemble a complete dataset,
7. export CSV,
8. balance the dataset,
9. package it for portable use.
- This makes the pipeline a staged batch job rather than a single monolithic ETL script.
4. Labeling and human-in-the-loop curation
- The repo supports both automatic heuristics and manual validation.
- dataset_extraction/scripts/label_ui_streamlit.py indicates a local Streamlit-based labeling interface used to review ambiguous samples.
- dataset_extraction/data/manual_labels.jsonl is the explicit human-labeled ground truth source that gets merged into the final dataset.
5. Configuration and external dependencies for extraction
- dataset_extraction/.env.example and clickbait_pipeline/env.py suggest the extraction stage depends on environment-provided secrets or API configuration.
- dataset_extraction/config/channels.csv is a curated list of source channels, which acts as the starting scope for collection.
- This implies the extraction pipeline is configured around a fixed channel set rather than open-ended crawling.
6. Dataset contract
- clickbait_pipeline/schema.py and feature_config.json indicate the project has a defined feature/label schema.
- jsonl.py, manifest.py, and summary.py suggest structured intermediate artifacts and dataset summaries are first-class outputs.
- The architecture likely depends on a stable tabular contract so training and serving can share the same feature interpretation.
7. Training boundary: training/
- Training is centered in a single notebook: training/click_bait.ipynb.
- That notebook likely performs EDA, feature engineering, train/test splitting, model fitting, and evaluation in one exploratory workflow.
- This is an analysis-and-model-building stage, not an online service.
8. Model artifact
- The trained model is serialized as app/src/clickbait_xgb_v1.pkl, which implies the chosen estimator is XGBoost or an XGBoost-based pipeline.
- The notebook produces the artifact that is later consumed by the app; there is no separate model server layer.
9. Serving boundary: app/
- app/src/streamlit_app.py is the runtime entry point for inference.
- The app loads the serialized model plus feature_config.json, then exposes an interactive Streamlit UI for predictions.
- This is a lightweight serving layer, not a REST API or containerized microservice in the repo structure.
10. Runtime inference flow
- The serving app appears to take a YouTube link or similar input, derive features at runtime, and feed them into the loaded model.
- The important architectural boundary is that feature extraction at inference time must match training-time feature definitions.
- That shared contract is enforced by the fixed config/artifact pair in app/src/.
11. Artifact handoff between phases
- The main data flow is: YouTube sources → extracted/cleaned dataset → trained model artifact → Streamlit inference app.
- Intermediate outputs are likely CSV/JSONL-based, while the final model output is a pickle file for direct loading.
- The repo therefore encodes a classic ML lifecycle: collection, labeling, training, packaging, serving.
12. Technologies that materially shape the architecture
- Streamlit is used both for labeling support and for end-user inference UI.
- Jupyter Notebook is the training environment.
- YouTube APIs are the external data source.
- The model artifact format is pickle, which keeps deployment simple but couples serving to the exact Python/model environment.
13. How to draw the architecture
- Draw three main boxes: Extraction, Training, Serving.
- Put YouTube APIs / transcripts / thumbnails outside the repo feeding into Extraction.
- Show manual labeling as a human-in-the-loop branch inside Extraction.
- Show training notebook consuming the curated dataset and producing the pickled model.
- Show Streamlit app consuming the model and feature config to produce predictions for users.
Main entry points: 01_collect_videos.py Batch pipeline · 05_merge_labels.py Label merge · streamlit_app.py Streamlit app · yt_api.py YouTube API
Components 17
External sources
Inputs and human actors outside the repository.
- YouTube · Video metadata, thumbnails, transcripts, and channel/video manifests.
- Reviewer · Manually validates ambiguous samples and supplies ground truth labels.
- User · Interacts with the Streamlit app to request predictions.
Extraction
Offline ETL that builds the supervised dataset from YouTube.
- Channel list · Curated source-channel input that defines collection scope.
dataset_extraction/config/channels.csv - YouTube API · API access and source retrieval for video/channel metadata.
dataset_extraction/clickbait_pipeline/yt_api.py - Transcripts · Transcript fetching and normalization.
dataset_extraction/clickbait_pipeline/transcripts.py - Thumbnails · Thumbnail download and handling.
dataset_extraction/clickbait_pipeline/thumbs.py - Dataset contract · Schema, JSONL, manifests, and summaries used by all dataset stages.
dataset_extraction/clickbait_pipeline/schema.py - Label merge · Combines heuristic auto-labels with manual labels into the final supervision set.
dataset_extraction/scripts/05_merge_labels.py - Batch pipeline · Staged scripts that collect, enrich, assemble, export, balance, and package the dataset.
dataset_extraction/scripts/01_collect_videos.py - Label UI · Local Streamlit interface for reviewing and labeling ambiguous samples.
dataset_extraction/scripts/label_ui_streamlit.py - Manual labels · Human-authored JSONL labels merged into the dataset.
dataset_extraction/data/manual_labels.jsonl - Curated dataset · Completed, balanced, and portable training dataset exported from the ETL flow.
dataset_extraction/scripts/09_make_portable_package.py
Training
Notebook-driven model development and artifact production.
- Training notebook · EDA, feature engineering, model fitting, and evaluation workflow.
training/click_bait.ipynb - Model artifact · Serialized XGBoost-based model consumed by the app.
app/src/clickbait_xgb_v1.pkl
Serving
Streamlit inference app for end users.
- Feature config · Shared feature definition used to align training and inference.
app/src/feature_config.json - Streamlit app · User-facing runtime that loads the model and produces predictions.
app/src/streamlit_app.py
Connections 18
- YouTube → YouTube API: metadata · Fetch video and channel metadata from external sources.
- YouTube → Transcripts: transcripts · Pull transcript content for candidate videos.
- YouTube → Thumbnails: thumbnails · Download thumbnail assets for each video.
- Channel list → Batch pipeline: scope · Defines the initial channel set for collection.
- YouTube API → Batch pipeline: ingest · Feeds collected metadata into the staged ETL workflow.
- Transcripts → Batch pipeline: enrich · Adds transcript data during dataset assembly.
- Thumbnails → Batch pipeline: enrich · Adds thumbnail assets during dataset assembly.
- Dataset contract → Batch pipeline: shape · Provides schema, manifests, and summaries for intermediate outputs.
- Batch pipeline → Label merge: stage · Produces auto-labeled records that are later merged with human labels.
- Reviewer → Label UI: review · Uses the Streamlit labeling interface to curate ambiguous samples.
- Label UI → Manual labels: write · Saves explicit manual labels as JSONL ground truth.
- Manual labels → Label merge: merge · Combines human labels with heuristic labels.
- Label merge → Curated dataset: build · Outputs the final curated dataset package.
- Curated dataset → Training notebook: train · Serves as the training data input for the notebook workflow.
- Training notebook → Model artifact: serialize · Produces the pickled model artifact after training and evaluation.
- Model artifact → Streamlit app: load · Loaded by the inference app at runtime.
- Feature config → Streamlit app: align · Keeps inference features consistent with training definitions.
- User → Streamlit app: predict · Submits inputs for interactive inference.