💼 Data Consulting Business Analysis Agent

AI-Powered Market Intelligence & Competitive Analysis System

Python 3.9+ Gemini 2.0 Flash Tavily API Matplotlib NetworkX

🔍 About This Code Showcase

This curated code snippet demonstrates how the Data Consulting Business Analysis Agent performs automated market research, competitor intelligence gathering, and strategic opportunity identification for consulting firms.

Full deployment scripts, API credentials, and proprietary details are omitted for clarity and security. This showcase highlights the core multi-agent orchestration and strategic analysis algorithms.

📖 Core Algorithm: Industry Research Agent

The Industry Research Agent discovers market trends, demand signals, and emerging technologies using web-based intelligence:

🔍 industry_research_agent.py
def industry_research_agent() -> dict: """ Researches current data analytics consulting industry trends. This agent transforms days of manual research into 10-15 minutes of automated intelligence gathering. It discovers: - Market trends with growth rate estimation - Key technologies driving demand - Emerging service opportunities Returns: { 'summary': str, 'trends': list, 'growth_rates': dict, 'key_technologies': list, 'visualization_path': str } """ log_agent_title("Industry Research Agent", "🔍") print_html("Analyzing data analytics consulting market trends...", "Status", "blue") # Multi-angle search strategy for comprehensive coverage queries = [ "data analytics consulting trends 2024 2025 market growth", "emerging data analytics services AI machine learning", "data consulting demand business intelligence cloud analytics" ] all_research = [] for query in queries: print(f"🌐 Searching: {query}") results = search_web(query, max_results=3) all_research.extend(results) # Compile research into structured text research_text = "\n\n".join([ f"Source: {r['title']}\n{r['content'][:400]}..." for r in all_research[:8] ]) # Analyze with LLM to extract structured insights analysis_prompt = f"""You are a data analytics consulting industry analyst. Web Research Results: {research_text} Analyze the data analytics consulting industry and extract: 1. TOP 8 MARKET TRENDS with growth rates (estimate based on research) 2. KEY TECHNOLOGIES driving demand 3. MARKET SUMMARY (3-4 sentences) Respond ONLY with valid JSON in this exact format: {{ "trends": [ {{"name": "AI/ML Analytics", "growth_rate": 85, "description": "..."}}, {{"name": "Real-time Analytics", "growth_rate": 70, "description": "..."}} ], "key_technologies": ["Python", "Spark", "Snowflake", "Power BI", "..."], "summary": "Market summary here..." }} Ensure growth_rate is a number between 0-100. """ try: response = model.generate_content(analysis_prompt) json_match = re.search(r'\{.*\}', response.text, re.DOTALL) if json_match: analysis = json.loads(json_match.group(0)) # Extract data for visualization trend_names = [t['name'] for t in analysis.get('trends', [])] growth_rates = [t['growth_rate'] for t in analysis.get('trends', [])] # Create trend growth visualization viz_path = "" if trend_names and growth_rates: viz_path = create_trend_chart({ 'trends': trend_names, 'growth_rates': growth_rates }) return { 'summary': analysis.get('summary', 'No summary available'), 'trends': analysis.get('trends', []), 'key_technologies': analysis.get('key_technologies', []), 'visualization_path': viz_path } except Exception as e: return {'summary': f"Analysis error: {str(e)}", 'trends': []}

🕵️ Competitor Intelligence Engine

The Competitor Intelligence Agent maps the competitive landscape and identifies capability gaps:

🔎 competitor_intelligence_agent.py
def competitor_intelligence_agent(industry_trends: list) -> dict: """ Analyzes competitors and identifies white-space opportunities. This agent creates a competitive capability matrix showing: - Who offers which services (capability mapping) - Which capabilities are oversaturated (red ocean) - Which capabilities are underserved (blue ocean) Args: industry_trends: List of trend objects from industry research Returns: { 'summary': str, 'competitors': list, 'capability_matrix': dict, 'gaps': list, # WHITE-SPACE OPPORTUNITIES 'visualization_path': str } """ log_agent_title("Competitor Intelligence Agent", "🕵️") # Search for competitors across multiple angles queries = [ "top data analytics consulting firms 2024 services", "leading business intelligence consulting companies capabilities", "data science consulting firms AI ML offerings" ] all_research = [] for query in queries: results = search_web(query, max_results=3) all_research.extend(results) research_text = "\n\n".join([ f"Source: {r['title']}\n{r['content'][:400]}..." for r in all_research[:8] ]) # Extract key capabilities from trends trend_names = [t.get('name', '') for t in industry_trends[:6]] # Analyze competitors and map capabilities competitor_prompt = f"""You are a competitive intelligence analyst for data analytics consulting. Web Research: {research_text} Key Industry Capabilities: {', '.join(trend_names)} Identify: 1. TOP 10 COMPETITORS in data analytics consulting 2. Map each competitor's capabilities (1=offers, 0=doesn't offer) 3. Identify WHITE-SPACE GAPS (capabilities no one offers well) Respond ONLY with valid JSON: {{ "competitors": [ {{"name": "Deloitte Analytics", "size": "Large", "focus": "Enterprise AI"}}, {{"name": "McKinsey Analytics", "size": "Large", "focus": "Strategy + Data"}} ], "capabilities": ["AI/ML", "Cloud", "Real-time", "Visualization", "Governance", "Edge"], "matrix": [ [1, 1, 1, 1, 0, 0], [1, 1, 0, 1, 1, 0] ], "gaps": [ {{"capability": "AI Governance", "reason": "Most firms offer AI but not governance"}} ], "summary": "Competitive landscape summary..." }} Matrix rows = competitors, columns = capabilities. """ try: response = model.generate_content(competitor_prompt) json_match = re.search(r'\{.*\}', response.text, re.DOTALL) if json_match: analysis = json.loads(json_match.group(0)) # Create competitor matrix heatmap visualization viz_path = "" if analysis.get('competitors') and analysis.get('matrix'): competitor_names = [c['name'] for c in analysis['competitors']] viz_path = create_competitor_matrix({ 'competitors': competitor_names, 'capabilities': analysis['capabilities'], 'matrix': analysis['matrix'] }) # Print white-space opportunities if analysis.get('gaps'): gaps_text = "\n".join([ f"- {g['capability']}: {g['reason']}" for g in analysis['gaps'][:5] ]) print_html(gaps_text, "🎯 White-Space Opportunities", "orange") return { 'summary': analysis.get('summary', 'No summary available'), 'competitors': analysis.get('competitors', []), 'gaps': analysis.get('gaps', []), 'visualization_path': viz_path } except Exception as e: return {'summary': f"Analysis error: {str(e)}", 'competitors': []}

💡 Opportunity Analyzer Agent

The Opportunity Analyzer synthesizes insights to identify specific market entry opportunities:

🎯 opportunity_analyzer_agent.py
def opportunity_analyzer_agent(industry_data: dict, competitor_data: dict) -> dict: """ Identifies specific opportunities using a 2x2 strategic matrix. The opportunity map plots each service opportunity on: - X-axis: Competitive Intensity (0=blue ocean, 1=red ocean) - Y-axis: Market Attractiveness (0=low value, 1=high value) Sweet Spot = High Attractiveness + Low Competition Returns: { 'summary': str, 'opportunities': list, 'recommendations': list, 'visualization_path': str # 2x2 opportunity map } """ log_agent_title("Opportunity Analyzer Agent", "💡") # Compile intelligence from previous agents trends_summary = "\n".join([ f"- {t['name']} (Growth: {t['growth_rate']}%): {t.get('description', '')}" for t in industry_data.get('trends', [])[:5] ]) gaps_summary = "\n".join([ f"- {g['capability']}: {g['reason']}" for g in competitor_data.get('gaps', [])[:5] ]) # Strategic synthesis prompt opportunity_prompt = f"""You are a strategy consultant for a NEW data analytics consulting firm. MARKET INTELLIGENCE: High-Growth Trends: {trends_summary} Competitor Gaps (White-Space): {gaps_summary} Identify 5-7 SPECIFIC OPPORTUNITIES for a new firm. For each opportunity, assess: - Market Attractiveness (0.0-1.0): Growth potential, pricing power - Competitive Intensity (0.0-1.0): How crowded? (0=blue ocean, 1=red ocean) Respond ONLY with valid JSON: {{ "opportunities": [ {{ "name": "AI Governance Consulting", "attractiveness": 0.85, "competition": 0.30, "rationale": "High demand, few providers, regulatory tailwinds", "target_clients": "Fortune 500 financial services", "estimated_deal_size": "$150K-$500K" }} ], "top_recommendations": [ "Focus on [niche] because...", "Avoid [area] due to..." ], "summary": "Strategic opportunity summary..." }} Prioritize opportunities in the "sweet spot" (high attractiveness, low competition). """ try: response = model.generate_content(opportunity_prompt) json_match = re.search(r'\{.*\}', response.text, re.DOTALL) if json_match: analysis = json.loads(json_match.group(0)) # Create 2x2 opportunity map visualization viz_path = "" if analysis.get('opportunities'): opp_names = [o['name'] for o in analysis['opportunities']] attractiveness = [o['attractiveness'] for o in analysis['opportunities']] competition = [o['competition'] for o in analysis['opportunities']] viz_path = create_opportunity_map({ 'opportunities': opp_names, 'attractiveness': attractiveness, 'competition': competition }) return { 'summary': analysis.get('summary', 'No summary'), 'opportunities': analysis.get('opportunities', []), 'recommendations': analysis.get('top_recommendations', []), 'visualization_path': viz_path } except Exception as e: return {'summary': f"Analysis error: {str(e)}", 'opportunities': []}

⚙️ Technical Implementation Notes

Key Algorithms & Innovations

Why This Approach Works

Output Package

Real-World Use Cases