Overview
Production-ready multi-agent AI system that automates competitive market research and analysis. Built seven specialized agents orchestrated by LangGraph to work together through parallel execution, reducing manual research time from 6-8 hours to under 2 minutes.
Manual competitive research is time-intensive and prone to inconsistencies. This system coordinates seven AI agents - each with a specific role - to gather data, analyze competitors, validate findings, and generate comprehensive reports with interactive visualizations.
Performance Metrics
- 200x+ faster: 6-8 hours → 1.75 minutes
- 30% speedup: Parallel execution (105s vs 150s sequential)
- 100% reliability: Success rate with retry logic and fallbacks
- $0/month: 100% free tier with quota protection
Multi-Agent Architecture
Built seven specialized agents that work together through strategic coordination:
1. Coordinator Agent - Creates strategic research plan with objectives, search priorities, and comparison angles that guide all downstream agents
2. Web Research & Financial Intelligence (run in parallel) - Web Research gathers competitive intelligence while Financial Intelligence researches funding, revenue, and growth data simultaneously
3. Data Analyst - Combines research from both sources to create SWOT analysis, feature comparison matrices, and market positioning insights
4. Fact Checker - Validates claims and triggers Human-in-the-Loop approval gates if quality issues are detected
5. Content Synthesizer & Data Visualization (run in parallel) - Content Synthesizer writes executive summary and detailed report while Data Visualization generates Chart.js specifications for interactive charts
The Coordinator generates structured guidance (objectives, search keywords, comparison dimensions) that all agents actually use to adapt their behavior - not just documentation for users. This makes the workflow more reliable than LLM-based dynamic routing.
Key Features
Strategic Coordination
The Coordinator agent creates a research strategy that all other agents follow. It defines research objectives, assigns specific search keywords per company, determines which financial metrics to prioritize, and sets comparison angles for analysis. This guided approach produces more focused results than generic research.
Parallel Execution Architecture
Two parallel execution stages deliver 30% performance improvement. Stage 1 runs Web Research and Financial Intelligence simultaneously. Stage 2 runs Content Synthesizer and Data Visualization in parallel. LangGraph handles synchronization and state merging automatically.
Real-Time Monitoring
WebSocket integration provides live updates as each agent executes. Users see progress in real-time with loading states, status updates, and completion notifications. The Fact Checker can pause workflow for human review if quality issues are detected, with automatic timeout to prevent blocking.
Production Resilience
Built with retry logic (3 attempts with exponential backoff), rate limiting to protect API quotas, and graceful degradation when services fail. Redis caching provides 5-10x speedup on repeated queries while protecting the Tavily search quota.
Complete Output Suite
- Interactive visualizations (Chart.js bar, line, pie, doughnut charts)
- PDF export with embedded charts
- Multiple formats (PDF, Markdown, JSON)
- Research strategy summary
- Comprehensive competitive analysis reports
Technical Achievements
Parallel State Management
Implemented LangGraph's state management patterns to enable safe concurrent execution. Agents running in parallel either accumulate data to list fields (research findings, cost tracking) or write to separate fields (analysis vs visualizations). This prevents race conditions while achieving 30% speedup.
Accurate Token Counting
Integrated tiktoken for precise token counting instead of character-based estimation. This eliminated 22.9% error rate and enables accurate cost tracking per agent, proper context window management, and automatic tokenizer selection based on the model being used.
Microservices Architecture
Web Research agent integrates with the Enterprise RAG Knowledge Base API as a tool, demonstrating composable systems where projects can leverage each other's capabilities. This reuses existing data and shows practical microservices patterns.
Free Tier Optimization
Designed entire system to run on free tiers through strategic caching, rate limiting, and quota protection. Redis caching achieves 40-70% hit rate on search queries, protecting the Tavily API quota while providing 5-10x speedup. Rate limiting prevents accidental quota exhaustion.
Production Code Quality
Built with comprehensive error handling, retry logic with exponential backoff, graceful service degradation, configuration validation, and type safety throughout. No deprecation warnings, no bare exception handlers, no dead code.
What I Learned
Building a multi-agent system taught me that coordination is more valuable than routing. Initially planned for the Coordinator to dynamically decide which agents to run based on the query. But having all agents run with strategic guidance proved more reliable - consistent workflow execution, agents that adapt their behavior based on objectives, and users can see the research strategy upfront.
State management in parallel systems is nuanced. Learned that agents running concurrently need careful design - either accumulate to list fields or write to completely different fields. LangGraph's operator.add pattern makes this safe and automatic, but you have to design your state schema with parallelism in mind from the start.
Token counting accuracy matters more than I expected. Switched from character-based estimation to tiktoken and discovered we were undercounting by 72% in some agents. This affects context window management, cost tracking, and even model selection since different models need different tokenizers.
Also learned that free tier constraints force good architecture. Rate limiting, caching, graceful degradation, quota protection - these aren't workarounds, they're production patterns that apply to paid systems too. Building under constraints teaches optimization that companies value.
Tech Stack
Backend: FastAPI, LangGraph, Ollama, Groq Search: Tavily API, DuckDuckGo Caching: Redis Cloud Frontend: Next.js 16, TypeScript, Tailwind CSS, Chart.js Real-Time: WebSocket Deployment: Render, Vercel