$ show tencentmusic/supersonic
SuperSonic is a full-stack AI+BI platform that combines Chat BI (natural language to SQL via LLMs) and Headless BI (semantic layer for metrics and dimensions). The backend is a modular Java Spring Boot application with modules for chat, headless query, authentication, and common utilities. It supports multiple databases (MySQL, PostgreSQL, ClickHouse, etc.) and integrates with various LLM providers (OpenAI, Ollama, Dify) and embedding stores (Milvus, Chroma, PGVector, InMemory). The frontend is a React application built with UmiJS and Ant Design, providing a semantic model editor, agent configuration, plugin management, and an embeddable chat SDK. The core NL2SQL pipeline involves schema mapping (rule-based and embedding-based), semantic parsing (rule and LLM), SQL correction (chain of correctors), translation to physical SQL, and execution. The system also includes chat memory for few-shot learning, plugin recognition, and post-query recommendations. While primarily an application, it contains data research elements such as evaluation scripts (benchmark.py, evaluation.py) and custom HanLP dictionaries for domain-specific entity recognition. The architecture is extensible via SPI-based component factories for parsers, correctors, mappers, and DB adaptors. The codebase is well-structured but shows signs of complexity with many modules, some commented-out code, hardcoded configurations, and a dependency on external LLM services that may introduce drift.
The LLM identified 4 files worth highlighting for reuse:
A comprehensive utility class for extracting and manipulating SQL SELECT statements using JSqlParser. It provides methods to get select fields, functions, group-by columns, order-by columns, and more. This is reusable across any Java project that needs to analyze or transform SQL queries, and demonstrates advanced use of the JSqlParser visitor pattern.
An abstract factory interface for creating embedding stores (vector databases). Implementations exist for InMemory, Milvus, Chroma, PGVector, and OpenSearch. This abstraction allows swapping vector stores without changing business logic, and is reusable in any Java application that needs semantic search or RAG capabilities.
A factory that provides database-specific adaptors (MySQL, PostgreSQL, ClickHouse, etc.) for SQL dialect handling and query execution. Each adaptor extends a base class and can be registered via SPI. This pattern is reusable for any multi-database application that needs to generate or rewrite SQL for different engines.
A self-contained React component library for embedding a conversational analytics interface into any web application. It includes message rendering, chart display (ECharts), filter items, and copilot functionality. The package is isolated with its own build and can be reused independently of the main SuperSonic frontend.