A powerful LangGraph-based AI agent that analyzes business data, provides actionable insights, and generates comprehensive reports with visual dashboards.
- 📊 Daily Profit Analysis: Real-time profit/loss calculations with trend comparisons
- 💰 Customer Acquisition Cost (CAC) Monitoring: Smart alerts when CAC increases >20%
- 📈 Revenue & Cost Trend Analysis: Monitors percentage changes with intelligent thresholds
- 🎯 Automated Recommendations: AI-powered actionable business advice
⚠️ Smart Alerts: Proactive warnings for concerning business metrics- 📄 JSON Export: Structured data output for integration with other systems
- 🌐 Interactive Dashboard: Beautiful HTML visualization of your business metrics
pip install -r requirements.txt# Simple execution - generates JSON output
python agent.pyThis command will:
- ✅ Analyze your business data
- 📁 Generate structured JSON output files
- 🎨 Create an interactive HTML dashboard
- 📊 Display comprehensive business insights
- JSON Output: Check generated
.jsonfiles for structured data - Visual Dashboard: Open
business_dashboard.htmlin your browser for interactive charts - Console Output: View summary directly in terminal
from agent import run_business_analysis
# Your business data
data = {
"daily_revenue": 5000,
"daily_cost": 3000,
"number_of_customers": 50,
"previous_day_revenue": 4500,
"previous_day_cost": 2500,
"previous_day_customers": 45
}
result = run_business_analysis(data)
print(result)python test_agent.pyThe agent automatically generates structured JSON files containing:
- Detailed profit/loss analysis
- CAC calculations and trends
- Revenue and cost metrics
- Automated recommendations
- Business alerts and warnings
View your business metrics through our beautiful dashboard:
- 📈 Real-time charts and graphs
- 🎯 Key performance indicators
- 📊 Trend analysis visualizations
- 🚨 Alert notifications
- 💡 Recommendation highlights
This project is fully configured for LangGraph Studio:
- Import the entire project folder
- Test the agent interactively
- Visualize the workflow graph
- Debug and optimize performance
Configuration file: langgraph.json
{
"daily_revenue": 5000,
"daily_cost": 3000,
"number_of_customers": 50,
"previous_day_revenue": 4500,
"previous_day_cost": 2500,
"previous_day_customers": 45
}{
"profit_loss_status": {
"daily_profit": 2000,
"status": "positive",
"revenue_change_percent": 11.11,
"cost_change_percent": 20.0
},
"customer_acquisition": {
"current_cac": 60.0,
"cac_change_percent": 8.0,
"cac_alert": false
},
"alerts": [
"💰 Costs increased significantly"
],
"recommendations": [
"✅ Maintain current profitable operations",
"📈 Strong revenue growth detected",
"🎯 Consider scaling operations"
],
"summary": {
"total_alerts": 1,
"total_recommendations": 4,
"analysis_date": "2024-01-01"
}
}- Daily Profit:
daily_revenue - daily_cost - CAC:
daily_cost / number_of_customers - Revenue Change:
(current - previous) / previous × 100 - Cost Change:
(current - previous) / previous × 100
| Condition | Alert Trigger |
|---|---|
| Negative Profit | Immediate alert |
| CAC Increase | >20% increase |
| Revenue Decline | >10% decrease |
| Cost Spike | >15% increase |
- 💡 Cost optimization strategies
- 📈 Marketing budget adjustments
- 🎯 Scaling recommendations
⚠️ Risk mitigation advice
Input → Processing → Analysis → Recommendations → Output
↓ ↓ ↓ ↓ ↓
Validate Calculate Generate Format Export
Data Metrics Insights Report Files
- 🧠 LangGraph: Workflow orchestration and state management
- 🐍 Python: Business logic and calculations
- 📊 JSON: Data serialization and API integration
- 🌐 HTML/CSS/JS: Interactive dashboard visualization
- 🧪 unittest: Comprehensive testing framework
Comprehensive test coverage includes:
- ✅ Profitable business scenarios
- ❌ Loss scenarios and edge cases
- 📊 High CAC alert testing
- 🔢 Metric calculation accuracy
- 💡 Recommendation logic validation
- 📥 Input validation and error handling
- 📤 Output format compliance
# Quick daily analysis
python agent.py
# Check dashboard
open business_dashboard.html# API integration example
import requests
from agent import run_business_analysis
# Fetch data from your business system
business_data = fetch_daily_metrics()
# Analyze with AI agent
insights = run_business_analysis(business_data)
# Send to dashboard or notification system
update_business_dashboard(insights)- Trend Analysis: Multi-day trend detection
- Predictive Insights: Future performance indicators
- Custom Thresholds: Configurable alert levels
- Export Options: Multiple output formats
- Real-time Updates: Live dashboard refresh
- Fork the repository
- Create a feature branch
- Add comprehensive tests
- Submit a pull request
MIT License - Open source and free to use for commercial projects.
python agent.py- Run analysis- Open
business_dashboard.html- View results - Check JSON files - Integrate with your systems
Ready to transform your business intelligence? Start analyzing now! 🚀