How garvitsh003/bhajan-marg-ai works
Bhajan Marg AI is a transcript-grounded devotional chatbot with a growing YouTube corpus. Its main workflow serves a chat request, uses conversation history to rewrite the question, searches and judges fresh transcript evidence, then returns an explanation with timestamped source cards. A separate ingestion workflow discovers videos, obtains transcripts, chunks and indexes them, while SQLite tracks corpus and conversation state. The README also documents optional cloud providers and periodic LoRA style training. Some subsystem links are omitted where the sampled excerpts do not show the runtime call.
Main entry points: llm.py Query and LLM · main.py Chat API · ingest.py Ingestion workflow · retrieval.py Evidence retrieval
Components 24
Chat and answers
- Chat interface
app/static/app.js - Chat API
app/main.py - Query and LLM
app/llm.py - Answer policy
app/answer_policy.py - Answer synthesis
app/synthesis.py
Retrieval and indexing
- Evidence retrieval
app/retrieval.py - Search dispatch
app/search_backend.py - Local hybrid search
app/vector_store.py - Cloud hybrid search
app/cloud_vector_store.py - Text processing
app/text.py
Corpus ingestion
- Transcript chunking
app/chunking.py - Ingestion workflow
app/ingest.py - Video transcripts
app/youtube.py - Daily updater
app/scheduler.py
Storage and providers
- Corpus and chat DB
app/db.py - Qdrant vector store
- Ollama service
- Gemini service
- Gemini adapter
app/cloud_llm.py - Request deadlines
app/budget.py
Optional style learning
- Style dataset builder
training/build_style_dataset.py - LoRA training
training/train_lora.py
Other components
- Chat user
- YouTube
Connections 32
- Chat user → Chat interface: uses
README.md - Chat API → Chat interface: serves
app/main.py - Chat API → Corpus and chat DB: loads and saves
app/main.py - Chat API → Query and LLM: rewrites query
app/main.py - Chat API → Evidence retrieval: requests evidence
app/main.py - Chat API → Daily updater: starts scheduler
app/main.py - Chat API → Ingestion workflow: queues update
app/main.py - Query and LLM → Answer policy: uses policy
app/answer_policy.py - Query and LLM → Ollama service: sends chat
app/llm.py - Query and LLM → Gemini adapter: delegates cloud calls
app/llm.py - Gemini adapter → Gemini service: sends prompts
app/cloud_llm.py - Query and LLM → Request deadlines: checks deadlines
app/llm.py - Evidence retrieval → Search dispatch: searches and reranks
app/retrieval.py - Evidence retrieval → Query and LLM: judges evidence
app/retrieval.py - Evidence retrieval → Corpus and chat DB: loads context
app/retrieval.py - Search dispatch → Local hybrid search: dispatches local
app/search_backend.py - Search dispatch → Cloud hybrid search: dispatches cloud
app/search_backend.py - Local hybrid search → Qdrant vector store: queries and indexes
app/vector_store.py - Local hybrid search → Text processing: builds lexical vectors
app/vector_store.py - Cloud hybrid search → Qdrant vector store: queries cloud index
app/cloud_vector_store.py - Ingestion workflow → Video transcripts: gets video transcripts
app/ingest.py - Ingestion workflow → Transcript chunking: chunks transcript
app/ingest.py - Transcript chunking → Text processing: normalizes text
app/chunking.py - Ingestion workflow → Corpus and chat DB: records corpus state
app/ingest.py - Ingestion workflow → Local hybrid search: indexes chunks
app/ingest.py - Video transcripts → YouTube: retrieves videos
- Daily updater → Ingestion workflow: runs updates
app/scheduler.py - Style dataset builder → Corpus and chat DB: reads corpus
training/build_style_dataset.py - Style dataset builder → Query and LLM: builds examples
training/build_style_dataset.py - Style dataset builder → LoRA training: provides reviewed data
- Answer synthesis → Gemini adapter: uses provider
app/synthesis.py - Answer synthesis → Search dispatch: uses search backend
app/synthesis.py