Skip to content

cesar39299/Northwind_AI_Web_Assistant

Repository files navigation

🧠 Northwind AI Web Assistant

πŸš€ Overview

Northwind AI Web Assistant is an AI-powered Business Intelligence web application that allows users to query relational databases using natural language.

Instead of writing SQL, users interact through a chat-based interface, and the system transforms questions into secure, optimized queries, returning results ready for analysis, visualization, and export.

⚑ Proven Multi-Database Capability Successfully tested with Northwind, AdventureWorks, and AdventureWorksDW, handling everything from simple schemas to enterprise-grade data models.


πŸ“Έ Demo

northwindaiweb.client

πŸ’‘ Conversational BI experience with charts, SQL transparency, and export features.


πŸ’¬ Intelligent Chat Interface

🧠 Chat-Based Experience

  • Conversational interface inspired by ChatGPT

  • Users ask questions in plain language

  • No SQL knowledge required

  • Responses include:

    • AI-generated analysis
    • Data tables
    • Charts
    • SQL query (expandable)

πŸ“± Mobile-Friendly Design

  • Fully responsive (desktop + mobile)
  • Optimized for smartphone browsers
  • Sticky input bar (chat-style)
  • Smooth scrolling experience

πŸ“² Enables data analysis from anywhere, directly on mobile.


πŸ“Š Integrated Data Visualization

Each query automatically returns:

  • πŸ“‹ Structured table
  • πŸ“ˆ Bar chart visualization
  • Clean and readable layout

The system prepares data for visualization automatically β€” no manual configuration needed.


πŸ“€ Export & Reporting Features

Users can export results instantly:

πŸ“„ PDF Report

  • Includes AI-generated analysis
  • Data table
  • Embedded chart

πŸ“Š Excel Export (.xlsx)

  • Raw structured data
  • Includes metadata (row count, timestamp)

πŸ–ΌοΈ Chart Export (.png)

  • High-quality chart image

⚑ Turns the app into a lightweight BI reporting tool.


🧠 AI-Generated Insights

Beyond raw data, the system provides:

  • Natural language analysis
  • Business-friendly summaries
  • Context-aware insights

Users don’t just see data β€” they understand it immediately.


πŸ—οΈ System Architecture

High-Level Architecture

graph TD
A[React + Vite Frontend] --> B[ASP.NET Core API]
B --> C[AI Query Engine]
C --> D[SQL Server Databases]
Loading

πŸ”¬ AI Query Pipeline

graph TD
U[User Question]
U --> V[Vector Schema Search]
V --> F[FK Graph Expander]
F --> S[Schema Filter]
S --> QP[Query Planner]
QP --> PB[Prompt Builder]
PB --> SG[SQL Generator]
SG --> SV[SQL Security Validator]
SV --> QE[Query Executor]
QE --> RA[Result Analyzer]
Loading

βš™οΈ How It Works

The system processes queries through a multi-stage AI pipeline:

  • Vector Schema Search β†’ Finds relevant tables
  • FK Graph Expander β†’ Resolves relationships
  • Schema Filter β†’ Reduces complexity
  • Query Planner β†’ Structures query logic
  • Prompt Builder β†’ Prepares LLM input
  • SQL Generator β†’ Generates SQL
  • SQL Security Validator β†’ Ensures safety
  • Query Executor β†’ Runs query
  • Result Analyzer β†’ Produces insights + visualization-ready data

✨ Key Features

  • πŸ”Ž Natural Language to SQL conversion
  • 🧠 AI-driven query planning
  • πŸ” Secure SQL validation
  • πŸ“Š Automatic chart generation
  • πŸ“„ SQL transparency (expandable view)
  • πŸ“€ Multi-format export (PDF, Excel, PNG)
  • πŸ“± Mobile-ready UI
  • 🧩 Modular architecture
  • πŸ—„οΈ Multi-database support

πŸ§ͺ Supported Databases

Northwind

  • Simple transactional schema
  • Ideal for demos and baseline testing

AdventureWorks

  • Complex OLTP system
  • Multi-schema relationships

AdventureWorksDW

  • Data warehouse model
  • Star schema (fact + dimensions)

βœ… Demonstrates adaptability from simple datasets to enterprise BI scenarios.


πŸ§ͺ Example Use Case

User Input:

"top 5 total sales by country"

System Output:

  • SQL query generated automatically
  • Aggregated dataset
  • AI-generated analysis
  • Bar chart visualization
  • Export options (PDF / Excel / PNG)

πŸ› οΈ Technology Stack

Frontend

  • React
  • Vite
  • Recharts

Backend

  • ASP.NET Core Web API
  • C#
  • MemoryCache

Data Layer

  • SQL Server
  • Northwind
  • AdventureWorks
  • AdventureWorksDW

AI & Processing

  • Large Language Models (LLMs)
  • Prompt Engineering
  • Vector-based schema retrieval

▢️ Getting Started

Prerequisites

  • Node.js
  • .NET 6+
  • SQL Server

Run Backend

dotnet run

Run Frontend

npm install
npm run dev

πŸ“ Project Structure

/frontend        β†’ React + Vite client
/backend         β†’ ASP.NET Core API
/docs            β†’ Documentation & assets

🧠 Architecture Decisions & Trade-offs

1️⃣ Decoupled Frontend & Backend

Why:

  • Independent scaling
  • Clean separation

Trade-off:

  • Requires CORS configuration

2️⃣ Multi-Stage AI Pipeline

Why:

  • Better accuracy
  • Debuggable

Trade-off:

  • More complex system

3️⃣ Schema-Aware Querying

Why:

  • Prevents hallucinations
  • Ensures valid joins

Trade-off:

  • Requires schema indexing

4️⃣ SQL Security Layer

Why:

  • Prevents destructive queries

Trade-off:

  • May restrict edge cases

5️⃣ OLTP + OLAP Support

Why:

  • Works with transactional and analytical DBs

Trade-off:

  • More complex logic

6️⃣ Visualization-Ready Output

Why:

  • Immediate UI integration

Trade-off:

  • Extra backend processing

πŸ“Š Future Improvements

  • AI-driven chart selection
  • Dashboard builder
  • Query history
  • Role-based security
  • BI tool integrations
  • Auto-aggregation for large datasets

🀝 Contribution

Contributions are welcome. Fork the repo and submit a PR.


πŸ“„ License

MIT License


πŸ‘¨β€πŸ’» Author

AI + Data Engineering portfolio project showcasing:

  • Natural Language β†’ SQL systems
  • Full-stack architecture
  • Business Intelligence applications
  • Real-world AI orchestration pipelines

⭐ Final Note

This project demonstrates how AI can transform traditional data access into a conversational, intuitive, and powerful BI experience.

From raw data β†’ to insights β†’ to reports β€” all in a single chat interface.

Releases

Packages

Contributors

Languages