How manojkesani/nl_sql works
This is a natural-language-to-SQL application for registered SQLite databases. A user submits a question through the web UI or API; the agent selects a database, builds a model-backed agent, executes read-only SQL, and returns a structured answer with usage and prompt metadata. Supporting product branches prepare schema profiles and prompts, generate and review evaluation data, and expose a database tool over MCP. The graph reflects the newer nlsql package as well as README-documented UI and service capabilities; unsampled links are omitted or marked unverified.
Main entry points: golden.py Golden data generation · build.py SQL agent · service.py Agent service · enrich.py Schema enrichment
Components 26
Question answering
- Web UI
frontend/index.html - HTTP API
nlsql/api.py - Agent service
nlsql/agent/service.py - Database router
nlsql/agent/router.py - SQL agent
nlsql/agent/build.py - Structured response
nlsql/agent/schema.py
Database access
- Database registry
nlsql/registry.py - Read-only SQL executor
nlsql/db/executor.py - SQLite databases
longlist.db - MCP database server
db_server.py
Database preparation
- Schema profiler
nlsql/db/introspect.py - Profile management
nlsql/ingest/profile.py - Schema enrichment
nlsql/ingest/enrich.py - Golden data generation
nlsql/ingest/golden.py - Prompt generation
nlsql/ingest/promptgen.py - Ingest pipeline
nlsql/ingest/pipeline.py - Golden data review
nlsql/ingest/review.py
Models and tracing
- Model factory
nlsql/llm/factory.py - Model providers
nlsql/llm/providers.py - Structured LLM calls
nlsql/llm/structured.py - Usage tracking
nlsql/llm/usage.py - Phoenix tracing
nlsql/observability.py
Evaluation
- Evaluation runner
nlsql/eval/runner.py - Result metrics
nlsql/eval/metrics.py
Other components
- Question asker
- Phoenix service
Connections 45
- Question asker → Web UI: asks
README.md - Web UI → HTTP API: submits question
README.md - Question asker → HTTP API: calls API
README.md - HTTP API → Agent service: calls
nlsql/api.py - Agent service → Database router: routes question
nlsql/agent/service.py - Agent service → Database registry: loads config
nlsql/agent/service.py - Agent service → SQL agent: runs agent
nlsql/agent/service.py - Agent service → Usage tracking: tracks usage
nlsql/agent/service.py - Agent service → Phoenix tracing: tags traces
nlsql/agent/service.py - Database router → Database registry: lists databases
nlsql/agent/router.py - Database router → Model factory: builds model
nlsql/agent/router.py - Database router → Structured LLM calls: requests route
nlsql/agent/router.py - SQL agent → Database registry: resolves database
nlsql/agent/build.py - SQL agent → Prompt generation: loads prompt
nlsql/agent/build.py - SQL agent → Model factory: builds model
nlsql/agent/build.py - SQL agent → Read-only SQL executor: runs SQL tool
nlsql/agent/build.py - SQL agent → Structured response: formats answer
nlsql/agent/build.py - Read-only SQL executor → SQLite databases: queries read-only
nlsql/db/executor.py - MCP database server → Read-only SQL executor: runs queries
db_server.py - Profile management → Database registry: resolves database
nlsql/ingest/profile.py - Profile management → Schema profiler: profiles schema
nlsql/ingest/profile.py - Schema profiler → Read-only SQL executor: opens read-only
nlsql/db/introspect.py - Ingest pipeline → Profile management: runs profiling
nlsql/ingest/pipeline.py - Ingest pipeline → Schema enrichment: runs enrichment
nlsql/ingest/pipeline.py - Ingest pipeline → Golden data generation: generates goldens
nlsql/ingest/pipeline.py - Ingest pipeline → Prompt generation: generates prompt
nlsql/ingest/pipeline.py - Schema enrichment → Profile management: reads schema card
nlsql/ingest/enrich.py - Schema enrichment → Model factory: builds model
nlsql/ingest/enrich.py - Schema enrichment → Structured LLM calls: creates documentation
nlsql/ingest/enrich.py - Golden data generation → Read-only SQL executor: validates SQL
nlsql/ingest/golden.py - Golden data generation → Result metrics: compares results
nlsql/ingest/golden.py - Golden data generation → Schema enrichment: reads documentation
nlsql/ingest/golden.py - Golden data generation → Profile management: reads schema card
nlsql/ingest/golden.py - Golden data generation → Model factory: builds model
nlsql/ingest/golden.py - Prompt generation → Profile management: uses profile
nlsql/ingest/promptgen.py - Prompt generation → Schema enrichment: uses enrichment
nlsql/ingest/promptgen.py - Prompt generation → Golden data generation: uses examples
nlsql/ingest/promptgen.py - Golden data review → Golden data generation: reviews records
nlsql/ingest/review.py - Model factory → Model providers: selects provider
nlsql/llm/factory.py - Phoenix tracing → Phoenix service: exports traces
nlsql/observability.py - Evaluation runner → Database registry: loads database
nlsql/eval/runner.py - Evaluation runner → SQL agent: builds agent
nlsql/eval/runner.py - Evaluation runner → Read-only SQL executor: runs evaluation SQL
nlsql/eval/runner.py - Evaluation runner → Golden data generation: loads test cases
nlsql/eval/runner.py - Evaluation runner → Result metrics: scores results
nlsql/eval/runner.py