Preface
As an engineer, I'm constantly asked by colleagues: "Can you pull this report for me?" or "What were last month's revenue numbers?" Each time I'd have to drop what I was doing, write code to query the database, and then come back. It actually eats up a lot of time.
So I started thinking: could AI handle this for us?
Imagine just "talking" to your computer: "Get me a list of all paying customers." The AI then queries the database, formats the results into a report โ no programming required, anyone can use it!
This article shares how I leveraged a large language model (LLM) to quickly build such an intelligent reporting system. A working prototype in a single morning, with later refinements based on real-world usage.
How does this system work?
In simple terms, the flow looks like this:
What you say โ AI translates into computer-readable instructions โ Database returns results โ Report is shown
For example:
- You enter: "List all paying users, including company name and expiration date"
- The AI automatically converts this into a database query
- The system runs the query and presents results in a clean table
P.S. With traditional programming this used to take a lot of time. Now AI can quickly generate the SQL and the report structure for you.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ System Workflow โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ ๐ค User types in the admin panel โ
โ "List paying users with company name, plan type, and โ
โ expiration date" โ
โ โ โ
โ โผ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ ๐ค AI Assistant (LangChain) โ โ
โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โ
โ โ โ ๐ Built-in knowledge โ โ โ
โ โ โ - Knows the company's business rules โ โ โ
โ โ โ - Knows what data can't be queried โ โ โ
โ โ โ - Knows how to protect sensitive data โ โ โ
โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ โ
โ โผ โ
โ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โ
โ โ Translate to SQL โ โ โ Safety checks โ โ
โ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โ
โ โ โ โ
โ โผ โผ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ ๐ Database โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
What tools did I use?
| Tool | Function | Why I chose it |
|---|---|---|
| Next.js | Web framework | Handles both frontend and backend, fast dev cycle |
| LangChain | AI assistant framework | Ready-to-use database query capability |
| Gemini 2.0 Flash | The AI brain | Google's model โ cheap and fast |
| TypeORM | DB connection layer | Secure connection to Azure DB |
| Tailwind CSS | Styling utility | Looks great on mobile and desktop |
What does the AI brain do in this system?
In this system, the AI (large language model) acts like a "super translator" โ its job is to translate what you say into database commands the computer understands.
What's the AI's job?
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Role of the AI in the system โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ What you say Computer command โ
โ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ "List all โ AI โ SELECT TOP 1000 โ โ
โ โ paying users" โ โโโโ โ company_name, plan_type โ โ
โ โ โ translate โ FROM users_table... โ โ
โ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
The AI needs to learn three things first
-
Know the database schema
- What tables exist? What does each table store?
- How are tables related? (e.g., relationship between customers and orders)
-
Understand the company's business rules
- What counts as a "paying user"? (Has a credit card on file and hasn't canceled)
- What's a "test account"? How do we exclude them?
-
Follow safety rules
- Which operations are forbidden? (No deleting or modifying data)
- Which fields can't be queried? (Passwords, secret keys, etc.)
Why Gemini 2.0 Flash?
There are many AI models out there. I picked Google's Gemini 2.0 Flash because:
| Model | Pros | Cons | Good for |
|---|---|---|---|
| GPT-4o | Strong reasoning | Pricier | Complex analysis |
| Claude 3.5 | Great with long docs | More usage limits | Document processing |
| Gemini 2.0 Flash โ | Cheap, fast | Slightly weaker on complex reasoning | Report queries (this project) |
For "structured-format" tasks like report queries, Gemini 2.0 Flash has the best price/performance:
- Super cheap โ Less than NT$50 per month for typical usage
- Fast response โ Generates a query in 1-2 seconds
- Accurate translation โ Solid grasp of database query syntax
Telling the AI "who you are"
We tell the AI its role and rules upfront โ like onboarding a new employee with the company handbook:
const aiAssistantConfig = `
## Your identity
You are the company's data analyst, here to help everyone query reports.
## Rules you must follow
1. You can only "query" data โ no inserts, updates, or deletes
2. Limit each query to 1,000 rows
3. Don't show deleted data
4. Sensitive fields like passwords must not be queried
## Business rules you know
- Paying user = has credit card AND hasn't canceled subscription
- Test account = email containing "xxx"
`;
The benefits of this design:
- Predictable behavior โ AI won't do anything dangerous
- Consistent results โ Every query applies the same rules
- Easy to tune โ To add a new rule, edit this one config
Don't 100% trust the AI: three layers of defense
Even though AI is smart, we can't fully trust it. What if someone deliberately enters malicious instructions? The system has three lines of defense:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Three layers of safety โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ Layer 1: Tell the AI the rules upfront โ
โ โโโโโโโโโโโโโโโโโโโโโโโโ โ
โ Tell the AI "what you can and can't do" โ
โ โ Blocks 80% of dangerous operations right here โ
โ โ
โ Layer 2: Code-level re-check โ
โ โโโโโโโโโโโโโโโโโโโโโโโโ โ
โ The code re-checks every command the AI generates โ
โ โ Even if the AI is tricked, code catches the danger โ
โ โ
โ Layer 3: Database permission limits โ
โ โโโโโโโโโโโโโโโโโโโโโโโโ โ
โ The DB account only has read permission โ can't write at all โ
โ โ Final line of defense to keep data safe โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
My tech stack
For this system I picked Next.js โ a full-stack web framework (React + Node).
Benefit 1: All code in one place
The traditional approach splits frontend and backend into two projects. With Next.js, everything lives together:
my-project/
โโโ src/
โ โโโ app/ # Pages users see
โ โ โโโ reports/
โ โ โโโ page.tsx
โ โโโ app/api/ # Backend handlers
โ โ โโโ reports/
โ โ โโโ route.ts
โ โโโ lib/ # Shared utility code
โ โโโ langchain-sql.ts
Why this matters:
- AI assistants help more easily โ Tools like Cursor or Copilot have context-length limits; with everything in one project, AI can understand the system better
- Code can be shared โ Write once, use in both frontend and backend
- Edit one place, changes apply immediately โ No switching back and forth
Benefit 2: AI library integration
LangChain is a library purpose-built for AI applications, and there's a Node version that drops right into Next.js:
// A few lines is all it takes to let AI query the database
const ai = new ChatVertexAI({ model: 'gemini-2.5-flash-001' });
const database = await SqlDatabase.fromDataSourceParams({ appDataSource });
const aiAssistant = await createSqlAgent(ai, new SqlToolkit(database, ai));
const result = await aiAssistant.invoke({ input: 'List paying users' });
Benefit 3: Web pages that adapt to all screen sizes
With Tailwind CSS, you can easily make pages look great on phone, tablet, and desktop:
// One column on phone, two on tablet, three on desktop
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
P.S. Next.js uses a request-based lifecycle โ each request runs independently โ so it's not suited for long-running jobs or heavy computation. For those, hand the work off to a background worker / job queue to avoid hurting request performance and overall stability.
Saving big time with a paid template
To accelerate development, I bought an off-the-shelf admin template (Isomorphic) for about NT$800.
Free template vs paid template
There's also the free shadcn-ui, which is genuinely great:
- Founder works at the well-known company Vercel
- Over 100k stars on GitHub
But the real difference is "how much time you save":
| Comparison | Free template | Paid template |
|---|---|---|
| Integration time | Tune it yourself | Plug-and-play |
| Stability | Test it yourself | Already battle-tested |
| Run into issues | Higher chance | Lower chance |
| Price | Free | About NT$800 |
Was it worth it?
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ROI analysis โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ Template cost: About NT$800 โ
โ โ
โ Time saved: At least 2 weeks โ
โ - UI page development โ
โ - Phone, tablet, desktop responsiveness โ
โ - Cross-browser testing โ
โ - SEO setup โ
โ โ
โ Verdict: 2 weeks of engineer salary >> NT$800 โ totally โ
โ worth it! โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
What the template ships with
A professional template usually includes:
- โ SEO โ Helps Google find your site
- โ Works on all devices โ Phone, tablet, desktop all tested
- โ Consistent visual style โ Colors, spacing, typography all designed
- โ Common UI components โ Tables, forms, charts, notifications
- โ Dark mode โ Easy on the eyes at night
This gives the project "production-quality" polish from day one, so you can focus on the features that actually matter.
This architecture is great for AI-assisted development
These days everyone uses AI tools (like Cursor or Copilot) to help write code, and this architecture is especially well-suited:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Why AI assistants love this architecture โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ 1. Everything in one project โ
โ โ AI can grasp the whole project at once โ
โ โ
โ 2. Type checking (TypeScript) โ
โ โ AI mistakes get caught immediately โ
โ โ
โ 3. Unified styling approach โ
โ โ AI tunes UI faster โ
โ โ
โ 4. File structure mirrors URLs โ
โ โ Easy for AI to map files to pages โ
โ โ
โ 5. Modular AI library (LangChain) โ
โ โ Swap in different AI models โ
โ โ Works with Google, OpenAI, Claude โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
This is also why the prototype came together in a single morning โ pick the right tools + AI assistance, and the rest is just iterating against real-world feedback.
What does the actual code look like?
Below is a simplified version of the core code so you can see the basic principles.
Step 1: Connect to the database
First, the program needs to connect to the database. Use the secure approach (don't hardcode passwords):
// Database connection code
import { DataSource } from 'typeorm';
async function connectDatabase() {
const connection = new DataSource({
type: 'mssql', // Microsoft SQL Server
host: process.env.AZURE_SQL_SERVER, // DB host (read from env)
database: process.env.AZURE_SQL_DATABASE, // DB name
// ... other secure auth settings
});
await connection.initialize(); // Establish connection
return connection;
}
Step 2: Cache the database structure
The database structure (tables, columns) doesn't change often, so caching it saves money:
// Cache mechanism: remember the DB structure, no need to re-query each time
let cache = null;
const cacheTTL = 60 * 60 * 1000; // Refresh after 60 minutes
function isCacheValid() {
if (!cache) return false;
return new Date() < cache.expiresAt;
}
Step 3: Set up the AI's "rule book"
This is the most important part โ tell the AI what it can and can't do:
const aiRuleBook = `
## Your identity
You are the company's data analyst, here to help with report queries.
---
## Things you absolutely cannot do
### Forbidden operations
- No insert
- No update
- No delete
- No schema changes
### Fields you cannot query (sensitive)
- Password fields
- Keys and tokens
### Query limits
- Max 1,000 rows per query
- Must include filter conditions
---
## Company rules you know
### Main tables
- Customer table โ basic customer info (ID, plan type, canceled flag, etc.)
- Customer detail table โ company name, contact, etc.
- Payment history table โ payment records
### Key business rules
#### Don't show deleted data
- Auto-exclude soft-deleted rows in queries
#### Exclude test accounts
- Emails containing "IQT" are test accounts
#### Definition of paying user
Has credit card + hasn't canceled subscription + not expired
`;
How does safety work?
Even if the AI is smart, we add extra layers of defense to make sure nothing goes wrong.
Defense 1: code-level checks
Before running a query, the code checks for dangerous operations:
// Dangerous operations blacklist
const blocklist = ['INSERT', 'UPDATE', 'DELETE', 'DROP TABLE'];
function checkSafety(queryStatement) {
// 1. Must start with SELECT
if (!queryStatement.startsWith('SELECT')) {
return { safe: false, error: 'Read-only โ no other operations allowed' };
}
// 2. Check for dangerous operations
for (const banned of blocklist) {
if (queryStatement.includes(banned)) {
return { safe: false, error: `Forbidden operation detected: ${banned}` };
}
}
// 3. Check for queries against sensitive fields
// ... similar logic
return { safe: true };
}
Defense 2: auto-add row limits
If the AI forgets to add a row limit, the code auto-injects one:
function autoAddLimit(queryStatement) {
// If no row limit is set, add "TOP 1000"
if (!queryStatement.includes('TOP')) {
return queryStatement.replace('SELECT', 'SELECT TOP 1000');
}
return queryStatement;
}
Defense 3: database-level permission
The most reliable approach is to set DB permissions: this account can only "read," not "write":
-- DB setup: read-only role
CREATE ROLE [report_query_role];
GRANT SELECT TO [report_query_role]; -- Only SELECT
DENY INSERT, UPDATE, DELETE TO [report_query_role]; -- Block writes
What does the user see?
Simple, intuitive UI
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐ค Smart report assistant โ
โ โ
โ Just ask in plain English! Type what you want โ AI handles it โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ ๐ Quick examples (one-click) โ
โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โ
โ โ Paying users โ โ New customers โ โ Plan stats โ โ
โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โ
โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Type what you want to query... โ โ
โ โ โ โ
โ โ E.g.: List all paying customers with company name and โ โ
โ โ expiration date โ โ
โ โ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โ
โ โ ๐ช Generate โ โ โถ๏ธ Run now โ โ
โ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Results in different views
Query results can be shown in various ways depending on what you need:
- ๐ Table โ See the full data
- ๐ Bar chart โ Compare numbers across categories
- ๐ Line chart โ See trends over time
- ๐ฅง Pie chart โ See proportions
Real-world examples
Example 1: Querying paying customers
User input: List all paying customers, including company name, plan type, and expiration date

The AI automatically:
- Understands what the user wants
- Finds the matching tables
- Generates a correct query
- Runs the query and returns results
The result is a clean table of paying customers!
Example 2: Visualizing as a chart
Beyond tables, results can be displayed as charts for more intuitive insights:

Example 3: Safety guard test
User input: Delete all test users
AI response:
Sorry, I can't perform delete operations. This is a read-only report query tool. To delete data, please contact the database administrator.
โ The system successfully blocked the dangerous operation!
How much does this system cost?
AI models are billed by usage, measured in Tokens (think of them as "word-units").
What's a Token?
In simple terms, a Token is the smallest text unit the AI processes:
- English: roughly 1 word = 1 Token
- Chinese: roughly 1 character = 2-3 Tokens (UTF-8 encoding makes Chinese heavier)
Gemini 2.0 Flash pricing
| Item | Price (USD) | Approx NT$ (1 USD โ 32 TWD) |
|---|---|---|
| 1M input Tokens | $0.10 | About NT$3.2 |
| 1M output Tokens | $0.40 | About NT$12.8 |
Per 1,000 Tokens
| Item | USD | NT$ |
|---|---|---|
| 1,000 input Tokens | $0.0001 | About NT$0.0032 |
| 1,000 output Tokens | $0.0004 | About NT$0.0128 |
๐ก Plain English: 1,000 input Tokens cost just NT$0.003 โ extremely cheap!
Examples
| Text | Length | Approx Tokens |
|---|---|---|
List all paying customers | 4 English words | ~5 Tokens |
SELECT * FROM customers | 4 English words | ~5 Tokens |
| A SQL query | ~50 chars | ~30-50 Tokens |
| System prompt (rule book) | ~800 Chinese chars | ~2,000 Tokens |
Each AI conversation has two cost categories:
- Input Tokens: your question + the database schema info
- Output Tokens: the AI's response (SQL query + explanation)
Real-world usage estimate
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Token consumption per report query โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ ๐ฅ Input Tokens (info you give the AI) โ
โ โโโ System prompt (rule book) ~2,000 Tokens โ
โ โโโ DB schema (cached, no repeat) ~3,000 Tokens (first time) โ
โ โโโ User question ~100 Tokens โ
โ โ
โ ๐ค Output Tokens (AI's response) โ
โ โโโ SQL query ~200 Tokens โ
โ โโโ Result explanation ~300 Tokens โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Cost breakdown
| Operation | Tokens | Estimated cost | Note |
|---|---|---|---|
| Read DB schema (first time) | ~5,000 input + 500 output | About NT$0.03 | One-time, then cached |
| Each query (after caching) | ~2,100 input + 500 output | About NT$0.003 | Saves repeat schema-read cost |
| 50 queries per day | ~130k Tokens | About NT$0.15 | Typical SMB daily usage |
| Per month (22 working days) | ~2.86M Tokens | About NT$5 | Cheaper than a bubble tea! |
Example: single-query cost
Suppose a user asks: "List all paying customers, including company name and expiration date"
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐ฐ Single-query cost calculation โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ ๐ฅ Input cost โ
โ โโโ System prompt 2,000 Tokens ร $0.0001/1K = $0.0002 โ
โ โโโ User question 100 Tokens ร $0.0001/1K = $0.00001 โ
โ โโโ Subtotal: $0.00021 (NT$0.007) โ
โ โ
โ ๐ค Output cost โ
โ โโโ SQL query 200 Tokens ร $0.0004/1K = $0.00008 โ
โ โโโ Explanation 300 Tokens ร $0.0004/1K = $0.00012 โ
โ โโโ Subtotal: $0.0002 (NT$0.006) โ
โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ ๐ Total: $0.0004 (NT$0.013) โ
โ โ
โ ๐ One query costs NT$0.01 โ 100 queries cost NT$1! โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Why so cheap?
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ The savings key: caching โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ โ Without caching โ
โ Re-read DB schema on every query โ
โ โ 5,000+ Tokens per query โ
โ โ Could be NT$50+ per month โ
โ โ
โ โ
With caching โ
โ Schema cached for 60 minutes โ
โ โ Only 2,100 Tokens per query โ
โ โ About NT$5 per month โ
โ โ
โ ๐ก 90% cost savings! โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Compared to other AI models
| Model | Same-usage monthly cost | Note |
|---|---|---|
| Gemini 2.0 Flash โ | About NT$5 | This project |
| GPT-4o | About NT$50 | 10x more expensive |
| GPT-4o mini | About NT$8 | Also a cheap option |
| Claude 3.5 Sonnet | About NT$40 | Good for complex analysis |
Super cheap! A month of AI costs less than a single drink ๐ฅค
Safety rules for the dev team
Beyond the system's own protection, I also wrote dev guidelines so the team doesn't accidentally trigger dangerous operations when using AI tools (like Cursor):
# Dev guidelines: database safety
## Things AI must never do
### 1. Delete data
- No row deletes
- No truncating tables
### 2. Delete schema
- No drop table
- No drop database
### 3. Risky modifications
- No ad-hoc schema changes
Conclusion
Why does this approach work?
- Tools are mature enough โ LangChain has handled the hard parts already
- AI is cheap enough โ Gemini 2.0 Flash cost is essentially negligible
- Safety is solid โ Three layers of defense, low-risk by design
What features could be added?
- Save common queries โ Click to re-run later
- Auto-recommend chart type โ Suggest a chart based on data shape
- Follow-up questions โ After a query, say "show only the top 10"
What's it good for?
- Internal company report needs
- Letting non-engineers query data
- Data analysts validating ideas quickly
If you want to build something similar, feel free to use this architecture as a reference! With vibe coding, you can have a prototype in a single morning, then refine and ship โ quickly.


























Comments