💡 Inspiration
Data is the lifeblood of modern decision-making, but extracting cross-table insights from raw spreadsheets usually requires deep mastery of complex SQL joins. When non-technical users want to combine multiple local datasets, they are forced to wait on busy data teams or risk corrupting data with brittle spreadsheet macros.
We built DuckBrain SQL to provide a zero-friction, production-ready solution that lets anyone talk directly to multiple relational datasets simultaneously using natural language—without sacrificing enterprise security, processing speed, or data privacy.
🤖 What it does
DuckBrain SQL turns raw, disconnected CSV files into an active, intelligent relational computing environment right inside the browser.
Multi-Table Schema Mapping: Users can drop in 2 to 5 completely different CSV datasets at once. The autonomous agent dynamically parses their structures, identifies overlapping relational keys, and maps out a unified database schema.
Natural Language to Relational Logic: It seamlessly translates complex, multi-layered analytical questions into standard SQL syntax, handling deep mathematical operations, self-contained aggregations, and advanced multi-table joins effortlessly.
Human-in-the-Loop Gate: Designed for safety and absolute predictability, the engine halts at a verification checkpoint, rendering the generated SQL syntax for human approval before executing it against the data.
Active Prompt Firewall: A built-in security perimeter intercepts and blocks destructive code injections or unauthorized database modifications (DROP, DELETE, ALTER), keeping the analytical runtime strictly read-only and resilient.
🛠️ How we built it
We engineered a lightweight, blisteringly fast, and cost-effective pipeline:
The Brain: Qwen Cloud (qwen-plus) via an OpenAI-compatible SDK handles flagship-class schema comprehension, multi-stage planning, and logical SQL formulation.
The Muscle: DuckDB acts as our high-performance, in-memory OLAP (Online Analytical Processing) database engine to compute complex multi-table joins in milliseconds.
The Interface: A sleek, customized charcoal dashboard built with Streamlit for real-time visualization and fluid interaction.
Environment Security: Secured using python-dotenv for local environment variable encapsulation and Streamlit Secrets for isolated production key hosting.
🚧 Challenges we ran into
The Multi-Table Roadblock: Getting an LLM to accurately write queries for a single table is straightforward. Getting it to reliably predict relational join keys, track column aliases perfectly, and avoid Cartesian products across multiple dynamic uploads required rigorous prompt structuring, explicit context scoping, and iterative schema profiling.
Zero-Trust App Safety: We had to ensure that the autonomous agent could never be manipulated via prompt injection into modifying or destroying the analytical database. We resolved this by building a dual-layer defense: an active prompt-level firewall paired with an un-bypassable human review gate.
🏅 Accomplishments that we're proud of
We successfully migrated our architecture from a simple, single-file local script to a fully scalable, cloud-ready platform.
The agent effortlessly handles complex mathematical edge cases—such as calculating real-time percentage inflation deviations and multi-column filters—in milliseconds using the DuckDB engine.
We successfully implemented a reliable human-in-the-loop checkpoint system that meets strict hackathon agent compliance and safety standards.
📚 What we learned
We gained deep insights into prompt engineering for structured database tasks and learned how to tightly constrain an LLM's reasoning path to prevent hallucinated SQL aliases. We also discovered the immense performance benefits of utilizing specialized in-memory analytical engines like DuckDB over traditional transactional database setups for rapid web-based data processing.
🔮 What's Next for DuckBrain SQL
Vectorized Knowledge Bases: Integrating a local vector database to auto-document highly specialized, industry-specific business jargon and schema descriptions.
Dynamic Charting Autopilot: Expanding the agent's capabilities to automatically choose, format, and render the cleanest interactive visualizations (using Plotly or ECharts) based entirely on the structure of the query results.
Log in or sign up for Devpost to join the conversation.