Skip to content

brightdata/competitive-intelligence

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ€– Multi-Agent Competitive Intelligence Platform

Python FastAPI React TypeScript License

Transform weeks of manual competitive research into minutes of AI-powered analysis using autonomous agents and enterprise-grade web scraping.

Platform Demo

🌟 Features

  • πŸ€– Multi-Agent Workflow: Three specialized AI agents working in harmony

    • πŸ“Š Researcher Agent: Data collection with Bright Data web scraping
    • πŸ” Analyst Agent: Strategic SWOT analysis and threat assessment
    • πŸ“ Writer Agent: Executive-ready competitive intelligence reports
  • 🌊 Real-Time Streaming: Live progress updates and tool call monitoring

  • ⚑ Enterprise-Grade: Built with FastAPI, React, and TypeScript

  • 🎯 Comprehensive Analysis: Pricing, leadership, market position, and strategy

  • πŸ“± Beautiful UI: Vercel-inspired design with responsive layout

  • πŸ”§ Production Ready: Docker support and scalable architecture

πŸš€ Quick Start

Prerequisites

1. Clone the Repository

git clone https://github.com/brightdata/competitive-intelligence.git
cd competitive-intelligence

2. Backend Setup

# Install Python dependencies
cd api && pip install -r requirements.txt

# Set environment variables
export GEMINI_API_KEY="your_gemini_api_key"
export BRIGHTDATA_API_KEY="your_brightdata_api_key"

# Start the API server
python app.py

The API will be available at http://localhost:8000

3. Frontend Setup

# Navigate to frontend directory
cd ci-agent-ui

# Install dependencies
npm install

# Start development server
npm run dev

The frontend will be available at http://localhost:5173

4. Try It Out!

  1. Open the frontend in your browser
  2. Select a demo scenario (Slack, Notion, Figma) or enter a custom company
  3. Click "Start Analysis" and watch the AI agents work in real-time
  4. Get comprehensive competitive intelligence in minutes!

πŸ“‹ Table of Contents

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   πŸ“Š Researcher │───▢│   πŸ” Analyst    │───▢│   πŸ“ Writer     β”‚
β”‚     Agent       β”‚    β”‚     Agent       β”‚    β”‚     Agent       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚                       β”‚                       β”‚
         β–Ό                       β–Ό                       β–Ό
   Data Collection      Strategic Analysis       Report Generation
   - Web scraping       - SWOT analysis         - Executive summary
   - Market research     - Threat assessment     - Recommendations
   - Company intel       - Competitive position  - Action items

                              β–²
                              β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚   🌐 FastAPI    β”‚
                    β”‚   Backend       β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β–²
                              β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚   βš›οΈ React      β”‚
                    β”‚   Frontend      β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Tech Stack

Backend:

  • FastAPI: Modern, fast web framework for building APIs
  • Strands Agents: Autonomous AI agent framework
  • Bright Data: Enterprise web scraping and data collection
  • Google Gemini 2.0: Advanced language model for analysis
  • LiteLLM: Unified interface for multiple AI models

Frontend:

  • React 18: Modern UI library with hooks
  • TypeScript: Type-safe JavaScript development
  • Vite: Fast build tool and development server
  • Tailwind CSS: Utility-first CSS framework
  • shadcn/ui: Beautiful, accessible component library

πŸ› οΈ Installation

Development Setup

  1. Clone and setup backend:
git clone https://github.com/brightdata/competitive-intelligence.git
cd competitive-intelligence

# Create virtual environment
python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate

# Install dependencies
pip install -r requirements-api.txt
  1. Setup frontend:
cd ci-agent-ui
npm install
  1. Environment configuration:
# Copy example environment file
cp .env.example .env

# Edit .env with your API keys
GEMINI_API_KEY=your_gemini_api_key_here
BRIGHTDATA_API_KEY=your_brightdata_api_key_here
  1. Start development servers:
# Terminal 1: Backend
python app.py

# Terminal 2: Frontend
cd ci-agent-ui && npm run dev

Production Setup

See our Docker Deployment section for production deployment instructions.

πŸ“š API Documentation

Base URL

http://localhost:8000

Endpoints

Health Check

GET /health

Competitive Analysis (Streaming)

POST /analyze/stream
Content-Type: application/json

{
  "competitor_name": "Slack",
  "competitor_website": "https://slack.com",
  "stream": true
}

Get Demo Scenarios

GET /demo-scenarios

Session Management

GET /sessions
GET /sessions/{session_id}

Response Format

{
  "competitor": "Slack",
  "website": "https://slack.com",
  "research_findings": "Comprehensive research data...",
  "strategic_analysis": "SWOT and competitive analysis...",
  "final_report": "Executive summary and recommendations...",
  "timestamp": "2025-09-17T10:30:00Z",
  "status": "success"
}

Interactive API Documentation

🎨 Frontend Guide

Key Components

  • CompetitiveIntelligenceForm: Main analysis interface with real-time streaming
  • DemoScenarios: Pre-configured company examples
  • Header: Navigation and branding
  • ProgressTracker: Live agent workflow visualization

Available Scripts

npm run dev          # Start development server
npm run build        # Build for production
npm run preview      # Preview production build
npm run lint         # Run ESLint

Customization

Styling: Modify tailwind.config.js for theme customization Components: Add new shadcn/ui components with npx shadcn@latest add [component] API Endpoint: Update API_BASE_URL in component files

βš™οΈ Configuration

Environment Variables

Variable Description Required Default
GEMINI_API_KEY Google AI Studio API key Yes -
BRIGHTDATA_API_KEY Bright Data API key Yes -
GEMINI_MODEL_NAME Gemini model version No gemini-2.0-flash
API_HOST API server host No 0.0.0.0
API_PORT API server port No 8000
LOG_LEVEL Logging level No info

Agent Configuration

Each agent can be customized by modifying their system prompts in api/ci_agent.py:

  • Researcher Agent: Data collection and web scraping behavior
  • Analyst Agent: Analysis depth and strategic focus
  • Writer Agent: Report structure and formatting

🐳 Docker Deployment

Using Docker Compose

# Start all services
docker-compose up -d

# View logs
docker-compose logs -f

# Stop services
docker-compose down

Manual Docker Build

Backend:

cd api
docker build -t ci-backend .
docker run -p 8000:8000 \
  -e GEMINI_API_KEY=your_key \
  -e BRIGHTDATA_API_KEY=your_key \
  ci-backend

Frontend:

cd ci-agent-ui
docker build -t ci-frontend .
docker run -p 3000:80 ci-frontend

Production Considerations

  • Use environment-specific configuration files
  • Implement proper logging and monitoring
  • Set up SSL/TLS certificates
  • Configure rate limiting and security headers
  • Use a reverse proxy (nginx/Cloudflare)

πŸ’» Examples

Python Client

import requests

# Start streaming analysis
response = requests.post(
    "http://localhost:8000/analyze/stream",
    json={
        "competitor_name": "Slack",
        "competitor_website": "https://slack.com",
        "stream": True
    },
    stream=True
)

for line in response.iter_lines(decode_unicode=True):
    if line.startswith("data: "):
        event = json.loads(line[6:])
        print(f"Event: {event['type']}")
        
        if event['type'] == 'complete':
            print("Analysis completed!")
            break

JavaScript/Fetch

const response = await fetch('/analyze/stream', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    competitor_name: 'Slack',
    stream: true
  })
});

const reader = response.body.getReader();
const decoder = new TextDecoder();

while (true) {
  const { value, done } = await reader.read();
  if (done) break;
  
  const chunk = decoder.decode(value);
  // Process streaming events
}

CLI Usage

# Run interactive demo
python api/ci_agent.py

# Analyze specific competitor
python -c "
from api.ci_agent import MultiAgentCompetitiveIntelligence
ci = MultiAgentCompetitiveIntelligence()
result = ci.run_competitive_intelligence_workflow('Slack')
print(result['final_report'])
"

πŸ§ͺ Testing

Backend Tests

cd api
pip install pytest httpx
pytest tests/

Frontend Tests

cd ci-agent-ui
npm test
npm run test:coverage

Integration Tests

# Start services
docker-compose up -d

# Run end-to-end tests
npm run test:e2e

🀝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

Development Workflow

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes and add tests
  4. Commit with conventional commits: git commit -m "feat: add amazing feature"
  5. Push to your fork: git push origin feature/amazing-feature
  6. Open a Pull Request

Code Style

  • Python: Follow PEP 8, use Black formatter
  • TypeScript: Follow ESLint configuration
  • Commits: Use Conventional Commits

πŸ“ Changelog

See CHANGELOG.md for a detailed history of changes.

πŸ› Issues and Support

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

πŸ”— Links


Built with ❀️ by Bright Data

⭐ Star this repo if you find it useful!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published