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! ๐