How nandhinikm/text_sql_ai_demo_project works
This is a conversational text-to-SQL application: users ask in plain language, clarify ambiguous requests, receive generated SQL checked for safety, and see query results. The Streamlit and CLI interfaces both delegate to the shared pipeline, which owns the domain flow and database execution. The README documents the repair loop and mock/offline mode; sampled source confirms the pipeline, clarification, validation, database, configuration, and LLM-client responsibilities. Some pipeline implementation lines were omitted, so only documented workflow links are shown where wiring was not directly visible.
Main entry points: pipeline.py Text-to-SQL pipeline · app.py Streamlit chat · cli.py Terminal chat · db.py Read-only database access
Components 13
User interfaces
- Streamlit chat
app.py - Terminal chat
cli.py
Query orchestration
- Text-to-SQL pipeline
src/pipeline.py - Clarification engine
src/clarifier.py - Schema formatting
src/schema_utils.py
Generation and safety
- SQL generation and repair
src/sql_generator.py - SQL safety validator
src/sql_validator.py
Runtime services
- Runtime settings
src/config.py - LLM client factory
src/llm_client.py - Read-only database access
src/db.py
Other components
- User
- Azure OpenAI
- SQLite database
Connections 23
- User → Streamlit chat: asks
- User → Terminal chat: asks
- Streamlit chat → Text-to-SQL pipeline: submits question
- Terminal chat → Text-to-SQL pipeline: submits question
- Streamlit chat → Runtime settings: loads settings
- Terminal chat → Runtime settings: loads settings
- Streamlit chat → LLM client factory: builds client
- Terminal chat → LLM client factory: builds client
- Streamlit chat → Read-only database access: opens database
- Terminal chat → Read-only database access: opens database
- Text-to-SQL pipeline → Read-only database access: reads schema
- Read-only database access → Schema formatting: provides schema
- Text-to-SQL pipeline → Schema formatting: formats schema
- Text-to-SQL pipeline → Clarification engine: checks clarity
- Clarification engine → LLM client factory: judges unclear cases
- Text-to-SQL pipeline → SQL generation and repair: generates or repairs SQL
- SQL generation and repair → LLM client factory: requests SQL
- Text-to-SQL pipeline → SQL safety validator: validates SQL
- Text-to-SQL pipeline → Read-only database access: executes safe SQL
- Read-only database access → SQLite database: reads query results
- Text-to-SQL pipeline → Streamlit chat: returns response
- Text-to-SQL pipeline → Terminal chat: returns response
- LLM client factory → Azure OpenAI: calls when configured