LangGraph-based multi-agent system for Amazon & Flipkart ad budget optimization.
Campaign Data
│
▼
┌─────────────────┐
│ Market Analyst │ → ACoS, ROAS, CTR analysis per channel
└────────┬────────┘
▼
┌─────────────────┐
│ Budget Optimizer│ → ROAS-weighted reallocation across 6 channels
└────────┬────────┘
▼
┌─────────────────┐
│ Bid Strategy │ → CPC/CPM bids, dayparting, match type shifts
└────────┬────────┘
▼
┌─────────────────┐
│ Risk Guard │ → ACoS cap, overspend, inventory stockout check
└────────┬────────┘
▼
┌─────────────────┐
│ Execution Plan │ → Final investment brief + monitoring triggers
└─────────────────┘
pip install langgraph langchain-groq langchain-core rich tabulateGet a free Groq API key at: https://console.groq.com
export GROQ_API_KEY=your_key_here# Interactive demo (recommended for presentations)
python demo.py
# Direct run with default data
python agents.py| # | Scenario | Budget | Season |
|---|---|---|---|
| 1 | Pre-Diwali Push | ₹5,00,000 | High Competition |
| 2 | Post-Sale Cleanup | ₹2,00,000 | Low Efficiency |
| 3 | New Product Launch | ₹1,50,000 | Zero History |
| 4 | Custom Input | User-defined | Any |
Amazon: Sponsored Products · Sponsored Brands · DSP Display
Flipkart: Product Ads · PLA Ads · Brand Ads
| Agent | Input | Output |
|---|---|---|
| Market Analyst | Raw KPIs | ROAS ranking, red flags |
| Budget Optimizer | Analysis + total budget | New spend per channel |
| Bid Strategy | Budget plan + competition | CPC/CPM per channel, dayparting |
| Risk Guard | Full plan | Risk table + GO/HOLD/REVISE |
| Execution Planner | All outputs | Final brief + 3 actions this week |
To plug in real data, replace CAMPAIGN_DATA in agents.py with your Amazon Ads API / Flipkart Ads API response.
To add a new agent, add a node to the StateGraph in build_graph().