How 54g0/kriar-learning-assistant works
Project Type & Purpose
• This is a single-repository, Python‐based web application built with Streamlit.
• It delivers a context-aware AI learning assistant: you load a YouTube video, extract its transcript, pick a timestamp, and ask questions that the AI answers using that exact context.
High-Level Architecture Components
A. Frontend (UI)
• app.py (Streamlit application): defines pages (“Load Video,” “Q&A Chat,” “Code Assistant”), handles user inputs, session state, and displays results.
B. Core Business Logic
• context_extractor.py: fetches YouTube transcripts, slices them by timestamp.
• agent.py: orchestrates a LangGraph workflow—pulls context, reformulates the user’s query, invokes the model, post-processes results.
• model.py: adapter layer for AI providers (OpenAI, Groq, Google AI), exposes a uniform interface for chat/completion calls.
• tools.py: auxiliary toolset (e.g., Wikipedia search) that the agent can invoke when needed.
C. External Services
• YouTube API (transcript source).
• AI Model Providers: OpenAI, Groq, Google AI APIs.
• Wikipedia API (via tools.py).
D. Session & Storage
• Streamlit’s in-memory session state holds video URLs, raw transcripts, selected timestamp, and chat history—no external database.
Key Interactions & Data Flows
1. User enters a YouTube URL → Frontend calls context_extractor → YouTube API → Transcript returned → stored in session state → UI confirms success.
2. User selects timestamp + asks a question → Frontend passes (query, timestamp) to agent → Agent fetches relevant transcript slice from session state via context_extractor → Agent sends “prompt + context” to model.py → model.py calls the chosen AI provider → Response flows back to agent → UI.
3. In “Code Assistant,” the UI sends raw code snippet + instruction to agent → agent invokes model.py directly (and optionally tools.py) → answer displayed.
Architectural Patterns & Design Principles
• Adapter Pattern (model.py abstracts multiple AI backends).
• Orchestration Pattern (agent.py organizes the workflow steps using LangGraph).
• Separation of Concerns: UI (app.py) vs. Context Extraction vs. Model Invocation vs. External Tools.
• Plugin/Extension Points:
• A new AI provider by extending model.py.
• New toolbox routines in tools.py.
Essential Elements Checklist
[ ] Clear, descriptive labels on each component
[ ] Flow numbering for major use cases