How younesameziane/local-rag works
This is a local, on-premises data-governance assistant. Users ask through the browser UI or terminal; chat maintains turn state, routes each question, retrieves catalog or document context, and generates read-only SQL when needed. Separate ingestion paths populate the two Qdrant collections. The graph follows documented workflows and sampled references; unsampled implementation details are not used to infer additional calls.
Main entry points: chat.py Turn coordinator · llm.py Local model client · sql_generator.py SQL generation and validation · retriever.py Catalog and document retrieval
Components 20
User interfaces
- Browser UI
webui.py - Terminal chat
chat.py
Conversation and routing
- Turn coordinator
chat.py - Conversation state
session.py - Question router
router.py - Local model client
llm.py - Runtime configuration
config.py
Knowledge retrieval
- Catalog and document retrieval
retriever.py - BM25 ranking
lexical.py - Qdrant vector store
SQL answering
- SQL generation and validation
sql_generator.py - Multi-step SQL planner
planner.py - Connection pool
db_pool.py - MetadataRepository
Knowledge ingestion
- Catalog ingestion
ingest.py - Document ingestion
ingest_docs.py - Document chunking
chunker.py - Document registry
doc_registry.py
Other components
- User
- Browser
Connections 29
- User → Browser UI: asks via
README.md - Browser → Browser UI: uses
README.md - User → Terminal chat: asks via
README.md - Browser UI → Turn coordinator: submits turns
README.md - Terminal chat → Turn coordinator: runs turns
README.md - Turn coordinator → Conversation state: uses state
chat.py - Turn coordinator → Question router: routes questions
chat.py - Turn coordinator → Catalog and document retrieval: retrieves context
chat.py - Turn coordinator → SQL generation and validation: runs SQL path
chat.py - Turn coordinator → Local model client: generates responses
chat.py - Question router → Local model client: classifies with
README.md - Catalog and document retrieval → Qdrant vector store: searches collections
README.md - Catalog and document retrieval → BM25 ranking: fuses rankings
retriever.py - Catalog and document retrieval → Local model client: rewrites queries
README.md - SQL generation and validation → Catalog and document retrieval: gets schema context
sql_generator.py - SQL generation and validation → Local model client: generates SQL
README.md - SQL generation and validation → Multi-step SQL planner: delegates enumeration
README.md - Multi-step SQL planner → Connection pool: checks out connection
planner.py - SQL generation and validation → Connection pool: checks out connection
sql_generator.py - Connection pool → MetadataRepository: opens connections
db_pool.py - Catalog ingestion → MetadataRepository: reads catalog
ingest.py - Catalog ingestion → Local model client: embeds chunks
ingest.py - Catalog ingestion → Qdrant vector store: upserts vectors
ingest.py - Document ingestion → Document chunking: chunks files
ingest_docs.py - Document ingestion → Local model client: embeds chunks
ingest_docs.py - Document ingestion → Qdrant vector store: upserts vectors
ingest_docs.py - Document ingestion → Document registry: tracks file state
ingest_docs.py - Runtime configuration → Local model client: configures clients
llm.py - Runtime configuration → Connection pool: sets pool size
db_pool.py