An intelligent AI-powered application that lets you chat with your Microsoft Fabric databases and Power BI semantic models using natural language. Built with FastAPI (Python backend) and Next.js (React frontend).
Check the video demonstration: https://youtu.be/ShrYnqdaGuc?si=SdCXLfUNGeo5Vnb_
- Ask Questions in Plain English: "Show me top 10 customers by revenue" or "What are sales trends this month?"
- AI Generates SQL/DAX: Automatically creates optimized queries for your data
- Self-Correcting: If a query fails, AI analyzes the error and fixes it automatically
- Real-Time Insights: Get instant answers with beautiful charts and tables
- Two Data Sources: Works with Microsoft Fabric (SQL) and Power BI (DAX)
- Connect to your Microsoft Fabric or Power BI
- Ask "What tables do I have?"
- Watch the AI generate and execute queries
- Get instant results with visualizations
- Python 3.8 or higher (Download here)
- Node.js 18 or higher (Download here)
- Git (Download here)
- Azure account with admin permissions
- Microsoft Fabric workspace (for SQL data) OR Power BI Premium workspace (for semantic models)
- Anthropic Claude API key (Get one here)
git clone https://github.com/yourusername/chat-with-data.git
cd chat-with-data# Make the script executable (Mac/Linux)
chmod +x setup.sh
# Run the automated setup
./setup.shWindows users: Run these commands instead:
# Copy environment files
copy backend\.env.example backend\.env
copy frontend\.env.local.example frontend\.env.local
# Setup backend
cd backend
python -m venv venv
venv\Scripts\activate
pip install -r requirements.txt
cd ..
# Setup frontend
cd frontend
npm install
cd ..- Go to console.anthropic.com
- Sign up for an account
- Go to API Keys section
- Create a new API key
- Copy the key (starts with
sk-ant-api03-)
- Go to portal.azure.com
- Search for "App registrations" → Click "New registration"
- Fill in:
- Name:
Chat with Data App - Account types:
Single tenant - Redirect URI:
Web→http://localhost:3000
- Name:
- Click "Register"
- Copy these 3 values:
- Application (client) ID
- Directory (tenant) ID
- Client Secret (go to "Certificates & secrets" → "New client secret")
- In your app registration, go to "API permissions"
- Click "Add a permission"
- Add these permissions:
- Power BI Service →
Dataset.ReadWrite.All,Workspace.Read.All - Azure SQL Database →
user_impersonation
- Power BI Service →
- Click "Grant admin consent"
Open backend/.env in any text editor and fill in:
# Your Claude AI API key
ANTHROPIC_API_KEY=sk-ant-api03-your-api-key-here
# Your Azure app registration details
AZURE_TENANT_ID=your-tenant-id-here
AZURE_CLIENT_ID=your-client-id-here
AZURE_CLIENT_SECRET=your-client-secret-here
# Leave these as they are
LOG_LEVEL=INFO
CORS_ORIGINS=http://localhost:3000The frontend/.env.local file should already be correct:
NEXT_PUBLIC_API_URL=http://localhost:8000- Go to fabric.microsoft.com
- Open your workspace
- Click "Workspace settings" (gear icon)
- Go to "Access" → "Add people or groups"
- Enter your Application (client) ID
- Select Member role
- Click "Add"
- Go to powerbi.microsoft.com
- Open your Premium workspace
- Click workspace menu (three dots) → "Settings"
- Go to "Access" → "Add people or groups"
- Enter your Application (client) ID
- Select Member role
- Click "Add"
Terminal 1 - Start Backend:
cd backend
# Activate virtual environment
# Windows:
venv\Scripts\activate
# Mac/Linux:
source venv/bin/activate
# Start backend server
python main.pyYou should see: ✅ Chat with Data API ready to accept requests
Terminal 2 - Start Frontend:
cd frontend
# Start frontend
npm run devYou should see: ▲ Next.js ready on http://localhost:3000
-
Open your browser and go to
http://localhost:3000 -
Configure Authentication:
- You'll see the main page
- The authentication should show as "✅ Configured" (if not, click "Configure OAuth2" and enter your Azure details)
-
Connect to Your Data:
- Choose either "SQL Endpoint" (for Fabric) or "Power BI Semantic Model"
- For Fabric: Enter your workspace SQL endpoint URL and database name
- For Power BI: Enter your XMLA endpoint URL and dataset name
- Click "Test Connection" - you should see "✅ Connected successfully"
-
Start Chatting:
- Try asking: "What tables are available?"
- Try asking: "Show me 5 rows from the largest table"
- Watch the AI generate queries and return results!
- "What tables do I have in this database?"
- "Show me the top 10 customers by revenue"
- "What are the sales trends by month this year?"
- "How many orders were placed last week?"
- "What measures are available in this model?"
- "Show me sales by product category"
- "Compare this year's revenue to last year"
- "What's the total revenue for each region?"
-
Error:
ModuleNotFoundError- Fix: Make sure virtual environment is activated and run
pip install -r requirements.txt
- Fix: Make sure virtual environment is activated and run
-
Error:
Claude is not available- Fix: Check your
ANTHROPIC_API_KEYinbackend/.env
- Fix: Check your
- Error:
Cannot find module- Fix: Run
npm installin the frontend directory
- Fix: Run
- Error: "Authentication not configured"
- Fix: Check your Azure credentials in
backend/.env - Fix: Make sure you've added the app to your workspaces
- Fix: Check your Azure credentials in
- Error: "Connection failed"
- Fix: Verify your workspace URLs are correct
- Fix: Make sure the app has Member permissions in the workspace
- Fix: Check if your workspace is Premium (required for Power BI XMLA)
- Real-time conversation with your data
- Shows AI thinking process
- Displays query attempts and corrections
- Conversation history for follow-up questions
- Auto-generated charts based on your questions
- Interactive data tables
- Export capabilities for results
- Browse your database/model structure
- View table relationships
- Explore available measures and columns
Edit backend/.env to adjust:
MAX_QUERY_ROWS=1000 # Maximum rows returned
QUERY_TIMEOUT=30 # Query timeout in seconds
CACHE_TTL=3600 # Cache duration in secondsFor production deployment, generate a strong secret key:
SECRET_KEY=your-very-strong-secret-key-here- API Documentation: Visit
http://localhost:8000/docswhen backend is running - Detailed Setup Guide: See INSTALLATION.md
- Architecture Overview: See ARCHITECTURE.md
- Deployment Guide: See DEPLOYMENT.md
If you encounter issues:
- Check the troubleshooting section above
- Review the logs in your terminal windows
- Verify your configuration files have the correct values
- Test your Azure app permissions in the Azure portal
- Open an issue on GitHub with error details
Once you have the basic setup working:
- Explore Advanced Features: Try complex queries and follow-up questions
- Connect Multiple Data Sources: Set up both Fabric and Power BI connections
- Customize the Interface: Modify the React components to fit your needs
- Deploy to Production: Follow the deployment guide for cloud hosting
This project is licensed under the MIT License - see the LICENSE file for details.
Built with ❤️ using Anthropic Claude, Microsoft Fabric, Power BI, FastAPI, and Next.js
⭐ If this project helps you, please give it a star on GitHub!
git clone https://github.com/yourusername/chat-with-data.git
cd chat-with-data# Run the setup script
chmod +x setup.sh
./setup.shBackend Setup:
cd backend
# Create virtual environment
python -m venv venv
# Activate virtual environment
# Windows:
venv\Scripts\activate
# macOS/Linux:
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Create environment file
cp .env.example .env
# Edit .env with your configuration (see Configuration section)
# Start backend
python main.pyFrontend Setup:
cd frontend
# Install dependencies
npm install
# Create environment file
cp .env.local.example .env.local
# Edit .env.local with your configuration
# Start frontend
npm run dev- Open browser to
http://localhost:3000 - Configure authentication
- Connect to your data source
- Start chatting with your data!
# AI Service
ANTHROPIC_API_KEY=your_claude_api_key_here
# Azure Authentication
AZURE_TENANT_ID=your_tenant_id
AZURE_CLIENT_ID=your_client_id
AZURE_CLIENT_SECRET=your_client_secret
# Optional: Logging
LOG_LEVEL=INFONEXT_PUBLIC_API_URL=http://localhost:8000- Go to Azure Portal → App Registrations
- Create new registration
- Configure API permissions:
- Power BI Service:
Dataset.ReadWrite.All - SQL Database:
user_impersonation
- Power BI Service:
- Generate client secret
- Note down Tenant ID, Client ID, and Client Secret
- SQL Endpoints: Lakehouse and Warehouse SQL endpoints
- Authentication: Azure AD OAuth2
- Query Language: T-SQL
- Features: Full schema discovery, table relationships, query optimization
- XMLA Endpoints: Premium workspace semantic models
- Authentication: Azure AD OAuth2
- Query Language: DAX
- Features: Measure discovery, table relationships, model metadata
- Converts natural language to SQL/DAX
- Understands business terminology
- Applies proper query optimization
- Handles complex joins and aggregations
- Analyzes query execution errors
- Automatically fixes syntax issues
- Retries with corrected queries
- Learns from failed attempts
- Remembers conversation history
- Handles follow-up questions
- Maintains query context
- Suggests related questions
For Microsoft Fabric (SQL):
- "Show me the top 10 customers by revenue"
- "What are the sales trends by month this year?"
- "Compare product performance across regions"
- "Find customers who haven't ordered in 90 days"
For Power BI (DAX):
- "What are our key performance measures?"
- "Show sales by product category"
- "Compare this year's revenue to last year"
- "What's the relationship between sales and customer satisfaction?"
- Follow-up Questions: "What about the previous month?"
- Filters: "Show only products with revenue > $100K"
- Comparisons: "How does this compare to last year?"
- Drill-downs: "Break that down by region"
chat-with-data/
├── backend/
│ ├── app/
│ │ ├── auth_service.py
│ │ ├── claude_service.py
│ │ ├── enhanced_multi_agent_service.py
│ │ ├── fabric_service.py
│ │ └── semantic_model_service.py
│ ├── main.py
│ └── requirements.txt
├── frontend/
│ ├── app/
│ │ ├── components/
│ │ │ ├── EnhancedChatInterface.tsx
│ │ │ ├── FabricConnection.tsx
│ │ │ └── PowerBIMCPConnection.tsx
│ │ └── page.tsx
│ └── package.json
└── README.md
Backend Services:
enhanced_multi_agent_service.py: Core AI orchestration and query generationfabric_service.py: Microsoft Fabric database connections and operationssemantic_model_service.py: Power BI semantic model connections and DAX executionclaude_service.py: AI service integration and prompt managementauth_service.py: OAuth2 authentication and token management
Frontend Components:
EnhancedChatInterface.tsx: Main chat interface with AI thinking processFabricConnection.tsx: Microsoft Fabric connection configurationPowerBIMCPConnection.tsx: Power BI semantic model connection setupSchemaExplorer.tsx: Database/model structure browser
Core Endpoints:
POST /api/chat/unified: Main chat endpoint for natural language queriesGET /api/connection/status: Check connection statusPOST /api/fabric/connect: Connect to Microsoft FabricPOST /api/powerbi/connect: Connect to Power BI semantic model
Authentication:
POST /api/auth/configure: Configure OAuth2 settingsGET /api/auth/status: Check authentication status
"Claude is not available"
- Check
ANTHROPIC_API_KEYin backend.env - Verify API key is valid and has sufficient credits
"Authentication not configured"
- Ensure Azure app registration is complete
- Check tenant ID, client ID, and client secret
- Verify API permissions are granted
"Connection failed"
- Verify data source URLs and credentials
- Check network connectivity
- Ensure proper licenses for Fabric/Power BI Premium
"Query generation failed"
- Check if schema was discovered correctly
- Verify AI service is responding
- Review error logs for specific issues
Enable detailed logging by setting LOG_LEVEL=DEBUG in backend .env
- Fork the repository
- Create feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Anthropic Claude: AI-powered query generation
- Microsoft: Fabric and Power BI platform support
- FastAPI: High-performance backend framework
- Next.js: React-based frontend framework
For support and questions:
- Open an issue on GitHub
- Check the troubleshooting section
- Review Azure and Microsoft Fabric documentation
Built with ❤️ by Sulaiman Ahmed
](https://github.com/sulaiman013/chat-with-your-data-fabric-PowerBI-/raw/1311777a7b34b0b54d7e1fd295505b19223572c5/Chat%20With%20Your%20Data.png)