How ashvinbari/youtube_agent works
What this project is (type + purpose)
This is a single-service, UI-driven Streamlit application (Python) that acts as an “AI agent” to recommend the best YouTube tutorials for a user-provided topic and difficulty level. The app’s core capability is delegated to the Tavily API (external search/content extraction). The UI renders a “best pick” plus additional recommendations, including thumbnails and links that ultimately route users to YouTube.
Given the tiny file tree (app.py, requirements.txt, README.md), the architecture is intentionally simple: one Streamlit container + external API dependencies.
How to read the file structure into architecture
From the file tree:
• app.py → All application logic and UI live here (input handling, calling Tavily, ranking/selection, rendering results).
• requirements.txt → Defines runtime dependencies (Streamlit, Tavily client/requests, etc.). This maps to the runtime container and external libs.
• A single UI+backend combined Streamlit service (not separate frontend/backend).
• External services: Tavily API (mandatory), YouTube (destination links + thumbnails/metadata source depending on how Tavily returns results).
Streamlit Server (Python runtime)
• “UI Layer” (Streamlit widgets/pages)
• “Agent/Recommendation Logic” (query building, filtering, picking best)
• “Integration Layer” (Tavily API client / HTTP requests)
YouTube (External)
• Mostly a link-out target; optionally the “content source” behind Tavily search results.
Secrets/Config Source
• Environment variables / Streamlit secrets (recommended) vs hardcoded key (current)
Deployment Environment
• Logging, error handling, rate-limit handling (even if minimal)
User → Browser → Streamlit App
• Inputs: topic, difficulty level, “Find Best Video” action
Streamlit App → Tavily API
• Outbound HTTPS request containing search query and parameters (and API key)
Tavily API → Streamlit App
• Response: list of candidate results (titles, URLs, snippets/metadata; possibly thumbnails if returned)
Streamlit App (internal)
• Ranking/selection: choose “best pick” (e.g., highest view / most relevant)
• Prepare “additional recommendations”
Streamlit App → Browser
• Render: thumbnail, title, description, “Watch Video” links
Browser → YouTube
• When user clicks a recommendation, they navigate to YouTube
• Streamlit App → Secrets/Env
• *(Optional)* Streamlit App ↔ Cache
Architectural pattern to highlight
• “Thin UI + orchestration service”: Streamlit is both presentation and controller/orchestrator.
• External-API-centric: core intelligence/search is delegated to Tavily; the app is an integration + ranking + visualization layer.
• Where the key should live (env var / Streamlit secrets)
• That the Streamlit server is the one holding the secret (not the browser)
An annotation near Tavily:
• “Rate limits / latency / failure modes” (just a note) to justify potential caching/retry logic.
Final “don’t overthink it” checklist (specific to this repo)
• Treat Streamlit as both frontend and backend.
• Always show Tavily as the core external dependency.
• YouTube as link-out destination (and implied content source).
• Secrets/Env explicitly due to the README warning.