This project powers the Power BI Insights Assistant — a dual-stack system built with:
- Backend: Node.js + Express server for Power BI embedding and Azure OpenAI communication
- Frontend: Streamlit app for conversational insights on Power BI data
Before running the project, make sure you have:
| Requirement | Description |
|---|---|
| Node.js | Version 18 or newer |
| npm | Comes with Node (check with npm -v) |
| Python 3.10+ | For Streamlit frontend |
| Azure OpenAI access | Endpoint, API key, deployment name, and API version |
| Power BI Workspace access | For embedding and exporting report visuals |
| config.json | Contains your Power BI workspace & report IDs |
cd backend
npm installpip install -r requirements.txt💡 The
node_modules/folder is excluded from Git via.gitignore. If missing, just runnpm install.
Create a .env file inside the backend folder:
# Azure OpenAI setup
AZURE_OPENAI_ENDPOINT=<your-endpoint>
AZURE_OPENAI_API_KEY=<your-api-key>
AZURE_OPENAI_DEPLOYMENT=<your-deployment-name>
AZURE_OPENAI_API_VERSION=<your-api-version>
# (Optional) Power BI configuration
WORKSPACE_ID=<your-workspace-id>
REPORT_ID=<your-report-id>Note The endpoint must only contain the base URL — no
/openai/deployments/...in it.
cd backend
npm startBackend runs by default on http://localhost:5300.
cd streamlit_app
streamlit run main.pyFrontend runs on http://localhost:8501.
Check these endpoints in your browser:
http://localhost:5300/debug/azure/env
http://localhost:5300/debug/azure/deployments
✅ If they respond with JSON, your backend and Azure connection are working.
- Frontend (Streamlit) embeds your Power BI report inside a dashboard panel.
- When Power BI loads or filters change, the frontend exports all visuals as CSV.
- The frontend auto-sends them to the backend:
POST /api/visual-data/upload - When the user asks a question (e.g., “Why did arrivals drop this week?”), Streamlit calls:
POST /api/ask - The backend:
- Retrieves cached CSVs
- Summarizes them via
chatHelper.js - Calls Azure OpenAI using your
.envcredentials - Returns a concise, data-grounded answer
├─ backend/
│ ├─ src/
│ │ ├─ server.js # Main Express server
│ │ ├─ aiHelper.js # Azure OpenAI integration + caching
│ │ ├─ chatHelper.js # CSV summarization logic
│ │ ├─ embedConfigService.js # Power BI embed config
│ │ └─ utils.js # Helper utilities
│ ├─ public/ # Static JS/CSS for embedding
│ ├─ package.json # Backend dependencies
│ ├─ .env.example # Example Azure OpenAI vars
│ └─ .gitignore # Ignores node_modules, env, logs
│
├
│─ main.py # Streamlit entrypoint
│─ mockinsights.json # Fallback mock data (if backend offline)
│─ requirements.txt # Python dependencies
│
│
├─ .gitignore
└─ README.md # (This file)
| Command | Description |
|---|---|
npm install |
Install backend dependencies |
npm start |
Run backend server |
pip install -r requirements.txt |
Install Streamlit dependencies |
streamlit run main.py |
Run Streamlit frontend |
git rm -r --cached node_modules |
Remove tracked node_modules |
nodemon src/server.js |
Auto-reload backend on change |
| Symptom | Cause | Fix |
|---|---|---|
Error: Azure call failed [404] |
Endpoint includes /openai/deployments/... |
Use only base URL in .env |
Error: Azure OpenAI env vars missing |
.env not found |
Restart after adding .env |
401 Unauthorized |
Wrong header type for API Management | Use Ocp-Apim-Subscription-Key (auto-handled) |
Cannot find module 'node-fetch' |
Dependency missing | Run npm install node-fetch@2 |
| Streamlit shows “Backend error” | Backend not running or port mismatch | Check backend logs and backend_url in frontend |
- Auto-restart backend:
npm i -g nodemon nodemon src/server.js
- Test Azure call manually:
curl -i -X POST "$AZURE_OPENAI_ENDPOINT/openai/deployments/$AZURE_OPENAI_DEPLOYMENT/chat/completions?api-version=$AZURE_OPENAI_API_VERSION" -H "Ocp-Apim-Subscription-Key: $AZURE_OPENAI_API_KEY" -H "Content-Type: application/json" -d '{ "messages": [{"role":"user","content":"ping"}] }'
cd backend && npm install- Add
.envwith Azure credentials npm startcd streamlit_app && pip install -r requirements.txtstreamlit run main.py- Visit http://localhost:8501 and chat with your Power BI dashboard 🚀