Skip to content

adeyemijosh/BizAgent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🤖 BizAgent :AI Business Intelligence Agent

Turn your business data into plain English answers. No SQL. No dashboards. Just ask.


What Is BizAgent?

BizAgent is an AI-powered business intelligence agent that connects to your existing data sources — Postgres, MySQL, Shopify, Stripe — and lets anyone in your business ask questions about their data in plain English and get instant, accurate answers.

Instead of hiring a data analyst, building a dashboard, or learning SQL, a business owner can just type:

"Why did revenue drop last Tuesday?" "Which products have the highest return rate this month?" "Who are my top 20 customers by lifetime value?"

And get a clear, actionable answer in seconds — with the SQL that ran behind it, a chart recommendation, and a follow-up insight they probably didn't think to ask.


How Businesses Use BizAgent

E-commerce Businesses

Connect your Shopify, WooCommerce, or custom e-commerce database and get instant insights:

  • Track sales performance and identify trends
  • Monitor inventory levels and product performance
  • Analyze customer behavior and purchasing patterns
  • Optimize marketing campaigns and ROI

Example Questions:

  • "What was my best-selling product last month?"
  • "Which marketing channel brings the highest lifetime value customers?"
  • "Are there any unusual patterns in my refund rates?"

SaaS Companies

Connect your subscription and user data to understand your business metrics:

  • Monitor MRR, churn, and customer retention
  • Track feature adoption and usage patterns
  • Analyze customer segments and growth trends
  • Identify upsell and cross-sell opportunities

Example Questions:

  • "What's our monthly recurring revenue growth rate?"
  • "Which features are most popular among enterprise customers?"
  • "How has our churn rate changed over the past quarter?"

Restaurants & Local Businesses

Connect your POS system or sales database to optimize operations:

  • Track daily, weekly, and monthly sales trends
  • Monitor inventory and supplier performance
  • Analyze customer traffic and peak hours
  • Optimize menu pricing and offerings

Example Questions:

  • "What are our busiest hours on weekends?"
  • "Which menu items have the highest profit margins?"
  • "How do sales compare to the same period last year?"

Agencies & Service Providers

Connect client data and project management systems to improve service delivery:

  • Track project profitability and resource utilization
  • Monitor client satisfaction and engagement
  • Analyze campaign performance across clients
  • Optimize team productivity and billing

Example Questions:

  • "Which clients are most profitable this quarter?"
  • "How many billable hours did we log last month?"
  • "What's our average project completion time?"

Developers & Platforms

White-label BizAgent as your own AI data assistant:

  • Embed it into your existing business applications
  • Provide AI-powered insights to your customers
  • Create custom dashboards and reports
  • Build data-driven features into your platform

Quick Start for Businesses

1. Clone & Setup

git clone <your-repo>
cd bizagent
cp .env.example .env
# Edit .env with your Anthropic API key

2. Launch with Docker

sudo docker-compose up -d

3. Create Your Business Account

curl -X POST http://localhost:8000/api/v1/auth/register \
  -H "Content-Type: application/json" \
  -d '{"name": "My Business", "email": "admin@mybusiness.com"}'

4. Connect Your Data Source

curl -X POST http://localhost:8000/api/v1/datasources/ \
  -H "X-API-Key: your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Production DB",
    "type": "postgresql",
    "connection_string": "postgresql://user:pass@host:5432/db"
  }'

5. Start Asking Questions!

curl -X POST http://localhost:8000/api/v1/query/ \
  -H "X-API-Key: your_api_key" \
  -H "Content-Type: application/json" \
  -d '{"question": "What is my total revenue?"}'

Integration Options for Your Business

Option 1: Embeddable Chat Widget (Easiest)

Add BizAgent to any website with 2 script tags:

<!-- Configure BizAgent -->
<script>
  window.BizAgentConfig = {
    apiKey:       "biz_your_key_here",
    datasourceId: "your-datasource-uuid", // Optional
    businessName: "Acme Corp",
    theme:        "dark",                 // "dark" | "light"
    position:     "bottom-right",         // "bottom-right" | "bottom-left"
    apiBase:      "https://your-api-endpoint.com/api/v1"
  };
</script>

<!-- Load the widget -->
<script src="https://your-api-endpoint.com/bizagent.js" async></script>

Perfect for:

  • Customer support portals
  • Internal business dashboards
  • Client-facing reporting tools
  • E-commerce admin panels

Features:

  • 📱 Floating chat button
  • 💬 AI-powered Q&A
  • 🎨 Customizable themes
  • 📊 Automatic charts
  • 🔄 Conversation history
  • 📱 Mobile responsive

Option 2: Direct API Integration

Integrate BizAgent directly into your business applications:

// POST /api/v1/query/
const response = await fetch('https://your-api-endpoint.com/api/v1/query/', {
  method: 'POST',
  headers: {
    'X-API-Key': 'biz_your_key_here',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    question: "What is my total revenue?",
    datasource_id: "optional-datasource-uuid"
  })
});

const result = await response.json();
// Returns: { answer, insight, sql, chart, follow_up, latency_ms, query_id }

Perfect for:

  • Custom business intelligence tools
  • Internal reporting systems
  • Mobile applications
  • Desktop business software

Option 3: White-Label for Platforms

Platforms can embed BizAgent as their own BI feature:

  1. Create business accounts via API
  2. Generate API keys for each business
  3. Set up datasources (PostgreSQL, MySQL, etc.)
  4. Provide embeddable widget with their branding

Perfect for:

  • SaaS platforms
  • ERP and CRM systems
  • E-commerce platforms
  • Business management software

API Reference

Authentication

All API requests require an X-API-Key header with your business API key.

Business Management

# Register new business
POST   /api/v1/auth/register
# Get business info
GET    /api/v1/auth/me
# Update business settings
PUT    /api/v1/auth/me

Data Sources

# Connect database
POST   /api/v1/datasources/
# List connected databases
GET    /api/v1/datasources/
# Remove database
DELETE /api/v1/datasources/{id}

Queries

# Ask questions (authenticated)
POST   /api/v1/query/
# Widget endpoint (API key in body)
POST   /api/v1/widget/query

Widget

# Get embed code for website
GET    /api/v1/widget/snippet
# Serve widget JavaScript
GET    /bizagent.js

Example widget snippet response:

{
  "snippet": "<!-- BizAgent Widget -->\n<script>\n  window.BizAgentConfig = {\n    apiKey: \"biz_xxx\",\n    datasourceId: \"\",\n    businessName: \"My Business\",\n    theme: \"dark\",\n    position: \"bottom-right\"\n  };\n</script>\n<script src=\"https://your-api-endpoint.com/bizagent.js\" async></script>",
  "instructions": "Paste this snippet before </body> on any page of your website."
}

The Problem It Solves

Most small and mid-size businesses are sitting on valuable data they can't access. Their options today are:

  • Hire a data analyst ($80–120k/year)
  • Buy a BI tool like Tableau or Looker (complex, expensive, requires training)
  • Ask a developer to write queries (slow, creates a bottleneck)
  • Export to Excel and do it manually (error-prone, time-consuming)

BizAgent removes all of that. It plugs into your existing data in minutes and gives every business owner the same insight capability as a fully staffed data team.


What It Does

Answers questions about your data in plain English Connect your database or SaaS tools once. Then ask anything. BizAgent translates your question into SQL, runs it safely against your data, and explains the results in clear language — not just numbers.

Embeds directly into any website or dashboard Drop one <script> tag onto any page and a chat bubble appears. Your customers or team can ask questions without ever leaving your existing tools.

Exposes a clean REST API Any application can call BizAgent via API. Send a question, get a structured JSON response with the answer, insight, chart data, and a follow-up suggestion.

Sends proactive alerts Set natural language conditions like "notify me when refunds exceed 5% of orders" and BizAgent monitors your data every 15 minutes, firing alerts to email or Slack automatically.

Maintains conversation context Ask a follow-up question and BizAgent remembers what you were just discussing. No need to repeat context.


Who It Is For

Business Type How they use it
E-commerce founders Track revenue, returns, best sellers, ad ROI
SaaS companies Monitor churn, MRR, feature adoption
Restaurants & local businesses Understand margins, busy hours, top items
Agencies Track client profitability and team utilisation
Developers Embed it into any product as an AI data layer

How It Works

User types a question in plain English
         ↓
BizAgent reads your database schema
         ↓
Claude AI translates the question into SQL
         ↓
SQL runs safely (read-only) against your data
         ↓
Claude AI interprets the results
         ↓
User gets a clear answer + insight + chart suggestion

The whole round trip takes under a second for most questions.


Tech Stack

Layer Technology
AI Brain Anthropic Claude (claude-sonnet-4)
Backend API Python, FastAPI
Database PostgreSQL + SQLAlchemy
Caching & Rate Limiting Redis
Supported Datasources PostgreSQL, MySQL, Shopify, Stripe
Widget Vanilla JavaScript (zero dependencies)
Infrastructure Docker, Docker Compose, Nginx

Development Setup

Prerequisites

  • Docker & Docker Compose
  • Git

Local Development

# Clone repository
git clone <your-repo>
cd bizagent

# Copy environment file
cp .env.example .env

# Edit .env with your keys
nano .env

# Start all services
sudo docker-compose up -d

# View logs
sudo docker-compose logs -f api

# Run tests
sudo docker-compose exec api python -m pytest

# Stop services
sudo docker-compose down

Environment Variables

# Required
ANTHROPIC_API_KEY=sk-ant-api03-...

# Database (Docker defaults)
DATABASE_URL=postgresql+asyncpg://bizagent:bizagent@db:5432/bizagent
REDIS_URL=redis://redis:6379

# Optional
SENDGRID_API_KEY=...
SLACK_BOT_TOKEN=...
FROM_EMAIL=alerts@yourbusiness.com

Security & Access Control

  • API Key authentication for all requests
  • Database-level isolation (each business sees only their data)
  • Rate limiting (20-1000 requests/minute based on plan)
  • CORS support for web embedding
  • Input validation and SQL injection prevention
  • Read-only database access (no data modification)

Troubleshooting

Common Issues

"Internal server error"

  • Check API logs: sudo docker-compose logs api
  • Verify Anthropic API key has credits
  • Ensure database connection is working

"Rate limit exceeded"

  • Upgrade your plan for higher limits
  • Implement request queuing in your app

Widget not loading

  • Check CORS headers
  • Verify API key is correct
  • Ensure JavaScript is loaded after DOM ready

Database connection failed

  • Verify connection string format
  • Check database credentials
  • Ensure database is accessible from Docker

Getting Help

  • Check API documentation at http://localhost:8000/docs
  • View logs: sudo docker-compose logs -f
  • Test endpoints: http://localhost:8000/health

Business Integration Examples

E-commerce Integration

// Connect Shopify data
const shopifyConfig = {
  name: "Shopify Store",
  type: "shopify",
  config: {
    shop: "mystore.myshopify.com",
    access_token: "shpat_..."
  }
};

// Ask business questions
const questions = [
  "What was my revenue last week?",
  "Which products have the highest return rate?",
  "How many new customers did I get this month?"
];

SaaS Metrics Integration

// Connect PostgreSQL with user data
const saasConfig = {
  name: "User Database",
  type: "postgresql",
  config: {
    host: "db.company.com",
    port: 5432,
    database: "analytics",
    user: "readonly_user",
    password: "secure_password"
  }
};

// Monitor key metrics
const metrics = [
  "What is our monthly recurring revenue?",
  "How many users churned this month?",
  "Which features are most popular?"
];

Restaurant POS Integration

// Connect MySQL with sales data
const posConfig = {
  name: "POS System",
  type: "mysql",
  config: {
    host: "pos.company.com",
    port: 3306,
    database: "sales",
    user: "readonly_user",
    password: "secure_password"
  }
};

// Optimize operations
const insights = [
  "What are our busiest hours?",
  "Which menu items sell best on weekends?",
  "How do sales compare to last month?"
];

Next Steps for Your Business

  1. Start Small: Begin with one data source and a few key questions
  2. Scale Up: Add more data sources and integrate into your workflows
  3. Customize: Tailor the widget and API to your specific business needs
  4. Expand: Share insights across your team and improve decision-making

BizAgent grows with your business, from startup to enterprise, providing the intelligence you need to make data-driven decisions without the complexity of traditional BI tools.


Ready to get started? Contact us for enterprise deployment options and custom integrations.

About

Turn your business data into plain English answers. No SQL. No dashboards. Just ask.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors