How kakuibeyond/chatbi_mvp works
ChatBI is a natural-language-to-SQL analytics application with both CLI and FastAPI/SSE entry points. Its main workflow validates a question, enriches a prompt with business rules and optional indicator/schema context, generates SQL, executes it under security controls, and formats results. A separate Plan-and-Execute agent decomposes complex analyses and can produce reports. The README documents additional retrieval and schema-generation capabilities; some internal connections are supported by the source index or README rather than complete excerpts, so unsampled implementation details are not inferred.
Main entry points: main.py ChatBI system · schema_linker.py Schema linker · llm_client.py LLM client · agent_planner.py Plan executor
Components 24
Entry points
- CLI
main.py - FastAPI service
api_service.py
Query workflow
- ChatBI system
main.py - Query parser
query_parser.py - Prompt builder
prompt_builder.py - LLM client
llm_client.py - Result formatter
result_formatter.py
Business context
- Indicator knowledge
indicator_knowledge.py - Indicator retrieval
indicator_retriever.py - Schema linker
schema_linker.py - Table retrieval
table_retriever.py - Field matching
field_matcher.py - Join resolution
join_resolver.py
Agent analysis
- Query decomposer
query_decomposer.py - Plan executor
agent_planner.py - Report generator
report_generator.py
Runtime and data
- Runtime factory
runtime_factory.py - Configuration
config.py - Database client
database.py - Query security
security.py - Schema generator
schema_generator.py
Other components
- Analyst
- LLM API
- SQL database
Connections 29
- Analyst → CLI: asks via CLI
README.md - Analyst → FastAPI service: sends query
README.md - CLI → ChatBI system: runs query
README.md - FastAPI service → ChatBI system: routes query
README.md - ChatBI system → Runtime factory: builds runtime
main.py - Runtime factory → Configuration: reads settings
runtime_factory.py - ChatBI system → Query parser: validates question
main.py - ChatBI system → Indicator knowledge: resolves indicators
main.py - ChatBI system → Indicator retrieval: retrieves indicators
main.py - ChatBI system → Prompt builder: builds prompt
main.py - Prompt builder → Schema linker: requests schema
prompt_builder.py - Schema linker → Table retrieval: retrieves tables
schema_linker.py - Schema linker → Field matching: matches fields
schema_linker.py - Schema linker → Join resolution: resolves joins
schema_linker.py - Field matching → Table retrieval: uses retrieval
field_matcher.py - ChatBI system → LLM client: generates SQL
main.py - LLM client → LLM API: calls API
llm_client.py - ChatBI system → Database client: executes SQL
main.py - Database client → Query security: secures SQL
database.py - Database client → SQL database: queries
README.md - ChatBI system → Result formatter: formats results
main.py - Indicator retrieval → Indicator knowledge: uses definitions
indicator_retriever.py - Plan executor → Query decomposer: decomposes question
README.md - Plan executor → ChatBI system: executes steps
agent_planner.py - Plan executor → Report generator: generates report
README.md - Report generator → LLM client: requests summary
report_generator.py - Query decomposer → LLM client: generates plan
query_decomposer.py - Query decomposer → Prompt builder: uses schema
query_decomposer.py - Schema generator → SQL database: reads schema
README.md