Backend ingestion engine for the link discovery game. This system extracts content from URLs (YouTube videos and websites), generates vector embeddings, and stores them in a Supabase database for similarity-based link discovery.
- YouTube Content Extraction: Automatically extracts video title, channel name, and auto-generated captions/transcripts
- Website Content Extraction: Extracts OpenGraph metadata and main body text (filtering out nav, ads, etc.)
- Vector Embeddings: Converts text content into 384-dimensional vectors using
all-MiniLM-L6-v2model - Supabase Integration: Stores links with vector embeddings for fast similarity search using pgvector
pip install -r requirements.txt- Create a new project at supabase.com
- Go to the SQL Editor in your Supabase dashboard
- Run the SQL schema from
schema.sql
-
Copy
.env.exampleto.env:cp .env.example .env
-
Edit
.envand add your Supabase credentials:SUPABASE_URL: Found in Project Settings > APISUPABASE_KEY: Use theanonpublic key from Project Settings > API
Run the main processing script:
python process_urls.pyThis will:
- Read URLs from
test_urls.txt - Extract content from each URL
- Generate vector embeddings
- Store everything in your Supabase database
from ingest import extract_content, vectorize
# Extract content from any URL
content = extract_content("https://www.example.com")
print(f"Title: {content['title']}")
print(f"Text: {content['text_content'][:200]}...")
# Generate vector embedding
vector = vectorize(content['text_content'])
print(f"Vector dimensions: {len(vector)}") # Should be 384from ingest import extract_content
# Extract from YouTube video
content = extract_content("https://www.youtube.com/watch?v=dQw4w9WgXcQ")
print(f"Title: {content['title']}")
print(f"Channel: {content['metadata']['channel_name']}")
print(f"Transcript: {content['text_content'][:500]}...")linksite/
├── schema.sql # Supabase database schema
├── ingest.py # Core content extraction and vectorization module
├── process_urls.py # Main script to process URLs from file
├── test_urls.txt # Sample URLs for testing
├── requirements.txt # Python dependencies
├── .env.example # Environment variables template
└── README.md # This file
The links table includes:
id: Auto-incrementing primary keyurl: Unique URL (text)title: Extracted titlemeta_json: JSONB field storing metadata (og:image, channel_name, type, etc.)content_vector: 384-dimensional vector embedding (pgvector)comment_vector: 384-dimensional vector for averaged user commentscreated_at: Timestampupdated_at: Auto-updated timestamp
Edit test_urls.txt and add one URL per line:
https://www.youtube.com/watch?v=example
https://interesting-blog.com/article
https://news.ycombinator.com/
Lines starting with # are treated as comments.
After populating your database with links, you'll need to:
- Create the
LinkCompassclass for finding related links - Implement the 5-slot system (Deep Dive, Pivot, Wildcard)
- Add comment vectorization for user feedback
See PROJECT_BRIEF.md for the full roadmap.
Make sure you've created a .env file with valid SUPABASE_URL and SUPABASE_KEY
Some YouTube videos may have restricted captions or may be unavailable. The script will fall back to the video description if captions aren't available.
Some websites heavily rely on JavaScript to render content. The current implementation uses static HTML parsing, so JavaScript-heavy sites may not extract well.
The all-MiniLM-L6-v2 model produces 384-dimensional vectors. Make sure your database schema uses vector(384).
- beautifulsoup4: HTML parsing
- yt-dlp: YouTube content extraction
- sentence-transformers: Vector embeddings
- supabase: Database client
- pgvector: PostgreSQL vector similarity search