Production-grade RAG system for YouTube videos with semantic chunking, contextual enrichment, and intelligent chat.
Phase 1 COMPLETE - All 6 containers operational
✅ Health endpoint | Whisper loaded | Embeddings (384-dim) | DB migrations | SSL resolved
Next: Phase 2 functional testing
👉 Quick Start: RESUME.md | Details: PROGRESS.md
Features:
- Per-conversation source control (include/exclude videos) with clickable citations that jump to the exact transcript segment.
- Ingest YouTube videos → extract audio transcripts (Whisper)
- Semantic chunking with contextual enrichment
- Chat with AI about video content with citations
- Persistent conversation history
Tech Stack:
- Backend: FastAPI, SQLAlchemy, Celery
- Database: PostgreSQL (pgvector), Redis, Qdrant
- ML: Whisper (transcription), sentence-transformers (embeddings)
- LLMs: DeepSeek/OpenAI/Anthropic
- Storage: Local (dev) → Azure Blob (prod)
| Service | Purpose | Key Features |
|---|---|---|
chunking.py |
Semantic text chunking | Token-aware (512t target), sentence boundaries, 80t overlap |
enrichment.py |
Contextual metadata | LLM-generated summaries, titles, keywords |
embeddings.py |
Vector embeddings | Multi-backend (local/OpenAI/Azure), batch processing, caching |
llm_providers.py |
LLM abstraction | DeepSeek/OpenAI/Anthropic, streaming, retry logic |
vector_store.py |
Qdrant integration | Cosine similarity, metadata filtering, batch indexing |
transcription.py |
Whisper STT | Multi-model support, timestamps, language detection |
youtube.py |
Video download | yt-dlp, audio extraction, metadata, chapters |
storage.py |
File storage | Local filesystem + Azure Blob interface |
Core Tables:
users- Accounts, subscription tiers, Stripe IDsvideos- Metadata, processing status, storage pathstranscripts- Full text, Whisper segments, timestampschunks- Semantic units, enrichment, embeddingsconversations- Chat sessions, selected videos, optional backing collectionmessages- User/assistant messages, LLM metadata, citationsmessage_chunk_references- Citation trackingconversation_sources- Per-conversation video list withis_selectedflag used to filter retrievalusage_events- Billable actions, quota trackinguser_quotas- Monthly limitsjobs- Background task tracking
YouTube URL → download_audio → transcribe (Whisper) → chunk (semantic)
→ enrich (LLM) → embed (vectors) → index (Qdrant) → ready for RAG
Status Flow:
pending → downloading → transcribing → chunking → enriching → indexing → completed
POST /api/v1/videos/ingest- Submit YouTube URLGET /api/v1/videos- List videos (paginated)GET /api/v1/videos/{id}- Video detailsDELETE /api/v1/videos/{id}- Soft delete
GET /api/v1/jobs/{job_id}- Job status/progress
POST /api/v1/conversations- Create chatGET /api/v1/conversations- List chatsGET /api/v1/conversations/{id}- Chat detailsPATCH /api/v1/conversations/{id}- Update (add/remove videos)DELETE /api/v1/conversations/{id}- DeletePOST /api/v1/conversations/{id}/messages- Send message (Phase 2)
Key settings in .env:
# Chunking
CHUNK_TARGET_TOKENS=512
CHUNK_OVERLAP_TOKENS=80
# Embeddings
EMBEDDING_PROVIDER=local # local, openai, azure
EMBEDDING_MODEL=sentence-transformers/all-MiniLM-L6-v2
EMBEDDING_DIMENSIONS=384
# LLM
LLM_PROVIDER=deepseek # deepseek, openai, anthropic
LLM_MODEL=deepseek-chat
# RAG
RETRIEVAL_TOP_K=10
ENABLE_RERANKING=False# Start services
docker-compose up -d
# Run migrations
docker-compose exec app alembic upgrade head
# Check health
curl http://localhost:8000/health# View logs
docker-compose logs -f app worker
# Create migration
docker-compose exec app alembic revision -m "description" --autogenerate
# Run tests
docker-compose exec app pytest
# Code formatting
docker-compose exec app black . && ruff .
# Run tests locally (venv)
python -m venv venv
venv\Scripts\activate
pip install -r backend/requirements.txt
set PYTHONPATH=backend # Powershell: $env:PYTHONPATH="backend"
pytest backend/tests/unitSee AGENTS.md for coding guidelines.
- Docker infrastructure (6 containers)
- Video ingestion pipeline
- Transcription, chunking, enrichment
- Vector indexing
- API endpoints (videos, jobs, conversations)
- Database migrations
- RAG chat implementation
- Streaming LLM responses
- Citation parsing
- Token budget management
- Usage tracking
- Frontend (Next.js)
- Authentication (JWT + OAuth)
- Stripe billing
- Admin dashboard
- Production deployment
- RESUME.md - Quick resume guide, commands, status
- PROGRESS.md - Recent changes, technical details
- AGENTS.md - Development guidelines, conventions
- API Docs: http://localhost:8000/docs (Swagger UI)
TBD