How skandharaj1307/hybridrag works
Purpose and Entry Points
This repository implements a retrieval-augmented analysis pipeline over software-quality artifacts: structured metadata plus logs, screenshots/OCR, SRS PDFs, defects, reports, and test cases. Primary operational entry points are main.py, index_qdrant.py, query_pipeline.py, evaluate_retrieval.py, and sync_views.py.
Source Data and Parsing Boundary
Raw corpus material resides under dataset/structured and dataset/unstructured. Format-specific parsers normalize unstructured inputs before downstream chunking:
• Logs: parsers/log_parser.py, dataset/unstructured/failure_logs
• SRS PDF: parsers/pdf_parser.py, dataset/unstructured/srs/srs_document.pdf
• Screenshot/OCR data: parsers/screenshot_parser.py, dataset/unstructured/screenshots
• Structured records loaded from Supabase: parsers/supabase_loader.py
This separates source-specific extraction from retrieval-oriented document construction.
Content Chunking and Metadata
Artifact-specific chunkers convert parsed content into retrievable units, preserving the semantic structure appropriate to each source type:
• chunkers/log_chunker.py
• chunkers/srs_chunker.py
• chunkers/screenshot_chunker.py
• chunkers/defect_chunker.py
• chunkers/report_chunker.py
• chunkers/testcase_chunker.py
metadata/metadata_builder.py constructs metadata attached to chunks; utils/id_generator.py supports stable identifiers. The checked-in dataset/structured/metadata.json appears to be a structured metadata artifact.
Indexing and Vector Infrastructure
index_qdrant.py is the indexing stage that likely embeds chunks and writes them into Qdrant. Vector-store connection management is isolated in retrieval/qdrant_client_provider.py; Qdrant querying is implemented in retrieval/qdrant_retriever.py.
Embedding is an explicit abstraction in retrieval/embedder.py, keeping vector-model selection separate from parsing, chunking, and query orchestration. Qdrant is the material retrieval infrastructure dependency.
Hybrid Retrieval and Query Control
Retrieval combines lexical and vector search:
• BM25 path: retrieval/bm25_retriever.py
• Dense/Qdrant path: retrieval/qdrant_retriever.py
• Combination logic: retrieval/hybrid_retriever.py
• Query dispatch/routing: retrieval/query_router.py
query_pipeline.py is the principal query-time coordinator: it accepts a query, routes or retrieves relevant context, and passes that context to answer-generation or execution stages. evaluate_retrieval.py assesses retrieval quality, with question inputs available in vanilla_rag_questions.txt.
LLM and Structured-Query Boundary
llm/mistral_service.py provides the generative-model integration, making Mistral an external inference service/runtime dependency. llm/sql_executor.py establishes a distinct path for executing SQL, likely when a routed request requires structured data rather than—or alongside—document retrieval.
This boundary is important: retrieval provides grounded text context, while SQL execution accesses structured information through a controlled executor rather than directly from LLM output.
Supabase Data Layer and View Synchronization
Supabase is the structured-data backend. supabase/migrations/20260801221712_create_context_views.sql defines database context views, while sync_views.py synchronizes or materializes them for pipeline use. parsers/supabase_loader.py is the bridge from those database records into the corpus/indexing flow.
Runtime configuration is centralized in config/config.py. The project is Python-based, as indicated by pyproject.toml, requirements.txt, and .python-version.
Main entry points: hybrid_retriever.py Hybrid retriever · query_router.py Query router · log_chunker.py Artifact chunkers · metadata_builder.py Chunk metadata builder
Components 21
Corpus & Data
- Raw artifact corpus · Structured and unstructured quality artifacts.
dataset/unstructured - Metadata artifact
dataset/structured/metadata.json
Ingestion & Indexing
- Format parsers · Normalizes logs, PDFs, screenshots, and database records.
parsers/log_parser.py - Supabase loader · Bridges structured records into corpus ingestion.
parsers/supabase_loader.py - Artifact chunkers · Creates source-aware retrievable units.
chunkers/log_chunker.py - Chunk metadata builder
metadata/metadata_builder.py - Indexing entry point · Embeds and writes annotated chunks.
index_qdrant.py
Retrieval & Querying
- Embedder
retrieval/embedder.py - Qdrant client provider
retrieval/qdrant_client_provider.py - Qdrant · Persistent dense-vector retrieval infrastructure.
- BM25 retriever
retrieval/bm25_retriever.py - Qdrant retriever
retrieval/qdrant_retriever.py - Hybrid retriever · Combines lexical and dense results.
retrieval/hybrid_retriever.py - Query router · Selects retrieval or structured-query paths.
retrieval/query_router.py - Query pipeline · Coordinates routing, context retrieval, and response execution.
query_pipeline.py - Retrieval evaluation · Measures retrieval quality using question inputs.
evaluate_retrieval.py
Structured Data & LLM
- Mistral service · External generative inference boundary.
llm/mistral_service.py - SQL executor · Executes structured-data access separately from LLM generation.
llm/sql_executor.py - Supabase · Backend for operational structured records and context views.
- Context views
supabase/migrations/20260801221712_create_context_views.sql - View synchronization · Synchronizes or materializes context views.
sync_views.py
Connections 22
- Raw artifact corpus → Format parsers: extract
- Metadata artifact → Chunk metadata builder: supplies metadata
- Supabase → Supabase loader: loads records
- Format parsers → Artifact chunkers: normalized content
- Supabase loader → Artifact chunkers: structured records
- Artifact chunkers → Chunk metadata builder: chunks
- Chunk metadata builder → Indexing entry point: annotated chunks
- Indexing entry point → Embedder: embed chunks
- Embedder → Qdrant: vectors
- Qdrant client provider → Qdrant: connects
- Qdrant → Qdrant retriever: search index
- Qdrant client provider → Qdrant retriever: provides client
- BM25 retriever → Hybrid retriever: lexical results
- Qdrant retriever → Hybrid retriever: dense results
- Query pipeline → Query router: dispatch query
- Query router → Hybrid retriever: retrieval route
- Hybrid retriever → Mistral service: grounding context
- Query router → SQL executor: structured route
- SQL executor → Supabase: controlled queries
- Context views → Supabase: defined in
- View synchronization → Context views: synchronizes
- Retrieval evaluation → Hybrid retriever: evaluates