How emiber/utdt works
UTDT is a Vue-and-Fastify text-to-SQL chatbot. A user supplies the shared access key, explores the available data, then submits a question; the backend classifies it, generates and executes read-only SQL, builds narrative and chart/table blocks, and returns the answer. Follow-up context and LLM-call records persist in the app database; the UI also offers a usage report. The graph preserves the documented catalog, multi-result answers, conversational replies, and usage features. Some subsystem links use README evidence because their implementations were not excerpted.
Main entry points: pipeline.ts Answer pipeline · api.ts API client · app.ts Route assembly · llm.ts LLM adapter
Components 32
Web interface
- App shell
frontend/src/App.vue - Key entry
frontend/src/components/AccessKeyForm.vue - Key state
frontend/src/auth.ts - Chat view
frontend/src/components/ChatView.vue - Answer blocks
frontend/src/components/ResponseBlocks.vue - Chart display
frontend/src/components/ChartBlock.vue - Data catalog view
frontend/src/components/DataCatalog.vue - Usage view
frontend/src/components/UsageView.vue - API client
frontend/src/api.ts
API and state
- HTTP server
backend/src/server.ts - Route assembly
backend/src/app.ts - Chat endpoint
backend/src/chat.ts - Request authentication
backend/src/auth.ts - Conversation history
backend/src/conversations.ts - Catalog endpoint
backend/src/catalog.ts - Usage endpoint
backend/src/usage-route.ts - Data metadata
backend/src/metadata.ts - Dataset database
backend/src/db.ts
Question answering
- Answer pipeline
backend/src/pipeline.ts - Question classification
backend/src/classify.ts - Schema context
backend/src/schema-context.ts - SQL generation
backend/src/generate-sql.ts - SQL execution
backend/src/execute-sql.ts - Text replies
backend/src/reply.ts - Result insights
backend/src/insights.ts - Chart construction
backend/src/chart.ts
LLM and reporting
- Usage reporting
backend/src/usage.ts - LLM adapter
backend/src/llm.ts - Prompt rendering
backend/src/prompts.ts - Call timing
backend/src/timing.ts
Other components
- User
- OpenAI APIs
Connections 40
- User → Key entry: enters key
- Key entry → Key state: saves key
frontend/src/components/AccessKeyForm.vue - User → Chat view: asks question
- App shell → Chat view: routes to
- App shell → Data catalog view: shows catalog
frontend/src/App.vue - App shell → Usage view: routes to
- Chat view → API client: requests chat
frontend/src/components/ChatView.vue - Data catalog view → API client: loads catalog
frontend/src/components/DataCatalog.vue - Usage view → API client: loads report
frontend/src/components/UsageView.vue - API client → Key state: uses key
frontend/src/api.ts - API client → Chat endpoint: posts question
- API client → Catalog endpoint: requests catalog
- API client → Usage endpoint: requests report
- Answer blocks → Chart display: renders chart
frontend/src/components/ResponseBlocks.vue - Chat view → Answer blocks: renders answer
frontend/src/components/ChatView.vue - HTTP server → Route assembly: builds app
backend/src/server.ts - Route assembly → Request authentication: checks key
backend/src/app.ts - Route assembly → Chat endpoint: registers route
backend/src/app.ts - Route assembly → Usage endpoint: registers route
backend/src/app.ts - Route assembly → Catalog endpoint: serves catalog
backend/src/app.ts - Chat endpoint → Answer pipeline: runs pipeline
backend/src/chat.ts - Chat endpoint → Conversation history: loads and saves
backend/src/chat.ts - Catalog endpoint → Data metadata: reads metadata
- Catalog endpoint → Dataset database: reads dataset
- Answer pipeline → Schema context: builds context
backend/src/pipeline.ts - Answer pipeline → Question classification: classifies question
backend/src/pipeline.ts - Answer pipeline → Text replies: builds text reply
backend/src/pipeline.ts - Answer pipeline → SQL generation: generates queries
backend/src/pipeline.ts - Answer pipeline → Result insights: builds insights
backend/src/pipeline.ts - Answer pipeline → Chart construction: builds charts
backend/src/pipeline.ts - SQL generation → SQL execution: executes SQL
backend/src/generate-sql.ts - SQL generation → LLM adapter: requests SQL
backend/src/generate-sql.ts - Question classification → LLM adapter: requests classification
backend/src/classify.ts - Text replies → LLM adapter: requests reply
backend/src/reply.ts - Result insights → LLM adapter: requests insights
backend/src/insights.ts - SQL generation → Prompt rendering: renders prompts
backend/src/generate-sql.ts - Answer pipeline → Conversation history: uses history types
backend/src/pipeline.ts - LLM adapter → OpenAI APIs: calls APIs
backend/src/llm.ts - Usage endpoint → Usage reporting: builds report
- Usage reporting → Conversation history: reads call records