How stan-ely/lakehouse-rag works
lakehouse-rag is an access-controlled enterprise RAG service with a document lakehouse ingestion path and a FastAPI query path that combines hybrid document retrieval and guarded text-to-SQL. The principal workflow authenticates a caller, routes their question, runs the required tools, and produces a cited answer or uniform refusal. The graph includes documented ingestion stages and serving safeguards; unsampled modules are represented only where the README or source index supports their role and connections.
Main entry points: orchestrator.py Query orchestrator · answer.py Grounded answers · service.py SQL tool · main.py Query API
Components 34
Query serving
- Persona UI
ui/streamlit_app.py - Query API
app/api/main.py - JWT identity
app/auth.py - Query orchestrator
app/orchestrator.py - Route classifier
app/router/classifier.py - Hybrid retrieval
app/retrieval/hybrid.py - Grounded answers
app/generation/answer.py - Answer prompting
app/generation/prompt.py - SQL tool
app/sql_tool/service.py - SQL catalog
app/sql_tool/catalog.py - SQL validation
app/sql_tool/validator.py - SQL executor
app/sql_tool/executor.py - Operations data
- LLM providers
app/llm/base.py
Lakehouse ingestion
- Chunks and vectors
- Spark medallion job
ingestion/spark/run.py - Bronze objects
ingestion/spark/bronze.py - Silver documents
ingestion/spark/silver.py - Gold chunks
ingestion/spark/gold.py - Incremental indexer
ingestion/indexer/run.py - Chunk embeddings
ingestion/indexer/embed.py - Index store
ingestion/indexer/store.py - Event registration
ingestion/lambda_register/handler.py - Source files
Data and evaluation
- Business facts
data_gen/facts.py - Generated data models
data_gen/models.py - Synthetic world
data_gen/world.py - Golden evaluation
eval/golden.py
Runtime safeguards
- Usage costing
app/llm/cost.py - PII masking
ingestion/pii.py - Runtime settings
app/settings.py - Structured logging
app/observability/logging.py - Optional tracing
app/observability/tracing.py
Other components
- Employee
Connections 36
- Employee → Persona UI: asks through
README.md - Persona UI → Query API: submits query
README.md - Query API → JWT identity: decodes token
app/api/main.py - Query API → Query orchestrator: serves query
app/api/main.py - Query orchestrator → Route classifier: routes question
app/orchestrator.py - Query orchestrator → SQL tool: runs SQL leg
app/orchestrator.py - Query orchestrator → Grounded answers: requests answer
app/orchestrator.py - Grounded answers → Hybrid retrieval: searches sources
app/generation/answer.py - Grounded answers → Answer prompting: builds prompt
app/generation/answer.py - Grounded answers → LLM providers: generates response
app/generation/answer.py - Hybrid retrieval → Chunks and vectors: queries chunks
README.md - SQL tool → SQL catalog: loads schema
app/sql_tool/service.py - SQL tool → LLM providers: writes SQL
app/sql_tool/service.py - SQL tool → SQL validation: validates query
app/sql_tool/service.py - SQL tool → SQL executor: runs validated SQL
app/sql_tool/service.py - SQL executor → Operations data: queries views
README.md - Query orchestrator → Usage costing: totals request cost
app/orchestrator.py - Source files → Event registration: raises event
README.md - Event registration → Bronze objects: records manifest
README.md - Spark medallion job → Bronze objects: builds bronze
README.md - Spark medallion job → Silver documents: builds silver
README.md - Spark medallion job → Gold chunks: builds gold
README.md - Bronze objects → Silver documents: parses and tags
README.md - Silver documents → Gold chunks: forms chunks
README.md - Gold chunks → Incremental indexer: feeds changes
README.md - Incremental indexer → Chunk embeddings: creates embeddings
README.md - Incremental indexer → Index store: writes index
README.md - Index store → Chunks and vectors: stores vectors
README.md - Grounded answers → PII masking: masks answer
app/generation/answer.py - Runtime settings → Optional tracing: configures optionally
app/observability/tracing.py - Optional tracing → PII masking: masks trace content
app/observability/tracing.py - Query API → Structured logging: configures logging
app/api/main.py - Business facts → Synthetic world: informs data world
data_gen/world.py - Business facts → Golden evaluation: defines expectations
README.md - Synthetic world → Golden evaluation: supplies expected data
README.md - Generated data models → Synthetic world: models generated entities
data_gen/world.py