Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:ALwrity ALwrity ContentGapAnalyzer analyze comprehensive gap

From Leeroopedia
Knowledge Sources
Domains SEO, Content_Gap, Competitor_Analysis
Last Updated 2026-10-24 00:00 GMT

Overview

Concrete tool for comprehensive content gap analysis across SERP landscape, keyword expansion, competitor content crawling, theme identification, and AI-powered insights, provided by the ALwrity SEO subsystem.

Description

The ContentGapAnalyzer.analyze_comprehensive_gap method is stage 3 of the SEO Analysis Pipeline. It runs a five-phase analysis: (1) SERP analysis using advertools (adv.serp_goog) to map the competitive landscape for target keywords; (2) keyword expansion using adv.kw_generate to discover additional keyword opportunities; (3) deep competitor content analysis using adv.crawl to crawl and analyse up to 5 competitor websites; (4) content theme analysis using adv.word_frequency to identify topic clusters and content gaps; (5) AI-powered insights via AIEngineService to synthesise recommendations. The result is a comprehensive dict with serp_analysis, keyword_expansion, competitor_content, content_themes, gap_analysis, ai_insights, and recommendations.

Usage

Import this service when:

  • The SEO pipeline needs to identify content gaps between a target site and its competitors.
  • Keyword expansion beyond the user's seed list is needed.
  • Competitor content must be crawled and thematically analysed.
  • AI-powered recommendations should synthesise the analysis into actionable steps.

Code Reference

Source Location

  • Repository: ALwrity
  • File: backend/services/content_gap_analyzer/content_gap_analyzer.py (L25-80+)

Signature

class ContentGapAnalyzer:
    """Enhanced content gap analyzer with advertools integration and AI insights."""

    def __init__(self):
        self.ai_engine = AIEngineService()
        self.competitor_analyzer = CompetitorAnalyzer()
        self.keyword_researcher = KeywordResearcher()

    async def analyze_comprehensive_gap(
        self,
        target_url: str,
        competitor_urls: List[str],
        target_keywords: List[str],
        user_id: str,
        industry: str = "general",
    ) -> Dict[str, Any]:
        """
        Perform comprehensive content gap analysis.

        Args:
            target_url: Your website URL.
            competitor_urls: List of competitor URLs (max 5 for performance).
            target_keywords: List of primary keywords to analyze.
            user_id: User ID for subscription checking.
            industry: Industry category for context.

        Returns:
            Comprehensive analysis with serp_analysis, keyword_expansion,
            competitor_content, content_themes, gap_analysis, ai_insights,
            recommendations.
        """

Import

from services.content_gap_analyzer.content_gap_analyzer import ContentGapAnalyzer

I/O Contract

Inputs

Name Type Required Description
target_url str Yes User's website URL
competitor_urls List[str] Yes Competitor URLs (max 5)
target_keywords List[str] Yes Primary keywords to analyse
user_id str Yes Clerk user ID for subscription checks
industry str No Industry category (default 'general')

Outputs

Name Type Description
return Dict[str, Any] serp_analysis, keyword_expansion, competitor_content, content_themes, gap_analysis, ai_insights, recommendations

Usage Examples

Running a full content gap analysis

from services.content_gap_analyzer.content_gap_analyzer import ContentGapAnalyzer

analyzer = ContentGapAnalyzer()
results = await analyzer.analyze_comprehensive_gap(
    target_url="https://acme-coffee.com",
    competitor_urls=["https://competitor1.com", "https://competitor2.com"],
    target_keywords=["specialty coffee", "coffee subscription"],
    user_id="clerk_user_123",
    industry="food_and_beverage",
)

print(f"Expanded keywords: {len(results['keyword_expansion']['expanded_keywords'])}")
print(f"Recommendations: {len(results['recommendations'])}")
for rec in results['recommendations']:
    print(f"  - {rec}")

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment