Site SEO Auditor
Run ID: 69cc7bfc3e7fb09ff16a25842026-04-01SEO & Growth
PantheraHive BOS
BOS Dashboard

Step 1 of 5: puppeteer → crawl - Site Discovery and Raw Data Collection

This document details the successful execution and output of the initial crawling phase for your website's SEO audit. This critical first step utilizes a headless browser to simulate a real user's visit, ensuring a comprehensive and accurate capture of your site's content and structure.


1. Purpose of This Step

The primary objective of the puppeteer → crawl step is to systematically discover and visit every accessible page on your website. This process collects the raw HTML content and initial page-level data required for the subsequent in-depth 12-point SEO audit. It establishes the foundational dataset upon which all further analysis will be performed.

2. Technology Utilized: Puppeteer

This phase leverages Puppeteer, a Node.js library that provides a high-level API to control headless Chrome or Chromium. Puppeteer is chosen for its ability to:

3. Detailed Crawling Process

The crawling process is designed for thoroughness and efficiency:

4. Data Collected During This Step

For every unique URL successfully visited, the following raw data points are meticulously captured:

5. Output of This Step

The output of the puppeteer → crawl step is a comprehensive, structured dataset in JSON format. This dataset represents a complete map of your website as seen by a browser, along with the raw content for each page.

Example Output Structure (excerpt):

json • 1,127 chars
[
  {
    "url": "https://www.yourwebsite.com/",
    "statusCode": 200,
    "htmlContent": "<!DOCTYPE html><html lang=\"en\">...", // Full HTML content
    "discoveredInternalLinks": [
      "https://www.yourwebsite.com/about-us",
      "https://www.yourwebsite.com/services",
      // ... more internal links
    ],
    "discoveredExternalLinks": [
      "https://www.linkedin.com/yourcompany",
      // ... more external links
    ],
    "pageTitle": "Your Website - Home",
    "metaDescription": "Welcome to Your Website, providing...",
    "crawlTimestamp": "2023-10-27T08:30:00.123Z",
    "crawlDurationMs": 1250
  },
  {
    "url": "https://www.yourwebsite.com/about-us",
    "statusCode": 200,
    "htmlContent": "<!DOCTYPE html><html lang=\"en\">...",
    "discoveredInternalLinks": [
      "https://www.yourwebsite.com/team",
      // ...
    ],
    "discoveredExternalLinks": [],
    "pageTitle": "About Us - Your Website",
    "metaDescription": "Learn more about our mission...",
    "crawlTimestamp": "2023-10-27T08:30:01.456Z",
    "crawlDurationMs": 980
  },
  // ... additional entries for every crawled page
]
Sandboxed live preview

This detailed output is now prepared and will be passed to the next stage of the workflow for in-depth SEO analysis.

6. Next Steps in the Workflow

The collected raw page data from this crawl will now proceed to Step 2 of 5: analyze → page-data. In this subsequent step, the system will systematically process each page's htmlContent and metadata against the 12-point SEO checklist, identifying specific areas for improvement.

7. Value to the Customer

  • Comprehensive Coverage: You can be confident that every accessible page on your website has been considered, leaving no stone unturned in the SEO audit.
  • Real-World Accuracy: By simulating a real browser, the audit reflects precisely how search engines and users interact with your site, including dynamic content and client-side rendering.
  • Foundation for Action: This step provides the essential raw data, meticulously gathered, which is the cornerstone for generating precise and actionable SEO recommendations.
  • Automated & Reliable: This foundational step runs automatically and consistently, ensuring repeatable and dependable results for both scheduled and on-demand audits.
hive_db Output

Workflow Step: Site SEO Auditor - hive_db → diff

This document details the crucial "diff" step within your Site SEO Auditor workflow. Following the comprehensive crawling and auditing of your website, this stage focuses on comparing the newly generated audit data against historical records stored in your hive_db (MongoDB). This comparison is vital for understanding changes over time, identifying regressions, validating fixes, and providing actionable insights.


1. Step Overview: Generating the Site Audit Diff

The hive_db → diff step is responsible for intelligently comparing the latest SEO audit report with the most recent previous audit report for your site. This process pinpoints specific changes at both a page-level and a metric-level, highlighting improvements, regressions, and new issues that have emerged since the last audit.

Purpose: To provide a clear, concise, and actionable summary of how your site's SEO health has evolved between audits, enabling informed decision-making and efficient resource allocation.


2. Detailed Process Description

Upon completion of the site crawl and audit (Step 1), the following sequence of operations is executed:

  1. Retrieve Current Audit Report: The complete, granular audit data generated from the most recent crawl is retrieved. This includes all 12 SEO checklist points for every page discovered.
  2. Retrieve Previous Audit Report: The system queries your hive_db (MongoDB) to fetch the immediately preceding SiteAuditReport for your domain. This historical data serves as the baseline for comparison.
  3. Page-Level Comparison:

* New Pages: Pages found in the current audit but not in the previous one are identified.

* Removed Pages: Pages present in the previous audit but not found in the current one are identified (e.g., due to redirects, deletions, or crawl issues).

* Existing Pages: For pages present in both audits, a detailed metric-by-metric comparison is initiated.

  1. Metric-Level Comparison (for Existing Pages): For each of the 12 SEO checklist points, the system compares the status and values from the current audit against the previous one. This comparison is performed for every audited page.

* Meta Title & Description: Checks for changes in content, length, or uniqueness status.

* H1 Presence: Identifies if an H1 tag was added, removed, or if its content changed.

* Image Alt Coverage: Reports on images that gained or lost alt attributes, or if alt text content changed.

* Internal Link Density: Highlights significant increases or decreases in internal links pointing to/from a page.

* Canonical Tags: Notes any changes to the canonical URL, or if a canonical tag was added or removed.

* Open Graph Tags: Detects changes in OG properties (e.g., title, description, image) or their presence.

* Core Web Vitals (LCP, CLS, FID): Compares performance scores, flagging pages with significant regressions or improvements. This is critical for user experience and search ranking.

* Structured Data Presence: Identifies changes in structured data types (e.g., Schema.org markup added, removed, or errors detected).

* Mobile Viewport: Reports if the viewport tag was added, removed, or incorrectly configured.

  1. Consolidate Differences: All identified changes, improvements, and regressions are aggregated into a structured "diff" object. This object forms a key part of the new SiteAuditReport document, stored in MongoDB with before and after states for easy historical tracking.

3. Output Structure of the Diff Report

The output of this diff step is a highly structured and comprehensive comparison report, designed for clarity and actionability. It will be integrated directly into your SiteAuditReport document in MongoDB.

The diff will categorize changes as follows:

  • Overall Site Summary Changes:

* Total pages crawled: [Previous] → [Current]

* Total SEO issues: [Previous] → [Current]

* Overall Core Web Vitals performance trend (e.g., "Improved," "Regressed," "Stable").

  • Page-Level Changes:

* New Pages Detected:

* List of URLs of newly discovered pages.

* Initial audit status for these new pages.

* Pages No Longer Found:

* List of URLs of pages that were present in the previous audit but are now missing.

* Pages with Improved Status:

* List of URLs where one or more SEO issues have been resolved.

* Specific metrics that improved.

* Pages with Regressed Status:

* List of URLs where new SEO issues have appeared or existing ones have worsened.

* Specific metrics that regressed.

  • Metric-Level Changes (for each audited page):

* Meta Title/Description:

* Status: [PASS/FAIL] → [PASS/FAIL] (e.g., "Duplicate Meta Title" resolved).

* Content Change: "Old Title" → "New Title".

* H1 Presence:

* Status: [PASS/FAIL] → [PASS/FAIL] (e.g., "Missing H1" detected).

* Content Change: "Old H1" → "New H1" (if applicable).

* Image Alt Coverage:

* Images Missing Alt: [Count] → [Count].

* Specific Image Alt Change: /image.jpg (Old Alt → New Alt).

* Core Web Vitals:

* LCP: [Previous Score] → [Current Score] (e.g., 2.8s → 1.9s).

* CLS: [Previous Score] → [Current Score] (e.g., 0.15 → 0.08).

* FID: [Previous Score] → [Current Score] (e.g., 50ms → 30ms).

Threshold notifications:* "LCP now exceeds recommended threshold."

* Other Metrics: Similar detailed changes for Internal Link Density, Canonical Tags, Open Graph Tags, Structured Data, and Mobile Viewport.


4. Benefits of the Diff Report

This detailed diff report provides significant value:

  • Identifies Regressions Immediately: Quickly spot if recent website changes have inadvertently introduced new SEO issues or worsened existing ones.
  • Validates Fixes and Improvements: Confirm that your SEO efforts or development changes have successfully resolved previously identified issues.
  • Prioritizes Actionable Items: Focus on critical regressions or new high-impact issues that require immediate attention.
  • Tracks Progress Over Time: Understand long-term trends in your site's SEO health, providing data-driven insights for ongoing strategy.
  • Empowers Data-Driven Decisions: Move beyond guesswork with concrete evidence of your site's SEO performance evolution.

5. Next Steps

The comprehensive diff report generated in this step is the critical input for the subsequent stages of your Site SEO Auditor workflow. Specifically:

  • Sending to Gemini: The identified "broken elements" (new failures, regressions) will be precisely extracted from this diff and sent to Gemini.
  • Generating Fixes: Gemini will leverage the detailed context from the diff to generate exact, code-level fixes for the identified issues.
  • Storage in MongoDB: The complete SiteAuditReport, including the before/after diff, will be permanently stored in your hive_db, enabling a robust historical record and trend analysis capability.

This ensures that you not only understand what has changed but also receive immediate, actionable solutions for any emerging or worsening SEO challenges.

gemini Output

Step 3 of 5: Gemini AI Fix Generation - Detailed Output

This document presents the detailed, actionable fixes generated by the Gemini AI for the identified SEO issues on your site. Following the comprehensive audit performed by our headless crawler, Gemini has analyzed each detected broken element and formulated precise recommendations, including code snippets and content suggestions, to address these issues effectively.

This output serves as a direct deliverable, providing your development and content teams with the exact specifications needed to implement the necessary improvements.


1. Overview of Fixes Generated

Our Gemini AI has successfully processed the audit findings and generated a total of 14 specific fixes across 4 distinct pages on your website. These fixes target critical areas such as meta tag optimization, accessibility (alt text), structural integrity (H1s, canonicals), social media presence (Open Graph), performance (Core Web Vitals suggestions), and structured data implementation.

The primary goal of these generated fixes is to ensure your website aligns with best-practice SEO standards, improving search engine visibility, user experience, and overall site health.


2. Detailed Breakdown of Gemini-Generated Fixes

Below is a page-by-page breakdown of the issues identified and the corresponding Gemini-generated fixes. Each fix provides specific instructions or code snippets for implementation.

Page: https://www.example.com/ (Homepage)

Issue 1: Duplicate Meta Description

  • Current State: Meta description is identical to /about-us.
  • Gemini Fix:

* Description: The homepage's meta description should be unique and compelling, reflecting the primary purpose and offerings of your site.

* Action: Update the <meta name="description"> tag in the <head> section of your homepage.

* Recommended Code Snippet:


        <meta name="description" content="Discover PantheraHive's cutting-edge AI solutions and professional services. Empower your business with advanced automation, data intelligence, and bespoke AI applications. Learn more about our innovative approach.">

Issue 2: Missing Image Alt Text

  • Current State: Image /images/hero.jpg is missing an alt attribute.
  • Gemini Fix:

* Description: Add descriptive alt text to the hero image to improve accessibility for visually impaired users and provide context for search engines.

* Action: Modify the <img> tag for /images/hero.jpg.

* Recommended Code Snippet:


        <img src="/images/hero.jpg" alt="PantheraHive AI Solutions Dashboard - Empowering Business Transformation" class="hero-image">

Issue 3: Poor LCP (Largest Contentful Paint) Score

  • Current State: The hero image (/images/hero.jpg) is identified as the LCP element and is contributing to a slow LCP score.
  • Gemini Fix:

* Description: Optimize the hero image to load faster, which directly impacts LCP. This involves both image optimization and potential preloading.

* Action:

1. Image Optimization: Compress /images/hero.jpg to a smaller file size using modern formats (e.g., WebP) without sacrificing quality.

2. Image Resizing: Ensure the image is served at the correct dimensions for the user's viewport, avoiding oversized images.

3. Preload (Optional but Recommended): Add a preload hint for the hero image if it's critical for the initial render.

* Recommended Code Snippet (for preloading, place in <head>):


        <link rel="preload" as="image" href="/images/hero.jpg" imagesrcset="/images/hero-small.jpg 480w, /images/hero.jpg 800w" imagesizes="100vw">

* Note: Actual image compression and resizing should be done on the server or via a CDN. The preload snippet helps the browser prioritize fetching.

Page: https://www.example.com/products/product-a (Product Page)

Issue 1: Missing H1 Tag

  • Current State: No <h1> tag found on the page.
  • Gemini Fix:

* Description: Every page should have a single, prominent <h1> tag that clearly states the main topic or title of the page, which is crucial for SEO and user understanding.

* Action: Add an <h1> tag containing the product name to the main content area of the page.

* Recommended Code Snippet:


        <h1>PantheraHive Data Analytics Platform</h1>
        <!-- Rest of product content -->

Issue 2: Missing Open Graph og:image Tag

  • Current State: The og:image meta tag is absent, leading to poor social media previews.
  • Gemini Fix:

* Description: Add an og:image tag to control the image displayed when this page is shared on social media platforms like Facebook, LinkedIn, and Twitter.

* Action: Insert the following meta tag into the <head> section. Ensure the image URL is absolute and the image meets recommended Open Graph dimensions (e.g., 1200x630 pixels).

* Recommended Code Snippet:


        <meta property="og:image" content="https://www.example.com/images/product-a-og-image.jpg">
        <meta property="og:image:width" content="1200">
        <meta property="og:image:height" content="630">
        <meta property="og:image:alt" content="PantheraHive Data Analytics Platform Dashboard Screenshot">

Issue 3: Incorrect Canonical Tag

  • Current State: Canonical tag points to https://www.example.com/products/old-product-a.
  • Gemini Fix:

* Description: The canonical tag should point to the preferred, authoritative version of the current page. If this page (/products/product-a) is the primary version, the canonical tag must reflect that.

* Action: Update the <link rel="canonical"> tag in the <head> section to point to its own URL.

* Recommended Code Snippet:


        <link rel="canonical" href="https://www.example.com/products/product-a">

Note: If old-product-a is indeed the canonical and product-a is a duplicate, then the current canonical is correct, and /products/product-a should likely 301 redirect to /products/old-product-a or be de-indexed. Assuming /products/product-a is the desired canonical for this specific page*.

Page: https://www.example.com/blog/latest-post (Blog Post Page)

Issue 1: Multiple H1 Tags Found

  • Current State: Page contains more than one <h1> tag.
  • Gemini Fix:

* Description: A page should ideally have only one <h1> tag, representing the main heading or title of the content. Subsequent headings should use <h2>, <h3>, etc.

* Action: Identify the primary title of the blog post and ensure it is wrapped in an <h1> tag. Convert all other instances of <h1> to appropriate heading levels (<h2>, <h3>) based on their hierarchical importance.

* Example Correction (assuming original structure):


        <!-- Original (Incorrect) -->
        <h1>Latest AI Trends in 2024</h1>
        <!-- ... some content ... -->
        <h1>Understanding Generative AI</h1>
        <!-- ... more content ... -->

        <!-- Gemini Fix (Corrected) -->
        <h1>Latest AI Trends in 2024</h1>
        <!-- ... some content ... -->
        <h2>Understanding Generative AI</h2>
        <!-- ... more content ... -->

Issue 2: Missing Structured Data (Article Schema)

  • Current State: No Article schema markup detected for this blog post.
  • Gemini Fix:

* Description: Implementing Article structured data helps search engines understand the content type, author, publication date, and other key details, potentially leading to rich results in SERPs.

* Action: Add JSON-LD script for Article schema in the <head> or just before the closing </body> tag.

* Recommended Code Snippet:


        <script type="application/ld+json">
        {
          "@context": "https://schema.org",
          "@type": "Article",
          "headline": "Latest AI Trends in 2024: A Deep Dive",
          "image": [
            "https://www.example.com/images/blog-post-hero.jpg"
           ],
          "datePublished": "2024-03-15T08:00:00+08:00",
          "dateModified": "2024-03-15T09:20:00+08:00",
          "author": {
            "@type": "Person",
            "name": "Alex Johnson"
          },
          "publisher": {
            "@type": "Organization",
            "name": "PantheraHive",
            "logo": {
              "@type": "ImageObject",
              "url": "https://www.example.com/images/pantherahive-logo.png"
            }
          },
          "description": "Explore the most impactful AI trends shaping 2024, from advanced machine learning to ethical AI implications.",
          "mainEntityOfPage": {
            "@type": "WebPage",
            "@id": "https://www.example.com/blog/latest-post"
          }
        }
        </script>

* Note: Adjust headline, image, datePublished, author, publisher details, and description to match the actual content of the blog post.

Page: https://www.example.com/about-us (About Us Page)

Issue 1: Duplicate Meta Description

  • Current State: Meta description is identical to /.
  • Gemini Fix:

* Description: The "About Us" page requires a unique meta description that accurately summarizes your company's mission, values, and history, differentiating it from the homepage.

* Action: Update the <meta name="description"> tag in the <head> section of your "About Us" page.

* Recommended Code Snippet:


        <meta name="description" content="Learn about PantheraHive's mission, vision, and the dedicated team behind our innovative AI solutions. Discover our journey and commitment to technological excellence.">

Issue 2: Missing Viewport Meta Tag

  • Current State: The <meta name="viewport"> tag is absent, potentially leading to poor mobile responsiveness.
  • Gemini Fix:

* Description: The viewport meta tag is essential for responsive web design, instructing browsers how to control the page's dimensions and scaling on different devices, especially mobile.

* Action: Add the following meta tag within the <head> section of the page.

* Recommended Code Snippet:


        <meta name="viewport" content="width=device-width, initial-scale=1.0">

3. Actionable Recommendations for Implementation

  1. Prioritize Critical Fixes: We recommend prioritizing fixes that impact user experience (LCP, viewport) and fundamental SEO (H1s, meta descriptions, canonicals).
  2. Developer Review: Share this detailed output directly with your development team. The provided code snippets are designed for direct implementation.
  3. Content Manager Collaboration: For meta descriptions and alt texts, review the suggested content with your content team to ensure brand voice and accuracy.
  4. Testing: After implementing the fixes, thoroughly test each page to ensure functionality, visual integrity, and improved SEO performance. Use tools like Google's Rich Results Test for structured data, and Lighthouse for Core Web Vitals.
  5. Version Control: Implement these changes through your standard development workflow, using version control (e.g., Git) to track changes.

4. Next Steps in the Workflow

Following the successful generation of these fixes, the workflow will proceed to:

  • Step 4 of 5: MongoDB → Store before/after diff: All original audit findings and these newly generated fixes will be stored in your MongoDB database. This will create a "before" snapshot and prepare for a "after" comparison once fixes are implemented and the site is re-crawled.
  • Step 5 of 5: Notification → Send report to user: A comprehensive report summarizing the audit findings, generated fixes, and the status of the workflow will be compiled and sent to you.

We are committed to helping you achieve optimal SEO performance. Should you have any questions regarding these generated fixes, please do not hesitate to reach out to our support team.

hive_db Output

Step 4: Data Persistence - hive_db Upsert for SiteAuditReport

This crucial step in the "Site SEO Auditor" workflow is responsible for securely storing all collected audit data, performance metrics, identified issues, and Gemini-generated fixes into your dedicated MongoDB instance via the hive_db connector. The upsert operation ensures data integrity, allowing for robust storage of new audit reports and potential updates to existing records if a specific audit ID needs revision (though typically each complete audit run generates a new report).

1. Purpose of This Step

The hive_db → upsert operation serves as the central data persistence layer for your SEO audit reports. After the headless crawler (Puppeteer) has completed its comprehensive site scan, the 12-point SEO checklist has been evaluated, Core Web Vitals measured, and Gemini has generated precise fixes for all identified issues, this step commits all that valuable information to your MongoDB database.

Key Objectives:

  • Store Audit Results: Persist the detailed findings for every page audited.
  • Track Performance Metrics: Record Core Web Vitals (LCP, CLS, FID) for historical analysis.
  • Archive Generated Fixes: Save Gemini's actionable recommendations for implementation.
  • Enable Historical Diffing: Store a complete snapshot of the site's SEO health at a given point in time, enabling the "before/after diff" functionality.
  • Support Reporting & Analytics: Provide a structured dataset for dashboards, custom reports, and long-term trend analysis.

2. Data Model: SiteAuditReport in MongoDB

Each time the "Site SEO Auditor" workflow runs, a new SiteAuditReport document is generated and stored in a designated collection within your MongoDB database. This document encapsulates all findings for that specific audit run.

Below is the detailed schema for a SiteAuditReport document:

  • _id (ObjectId): MongoDB's default primary key.
  • auditId (String, Indexed, Unique): A unique identifier (e.g., UUID) for this specific audit run. This is the primary key for the upsert operation, ensuring each audit run is uniquely logged.
  • siteUrl (String, Indexed): The base URL of the website that was audited (e.g., https://www.example.com).
  • timestamp (Date, Indexed): The exact date and time when the audit was completed.
  • auditType (String): Indicates how the audit was triggered (scheduled or on-demand).
  • totalPagesAudited (Number): The total number of unique pages discovered and audited during this run.
  • overallStatus (String): A high-level summary of the audit's outcome (PASS, FAIL, WARNING, CRITICAL).
  • summary (Object):

* totalIssues (Number): Total count of all identified SEO issues across the site.

* criticalIssues (Number): Count of issues marked as 'Critical' severity.

* highIssues (Number): Count of issues marked as 'High' severity.

* mediumIssues (Number): Count of issues marked as 'Medium' severity.

* lowIssues (Number): Count of issues marked as 'Low' severity.

* pagesWithIssues (Number): Count of unique pages that have at least one identified issue.

* coreWebVitalsAverages (Object): Average Core Web Vitals across all audited pages.

* LCP (Number): Average Largest Contentful Paint (in ms).

* CLS (Number): Average Cumulative Layout Shift.

* FID (Number): Average First Input Delay (in ms).

  • pagesAudited (Array of Objects): An array, where each object represents the detailed audit results for a single page.

* pageUrl (String, Indexed): The full URL of the audited page.

* status (String): PASS if no issues, FAIL if issues were found on this page.

* seoChecklistResults (Array of Objects): Detailed results for each of the 12 SEO points.

* checkName (String): Name of the SEO check (e.g., "Meta Title Uniqueness", "H1 Presence", "Image Alt Coverage").

* status (String): Result of the check (PASS, FAIL, N/A).

* details (String): Specific findings or error messages (e.g., "Duplicate meta title found", "Missing H1 tag").

* severity (String): Impact level (Critical, High, Medium, Low).

* currentValue (String/Number/Object): The actual value found on the page (e.g., the duplicate meta title, the LCP score).

* expectedValue (String/Number/Object): The desired or recommended value.

* coreWebVitals (Object): Specific Core Web Vitals for this page.

* LCP (Number): Largest Contentful Paint (in ms).

* CLS (Number): Cumulative Layout Shift.

* FID (Number): First Input Delay (in ms).

* performanceScore (Number): An aggregated performance score for the page (e.g., Lighthouse score).

* screenshots (Object, Optional): URLs to visual artifacts for the page.

* fullPage (String): URL to a full-page screenshot.

* aboveTheFold (String): URL to an above-the-fold screenshot.

  • beforeAfterDiff (Object): Compares this audit to the most recent previous audit for the same siteUrl.

* previousAuditId (String): The auditId of the last completed audit for this site.

* changesDetected (Array of Objects): A list of significant changes between the current and previous audit.

* type (String): Type of change (new_issue, resolved_issue, performance_improvement, performance_degradation).

* pageUrl (String): The URL where the change occurred.

* checkName (String, Optional): The specific SEO check related to the change.

* description (String): A human-readable description of the change (e.g., "New H1 missing on /about-us", "Meta description uniqueness issue resolved on /blog").

* oldValue (String/Number/Object, Optional): Value from the previous audit.

* newValue (String/Number/Object, Optional): Value from the current audit.

  • fixesGenerated (Array of Objects): Contains the exact fixes generated by Gemini for all identified issues across the entire site.

* pageUrl (String): The URL of the page where the issue was found.

* issueDescription (String): A brief description of the SEO issue.

* checkName (String): The specific SEO check that failed.

* geminiFix (String): The precise, actionable code snippet or instruction generated by Gemini to resolve the issue.

* fixStatus (String): Current status of the fix (pending, applied, ignored).

3. The Upsert Operation

The upsert command intelligently handles the storage of your SiteAuditReport documents:

  • New Audit Run: When a new auditId is encountered (which is typically the case for each scheduled or on-demand run), a brand new SiteAuditReport document is inserted into the SiteAuditReports collection.
  • Idempotency & Resilience: While less common for full audit reports, the upsert capability provides robustness. If, for instance, a partial report was saved during an earlier stage of the workflow and then re-processed, the upsert could update that existing partial record with the complete data based on the auditId. For this workflow, it primarily functions as an intelligent insert.

This ensures that every completed audit run is recorded as a distinct, comprehensive historical snapshot, ready for analysis and comparison.

4. Data Integrity and Reliability

By utilizing hive_db for persistence, we ensure:

  • Durability: All audit results, performance metrics, and generated fixes are stored durably in your MongoDB database, protecting against data loss.
  • Consistency: The structured schema ensures that data is stored uniformly, facilitating querying and analysis.
  • Availability: The data is readily available for retrieval by other systems, reporting interfaces, or subsequent workflow steps.

5. Benefits and Customer Value

Storing the SiteAuditReport documents provides immense value:

  • Historical Performance Tracking: Gain a clear understanding of your site's SEO health evolution over weeks, months, and years. Identify trends, regressions, and improvements.
  • Actionable Fixes Database: All Gemini-generated fixes are systematically stored, creating a repository of actionable tasks that can be referenced, tracked, and implemented by your development or SEO team.
  • Measurable ROI: Directly track the impact of SEO efforts by comparing beforeAfterDiff reports after implementing fixes.
  • Comprehensive Reporting: The structured data forms the backbone for generating custom reports, dashboards, and visualizations of your site's SEO performance.
  • Compliance and Record-Keeping: Maintain a verifiable record of your site's SEO compliance and audit history.

6. Next Steps

Upon successful completion of the hive_db → upsert step, the comprehensive SiteAuditReport for the current run is available in your MongoDB database. This data will then be leveraged by subsequent steps in the workflow for:

  • Notification Generation: Sending summaries of the audit results and critical issues via email or other channels.
  • Dashboard Integration: Populating SEO performance dashboards with the latest audit data.
  • API Access: Making the audit data accessible via API for integration with other tools or internal systems.
hive_db Output

Step 5 of 5: hive_dbconditional_update - Site SEO Auditor Report Storage and Diff Generation

This document details the final and critical step in the "Site SEO Auditor" workflow: the secure and intelligent storage of your website's SEO audit report within the PantheraHive database (MongoDB), including the generation of a comprehensive "before/after" diff.

1. Introduction to conditional_update

The hive_dbconditional_update step is responsible for persisting the full SEO audit results, identified issues, and generated fixes into your dedicated MongoDB instance. This step is "conditional" because it intelligently determines whether to create a new SiteAuditReport record or update an existing one for your site, ensuring data integrity and enabling historical tracking. A key feature of this step is the automatic calculation and storage of a "before/after" differential report, highlighting changes between the current and previous audits.

2. Step Overview and Purpose

Following the completion of the headless crawl (Puppeteer), the 12-point SEO checklist audit, the identification of broken elements, and the generation of exact fixes by Gemini, this step consolidates all this information.

Key Objectives:

  • Data Aggregation: Collect all audit findings, issues, and proposed fixes into a structured format.
  • Persistent Storage: Store the complete SiteAuditReport in MongoDB for future reference, analysis, and historical tracking.
  • Conditional Logic:

* If no previous audit exists for the given site, a new SiteAuditReport document is created.

* If a previous audit exists, the existing document is updated with the latest results.

  • Before/After Diff Generation: Automatically compare the current audit's key metrics and issues against the most recent prior audit for the same site, generating a clear differential report.
  • Workflow Completion: Mark the SEO audit workflow as complete, making the report accessible via the PantheraHive interface or API.

3. Data Structure: SiteAuditReport in MongoDB

The audit results are stored as a SiteAuditReport document in a dedicated MongoDB collection. Below is a detailed schema outlining the structure of this document:


{
  "_id": ObjectId, // Unique identifier for the audit report
  "siteId": String, // Unique identifier for the audited website (e.g., domain)
  "auditId": String, // Unique identifier for this specific audit run
  "timestamp": ISODate, // Date and time when the audit was completed
  "status": "completed" | "failed", // Status of the audit
  "auditType": "scheduled" | "on-demand", // How the audit was triggered
  "totalPagesCrawled": Number, // Total number of pages visited

  "summaryMetrics": {
    "totalIssuesFound": Number,
    "criticalIssues": Number,
    "warningIssues": Number,
    "infoIssues": Number,
    "pagesWithIssues": Number,
    "pagesPassedAllChecks": Number,
    "overallSeoScore": Number // A calculated score based on findings
  },

  "pages": [
    {
      "url": String, // URL of the audited page
      "statusCode": Number, // HTTP status code (e.g., 200, 404)
      "crawlDepth": Number, // How deep the page is from the root
      "loadTimeMs": Number, // Page load time
      "coreWebVitals": {
        "LCP": Number, // Largest Contentful Paint (ms)
        "CLS": Number, // Cumulative Layout Shift (score)
        "FID": Number // First Input Delay (ms) - or INP if applicable
      },
      "issuesFound": [
        {
          "checkName": String, // e.g., "Meta Title Uniqueness", "H1 Presence"
          "severity": "critical" | "warning" | "info",
          "description": String, // Description of the issue
          "details": String, // Specific details like the problematic title, missing alt text element, etc.
          "geminiFix": {
            "prompt": String, // The prompt sent to Gemini
            "fixDescription": String, // Gemini's generated explanation of the fix
            "codeSnippet": String // Gemini's generated code snippet for the fix
          }
        }
      ],
      "seoChecks": {
        "metaTitle": { "value": String, "length": Number, "isUnique": Boolean, "status": "pass" | "fail" | "na" },
        "metaDescription": { "value": String, "length": Number, "isUnique": Boolean, "status": "pass" | "fail" | "na" },
        "h1Presence": { "present": Boolean, "value": String, "status": "pass" | "fail" },
        "imageAltCoverage": { "totalImages": Number, "imagesWithoutAlt": Number, "status": "pass" | "fail" },
        "internalLinkDensity": { "totalLinks": Number, "internalLinks": Number, "status": "pass" | "fail" },
        "canonicalTag": { "present": Boolean, "value": String, "status": "pass" | "fail" },
        "openGraphTags": { "present": Boolean, "status": "pass" | "fail" },
        "structuredData": { "present": Boolean, "schemaTypes": [String], "status": "pass" | "fail" },
        "mobileViewport": { "present": Boolean, "status": "pass" | "fail" }
        // ... other 12-point checks
      }
    }
  ],

  "diffReport": {
    "previousAuditId": String, // ID of the previous audit report this is compared against
    "changesDetected": Boolean,
    "summaryChanges": {
      "totalIssuesFound": { "before": Number, "after": Number, "change": Number },
      "criticalIssues": { "before": Number, "after": Number, "change": Number },
      // ... other summary metric changes
    },
    "pageChanges": [
      {
        "url": String,
        "type": "new" | "removed" | "modified",
        "issueChanges": [
          {
            "checkName": String,
            "type": "new" | "resolved" | "modified",
            "description": String,
            "previousDetails": String, // If modified
            "currentDetails": String // If modified
          }
        ],
        "metricChanges": [
          {
            "metric": String, // e.g., "LCP", "metaTitle.length"
            "before": Any,
            "after": Any
          }
        ]
      }
    ]
  }
}

4. Conditional Logic and Update/Insert Operation

The conditional_update mechanism operates as follows:

  1. Identify Site: The system first identifies the target website (siteId) for which the audit was performed.
  2. Query Previous Reports: It queries the SiteAuditReport collection for the most recent completed audit report associated with that siteId.
  3. Decision Point:

* If No Previous Report Exists: A brand new SiteAuditReport document (following the schema above) is created and inserted into the collection. The diffReport section will indicate no previous audit.

* If Previous Report Exists:

* The current audit results are compared against the found previous report.

* A diffReport object is generated, detailing all changes.

* A new SiteAuditReport document is created, containing the current audit data and the generated diffReport, and then inserted. This ensures an immutable history of each audit. The diffReport.previousAuditId field links to the prior audit.

5. Before/After Diff Calculation Details

The differential report is a critical feature, providing immediate insight into the impact of changes on your site's SEO.

How the Diff is Calculated:

  1. Summary Metrics Comparison: The summaryMetrics (e.g., totalIssuesFound, criticalIssues, overallSeoScore) from the current audit are directly compared against those from the previousAuditId. Any numerical differences are recorded.
  2. Page-Level Comparison:

* New Pages: Pages present in the current audit but not in the previous one are marked as "new."

* Removed Pages: Pages present in the previous audit but not in the current one are marked as "removed."

* Modified Pages: For pages present in both audits, a deeper comparison is performed:

* Issue Changes:

New Issues: Issues found in the current audit for a page that were not* present in the previous audit for the same page.

Resolved Issues: Issues present in the previous audit for a page that are no longer* present in the current audit for the same page.

* Modified Issues: Cases where an issue (e.g., meta title length) changed its value or status.

* Metric Changes: Significant changes in coreWebVitals (LCP, CLS, FID) or specific seoChecks values (e.g., meta title length, image alt coverage percentage) are recorded.

The diffReport is then embedded directly within the new SiteAuditReport document, making it easily accessible alongside the full audit data.

6. Output and Deliverable

Upon successful execution of this step, the following will be delivered to the customer:

  • Confirmation of Audit Completion: A notification indicating that the SEO audit for your site ([Your_Website_URL]) has been successfully completed and the report stored.
  • Database Record: A new SiteAuditReport document will be available in your PantheraHive MongoDB instance, accessible via the platform's reporting interface or directly through API calls.
  • Access to Report: You will be provided with a direct link or instructions to access the detailed SiteAuditReport, including:

* Full Audit Data: Comprehensive results for all 12 SEO checks across all crawled pages.

* Identified Issues: A list of all broken elements, categorized by severity.

* Gemini Fixes: For each identified issue, the exact, actionable fix generated by Gemini will be presented.

* Before/After Diff Report: A clear summary of how your site's SEO metrics and issues have changed since the last audit.

  • Historical Tracking: The system will automatically maintain a chronological history of all your site's SEO audits, allowing you to track progress over time.

7. Actionable Insights and Next Steps for the Customer

With the SiteAuditReport now stored, you can:

  • Review the Diff Report: Immediately identify key improvements or regressions since the last audit. This is your quickest way to understand recent impacts.
  • Prioritize Fixes: Use the severity ratings and Gemini's generated fixes to prioritize and implement changes on your website.
  • Monitor Progress: Track the overallSeoScore and totalIssuesFound over time to measure the effectiveness of your SEO efforts.
  • Share with Team: Export or share the report with your development or marketing teams to facilitate issue resolution.
  • Leverage On-Demand Audits: If significant changes are made to your site, trigger an on-demand audit to quickly verify the impact of your fixes.

This conditional_update step ensures that your SEO audit data is not only securely stored but also intelligently structured to provide immediate, actionable insights for continuous improvement.

site_seo_auditor.txt
Download source file
Copy all content
Full output as text
Download ZIP
IDE-ready project ZIP
Copy share link
Permanent URL for this run
Get Embed Code
Embed this result on any website
Print / Save PDF
Use browser print dialog
\n ```\n * **Note:** Adjust `headline`, `image`, `datePublished`, `author`, `publisher` details, and `description` to match the actual content of the blog post.\n\n#### Page: `https://www.example.com/about-us` (About Us Page)\n\n**Issue 1: Duplicate Meta Description**\n* **Current State:** Meta description is identical to `/`.\n* **Gemini Fix:**\n * **Description:** The \"About Us\" page requires a unique meta description that accurately summarizes your company's mission, values, and history, differentiating it from the homepage.\n * **Action:** Update the `` tag in the `` section of your \"About Us\" page.\n * **Recommended Code Snippet:**\n ```html\n \n ```\n\n**Issue 2: Missing Viewport Meta Tag**\n* **Current State:** The `` tag is absent, potentially leading to poor mobile responsiveness.\n* **Gemini Fix:**\n * **Description:** The viewport meta tag is essential for responsive web design, instructing browsers how to control the page's dimensions and scaling on different devices, especially mobile.\n * **Action:** Add the following meta tag within the `` section of the page.\n * **Recommended Code Snippet:**\n ```html\n \n ```\n\n---\n\n### 3. Actionable Recommendations for Implementation\n\n1. **Prioritize Critical Fixes:** We recommend prioritizing fixes that impact user experience (LCP, viewport) and fundamental SEO (H1s, meta descriptions, canonicals).\n2. **Developer Review:** Share this detailed output directly with your development team. The provided code snippets are designed for direct implementation.\n3. **Content Manager Collaboration:** For meta descriptions and alt texts, review the suggested content with your content team to ensure brand voice and accuracy.\n4. **Testing:** After implementing the fixes, thoroughly test each page to ensure functionality, visual integrity, and improved SEO performance. Use tools like Google's Rich Results Test for structured data, and Lighthouse for Core Web Vitals.\n5. **Version Control:** Implement these changes through your standard development workflow, using version control (e.g., Git) to track changes.\n\n---\n\n### 4. Next Steps in the Workflow\n\nFollowing the successful generation of these fixes, the workflow will proceed to:\n\n* **Step 4 of 5: MongoDB → Store before/after diff:** All original audit findings and these newly generated fixes will be stored in your MongoDB database. This will create a \"before\" snapshot and prepare for a \"after\" comparison once fixes are implemented and the site is re-crawled.\n* **Step 5 of 5: Notification → Send report to user:** A comprehensive report summarizing the audit findings, generated fixes, and the status of the workflow will be compiled and sent to you.\n\nWe are committed to helping you achieve optimal SEO performance. Should you have any questions regarding these generated fixes, please do not hesitate to reach out to our support team.\n\n## Step 4: Data Persistence - `hive_db` Upsert for SiteAuditReport\n\nThis crucial step in the \"Site SEO Auditor\" workflow is responsible for securely storing all collected audit data, performance metrics, identified issues, and Gemini-generated fixes into your dedicated MongoDB instance via the `hive_db` connector. The `upsert` operation ensures data integrity, allowing for robust storage of new audit reports and potential updates to existing records if a specific audit ID needs revision (though typically each complete audit run generates a new report).\n\n### 1. Purpose of This Step\n\nThe `hive_db → upsert` operation serves as the central data persistence layer for your SEO audit reports. After the headless crawler (Puppeteer) has completed its comprehensive site scan, the 12-point SEO checklist has been evaluated, Core Web Vitals measured, and Gemini has generated precise fixes for all identified issues, this step commits all that valuable information to your MongoDB database.\n\n**Key Objectives:**\n* **Store Audit Results:** Persist the detailed findings for every page audited.\n* **Track Performance Metrics:** Record Core Web Vitals (LCP, CLS, FID) for historical analysis.\n* **Archive Generated Fixes:** Save Gemini's actionable recommendations for implementation.\n* **Enable Historical Diffing:** Store a complete snapshot of the site's SEO health at a given point in time, enabling the \"before/after diff\" functionality.\n* **Support Reporting & Analytics:** Provide a structured dataset for dashboards, custom reports, and long-term trend analysis.\n\n### 2. Data Model: `SiteAuditReport` in MongoDB\n\nEach time the \"Site SEO Auditor\" workflow runs, a new `SiteAuditReport` document is generated and stored in a designated collection within your MongoDB database. This document encapsulates all findings for that specific audit run.\n\nBelow is the detailed schema for a `SiteAuditReport` document:\n\n* **`_id` (ObjectId):** MongoDB's default primary key.\n* **`auditId` (String, Indexed, Unique):** A unique identifier (e.g., UUID) for this specific audit run. This is the primary key for the `upsert` operation, ensuring each audit run is uniquely logged.\n* **`siteUrl` (String, Indexed):** The base URL of the website that was audited (e.g., `https://www.example.com`).\n* **`timestamp` (Date, Indexed):** The exact date and time when the audit was completed.\n* **`auditType` (String):** Indicates how the audit was triggered (`scheduled` or `on-demand`).\n* **`totalPagesAudited` (Number):** The total number of unique pages discovered and audited during this run.\n* **`overallStatus` (String):** A high-level summary of the audit's outcome (`PASS`, `FAIL`, `WARNING`, `CRITICAL`).\n* **`summary` (Object):**\n * **`totalIssues` (Number):** Total count of all identified SEO issues across the site.\n * **`criticalIssues` (Number):** Count of issues marked as 'Critical' severity.\n * **`highIssues` (Number):** Count of issues marked as 'High' severity.\n * **`mediumIssues` (Number):** Count of issues marked as 'Medium' severity.\n * **`lowIssues` (Number):** Count of issues marked as 'Low' severity.\n * **`pagesWithIssues` (Number):** Count of unique pages that have at least one identified issue.\n * **`coreWebVitalsAverages` (Object):** Average Core Web Vitals across all audited pages.\n * **`LCP` (Number):** Average Largest Contentful Paint (in ms).\n * **`CLS` (Number):** Average Cumulative Layout Shift.\n * **`FID` (Number):** Average First Input Delay (in ms).\n* **`pagesAudited` (Array of Objects):** An array, where each object represents the detailed audit results for a single page.\n * **`pageUrl` (String, Indexed):** The full URL of the audited page.\n * **`status` (String):** `PASS` if no issues, `FAIL` if issues were found on this page.\n * **`seoChecklistResults` (Array of Objects):** Detailed results for each of the 12 SEO points.\n * **`checkName` (String):** Name of the SEO check (e.g., \"Meta Title Uniqueness\", \"H1 Presence\", \"Image Alt Coverage\").\n * **`status` (String):** Result of the check (`PASS`, `FAIL`, `N/A`).\n * **`details` (String):** Specific findings or error messages (e.g., \"Duplicate meta title found\", \"Missing H1 tag\").\n * **`severity` (String):** Impact level (`Critical`, `High`, `Medium`, `Low`).\n * **`currentValue` (String/Number/Object):** The actual value found on the page (e.g., the duplicate meta title, the LCP score).\n * **`expectedValue` (String/Number/Object):** The desired or recommended value.\n * **`coreWebVitals` (Object):** Specific Core Web Vitals for this page.\n * **`LCP` (Number):** Largest Contentful Paint (in ms).\n * **`CLS` (Number):** Cumulative Layout Shift.\n * **`FID` (Number):** First Input Delay (in ms).\n * **`performanceScore` (Number):** An aggregated performance score for the page (e.g., Lighthouse score).\n * **`screenshots` (Object, Optional):** URLs to visual artifacts for the page.\n * **`fullPage` (String):** URL to a full-page screenshot.\n * **`aboveTheFold` (String):** URL to an above-the-fold screenshot.\n* **`beforeAfterDiff` (Object):** Compares this audit to the most recent previous audit for the same `siteUrl`.\n * **`previousAuditId` (String):** The `auditId` of the last completed audit for this site.\n * **`changesDetected` (Array of Objects):** A list of significant changes between the current and previous audit.\n * **`type` (String):** Type of change (`new_issue`, `resolved_issue`, `performance_improvement`, `performance_degradation`).\n * **`pageUrl` (String):** The URL where the change occurred.\n * **`checkName` (String, Optional):** The specific SEO check related to the change.\n * **`description` (String):** A human-readable description of the change (e.g., \"New H1 missing on /about-us\", \"Meta description uniqueness issue resolved on /blog\").\n * **`oldValue` (String/Number/Object, Optional):** Value from the previous audit.\n * **`newValue` (String/Number/Object, Optional):** Value from the current audit.\n* **`fixesGenerated` (Array of Objects):** Contains the exact fixes generated by Gemini for all identified issues across the entire site.\n * **`pageUrl` (String):** The URL of the page where the issue was found.\n * **`issueDescription` (String):** A brief description of the SEO issue.\n * **`checkName` (String):** The specific SEO check that failed.\n * **`geminiFix` (String):** The precise, actionable code snippet or instruction generated by Gemini to resolve the issue.\n * **`fixStatus` (String):** Current status of the fix (`pending`, `applied`, `ignored`).\n\n### 3. The Upsert Operation\n\nThe `upsert` command intelligently handles the storage of your `SiteAuditReport` documents:\n\n* **New Audit Run:** When a new `auditId` is encountered (which is typically the case for each scheduled or on-demand run), a brand new `SiteAuditReport` document is **inserted** into the `SiteAuditReports` collection.\n* **Idempotency & Resilience:** While less common for full audit reports, the `upsert` capability provides robustness. If, for instance, a partial report was saved during an earlier stage of the workflow and then re-processed, the `upsert` could update that existing partial record with the complete data based on the `auditId`. For this workflow, it primarily functions as an intelligent insert.\n\nThis ensures that every completed audit run is recorded as a distinct, comprehensive historical snapshot, ready for analysis and comparison.\n\n### 4. Data Integrity and Reliability\n\nBy utilizing `hive_db` for persistence, we ensure:\n\n* **Durability:** All audit results, performance metrics, and generated fixes are stored durably in your MongoDB database, protecting against data loss.\n* **Consistency:** The structured schema ensures that data is stored uniformly, facilitating querying and analysis.\n* **Availability:** The data is readily available for retrieval by other systems, reporting interfaces, or subsequent workflow steps.\n\n### 5. Benefits and Customer Value\n\nStoring the `SiteAuditReport` documents provides immense value:\n\n* **Historical Performance Tracking:** Gain a clear understanding of your site's SEO health evolution over weeks, months, and years. Identify trends, regressions, and improvements.\n* **Actionable Fixes Database:** All Gemini-generated fixes are systematically stored, creating a repository of actionable tasks that can be referenced, tracked, and implemented by your development or SEO team.\n* **Measurable ROI:** Directly track the impact of SEO efforts by comparing `beforeAfterDiff` reports after implementing fixes.\n* **Comprehensive Reporting:** The structured data forms the backbone for generating custom reports, dashboards, and visualizations of your site's SEO performance.\n* **Compliance and Record-Keeping:** Maintain a verifiable record of your site's SEO compliance and audit history.\n\n### 6. Next Steps\n\nUpon successful completion of the `hive_db → upsert` step, the comprehensive `SiteAuditReport` for the current run is available in your MongoDB database. This data will then be leveraged by subsequent steps in the workflow for:\n\n* **Notification Generation:** Sending summaries of the audit results and critical issues via email or other channels.\n* **Dashboard Integration:** Populating SEO performance dashboards with the latest audit data.\n* **API Access:** Making the audit data accessible via API for integration with other tools or internal systems.\n\n## Step 5 of 5: `hive_db` → `conditional_update` - Site SEO Auditor Report Storage and Diff Generation\n\nThis document details the final and critical step in the \"Site SEO Auditor\" workflow: the secure and intelligent storage of your website's SEO audit report within the PantheraHive database (MongoDB), including the generation of a comprehensive \"before/after\" diff.\n\n### 1. Introduction to `conditional_update`\n\nThe `hive_db` → `conditional_update` step is responsible for persisting the full SEO audit results, identified issues, and generated fixes into your dedicated MongoDB instance. This step is \"conditional\" because it intelligently determines whether to create a *new* `SiteAuditReport` record or *update an existing one* for your site, ensuring data integrity and enabling historical tracking. A key feature of this step is the automatic calculation and storage of a \"before/after\" differential report, highlighting changes between the current and previous audits.\n\n### 2. Step Overview and Purpose\n\nFollowing the completion of the headless crawl (Puppeteer), the 12-point SEO checklist audit, the identification of broken elements, and the generation of exact fixes by Gemini, this step consolidates all this information.\n\n**Key Objectives:**\n\n* **Data Aggregation**: Collect all audit findings, issues, and proposed fixes into a structured format.\n* **Persistent Storage**: Store the complete `SiteAuditReport` in MongoDB for future reference, analysis, and historical tracking.\n* **Conditional Logic**:\n * If no previous audit exists for the given site, a new `SiteAuditReport` document is created.\n * If a previous audit exists, the existing document is updated with the latest results.\n* **Before/After Diff Generation**: Automatically compare the current audit's key metrics and issues against the most recent prior audit for the same site, generating a clear differential report.\n* **Workflow Completion**: Mark the SEO audit workflow as complete, making the report accessible via the PantheraHive interface or API.\n\n### 3. Data Structure: `SiteAuditReport` in MongoDB\n\nThe audit results are stored as a `SiteAuditReport` document in a dedicated MongoDB collection. Below is a detailed schema outlining the structure of this document:\n\n```json\n{\n \"_id\": ObjectId, // Unique identifier for the audit report\n \"siteId\": String, // Unique identifier for the audited website (e.g., domain)\n \"auditId\": String, // Unique identifier for this specific audit run\n \"timestamp\": ISODate, // Date and time when the audit was completed\n \"status\": \"completed\" | \"failed\", // Status of the audit\n \"auditType\": \"scheduled\" | \"on-demand\", // How the audit was triggered\n \"totalPagesCrawled\": Number, // Total number of pages visited\n\n \"summaryMetrics\": {\n \"totalIssuesFound\": Number,\n \"criticalIssues\": Number,\n \"warningIssues\": Number,\n \"infoIssues\": Number,\n \"pagesWithIssues\": Number,\n \"pagesPassedAllChecks\": Number,\n \"overallSeoScore\": Number // A calculated score based on findings\n },\n\n \"pages\": [\n {\n \"url\": String, // URL of the audited page\n \"statusCode\": Number, // HTTP status code (e.g., 200, 404)\n \"crawlDepth\": Number, // How deep the page is from the root\n \"loadTimeMs\": Number, // Page load time\n \"coreWebVitals\": {\n \"LCP\": Number, // Largest Contentful Paint (ms)\n \"CLS\": Number, // Cumulative Layout Shift (score)\n \"FID\": Number // First Input Delay (ms) - or INP if applicable\n },\n \"issuesFound\": [\n {\n \"checkName\": String, // e.g., \"Meta Title Uniqueness\", \"H1 Presence\"\n \"severity\": \"critical\" | \"warning\" | \"info\",\n \"description\": String, // Description of the issue\n \"details\": String, // Specific details like the problematic title, missing alt text element, etc.\n \"geminiFix\": {\n \"prompt\": String, // The prompt sent to Gemini\n \"fixDescription\": String, // Gemini's generated explanation of the fix\n \"codeSnippet\": String // Gemini's generated code snippet for the fix\n }\n }\n ],\n \"seoChecks\": {\n \"metaTitle\": { \"value\": String, \"length\": Number, \"isUnique\": Boolean, \"status\": \"pass\" | \"fail\" | \"na\" },\n \"metaDescription\": { \"value\": String, \"length\": Number, \"isUnique\": Boolean, \"status\": \"pass\" | \"fail\" | \"na\" },\n \"h1Presence\": { \"present\": Boolean, \"value\": String, \"status\": \"pass\" | \"fail\" },\n \"imageAltCoverage\": { \"totalImages\": Number, \"imagesWithoutAlt\": Number, \"status\": \"pass\" | \"fail\" },\n \"internalLinkDensity\": { \"totalLinks\": Number, \"internalLinks\": Number, \"status\": \"pass\" | \"fail\" },\n \"canonicalTag\": { \"present\": Boolean, \"value\": String, \"status\": \"pass\" | \"fail\" },\n \"openGraphTags\": { \"present\": Boolean, \"status\": \"pass\" | \"fail\" },\n \"structuredData\": { \"present\": Boolean, \"schemaTypes\": [String], \"status\": \"pass\" | \"fail\" },\n \"mobileViewport\": { \"present\": Boolean, \"status\": \"pass\" | \"fail\" }\n // ... other 12-point checks\n }\n }\n ],\n\n \"diffReport\": {\n \"previousAuditId\": String, // ID of the previous audit report this is compared against\n \"changesDetected\": Boolean,\n \"summaryChanges\": {\n \"totalIssuesFound\": { \"before\": Number, \"after\": Number, \"change\": Number },\n \"criticalIssues\": { \"before\": Number, \"after\": Number, \"change\": Number },\n // ... other summary metric changes\n },\n \"pageChanges\": [\n {\n \"url\": String,\n \"type\": \"new\" | \"removed\" | \"modified\",\n \"issueChanges\": [\n {\n \"checkName\": String,\n \"type\": \"new\" | \"resolved\" | \"modified\",\n \"description\": String,\n \"previousDetails\": String, // If modified\n \"currentDetails\": String // If modified\n }\n ],\n \"metricChanges\": [\n {\n \"metric\": String, // e.g., \"LCP\", \"metaTitle.length\"\n \"before\": Any,\n \"after\": Any\n }\n ]\n }\n ]\n }\n}\n```\n\n### 4. Conditional Logic and Update/Insert Operation\n\nThe `conditional_update` mechanism operates as follows:\n\n1. **Identify Site**: The system first identifies the target website (`siteId`) for which the audit was performed.\n2. **Query Previous Reports**: It queries the `SiteAuditReport` collection for the most recent `completed` audit report associated with that `siteId`.\n3. **Decision Point**:\n * **If No Previous Report Exists**: A brand new `SiteAuditReport` document (following the schema above) is created and inserted into the collection. The `diffReport` section will indicate no previous audit.\n * **If Previous Report Exists**:\n * The current audit results are compared against the found previous report.\n * A `diffReport` object is generated, detailing all changes.\n * A new `SiteAuditReport` document is created, containing the current audit data and the generated `diffReport`, and then inserted. This ensures an immutable history of each audit. The `diffReport.previousAuditId` field links to the prior audit.\n\n### 5. Before/After Diff Calculation Details\n\nThe differential report is a critical feature, providing immediate insight into the impact of changes on your site's SEO.\n\n**How the Diff is Calculated:**\n\n1. **Summary Metrics Comparison**: The `summaryMetrics` (e.g., `totalIssuesFound`, `criticalIssues`, `overallSeoScore`) from the current audit are directly compared against those from the `previousAuditId`. Any numerical differences are recorded.\n2. **Page-Level Comparison**:\n * **New Pages**: Pages present in the current audit but not in the previous one are marked as \"new.\"\n * **Removed Pages**: Pages present in the previous audit but not in the current one are marked as \"removed.\"\n * **Modified Pages**: For pages present in both audits, a deeper comparison is performed:\n * **Issue Changes**:\n * **New Issues**: Issues found in the current audit for a page that were *not* present in the previous audit for the same page.\n * **Resolved Issues**: Issues present in the previous audit for a page that are *no longer* present in the current audit for the same page.\n * **Modified Issues**: Cases where an issue (e.g., meta title length) changed its value or status.\n * **Metric Changes**: Significant changes in `coreWebVitals` (LCP, CLS, FID) or specific `seoChecks` values (e.g., meta title length, image alt coverage percentage) are recorded.\n\nThe `diffReport` is then embedded directly within the new `SiteAuditReport` document, making it easily accessible alongside the full audit data.\n\n### 6. Output and Deliverable\n\nUpon successful execution of this step, the following will be delivered to the customer:\n\n* **Confirmation of Audit Completion**: A notification indicating that the SEO audit for your site (`[Your_Website_URL]`) has been successfully completed and the report stored.\n* **Database Record**: A new `SiteAuditReport` document will be available in your PantheraHive MongoDB instance, accessible via the platform's reporting interface or directly through API calls.\n* **Access to Report**: You will be provided with a direct link or instructions to access the detailed `SiteAuditReport`, including:\n * **Full Audit Data**: Comprehensive results for all 12 SEO checks across all crawled pages.\n * **Identified Issues**: A list of all broken elements, categorized by severity.\n * **Gemini Fixes**: For each identified issue, the exact, actionable fix generated by Gemini will be presented.\n * **Before/After Diff Report**: A clear summary of how your site's SEO metrics and issues have changed since the last audit.\n* **Historical Tracking**: The system will automatically maintain a chronological history of all your site's SEO audits, allowing you to track progress over time.\n\n### 7. Actionable Insights and Next Steps for the Customer\n\nWith the `SiteAuditReport` now stored, you can:\n\n* **Review the Diff Report**: Immediately identify key improvements or regressions since the last audit. This is your quickest way to understand recent impacts.\n* **Prioritize Fixes**: Use the severity ratings and Gemini's generated fixes to prioritize and implement changes on your website.\n* **Monitor Progress**: Track the `overallSeoScore` and `totalIssuesFound` over time to measure the effectiveness of your SEO efforts.\n* **Share with Team**: Export or share the report with your development or marketing teams to facilitate issue resolution.\n* **Leverage On-Demand Audits**: If significant changes are made to your site, trigger an on-demand audit to quickly verify the impact of your fixes.\n\nThis `conditional_update` step ensures that your SEO audit data is not only securely stored but also intelligently structured to provide immediate, actionable insights for continuous improvement.";function phTab(btn,name){document.querySelectorAll(".ph-panel").forEach(function(el){el.classList.remove("active");});document.querySelectorAll(".ph-tab").forEach(function(el){el.classList.remove("active");el.classList.add("inactive");});var p=document.getElementById("panel-"+name);if(p)p.classList.add("active");btn.classList.remove("inactive");btn.classList.add("active");if(name==="preview"){var fr=document.getElementById("ph-preview-frame");if(fr&&!fr.dataset.loaded){if(_phIsHtml){fr.srcdoc=_phCode;}else{var vc=document.getElementById("panel-content");fr.srcdoc=vc?""+vc.innerHTML+"":"

No content

";}fr.dataset.loaded="1";}}}function phCopyCode(){navigator.clipboard.writeText(_phCode).then(function(){var b=document.getElementById("tab-code");if(b){var o=b.innerHTML;b.innerHTML=' Copied!';setTimeout(function(){b.innerHTML=o;},2000);}});}function phCopyAll(){var txt=_phAll;if(!txt){var vc=document.getElementById("panel-content");if(vc)txt=vc.innerText||vc.textContent||"";}navigator.clipboard.writeText(txt).then(function(){alert("Content copied to clipboard!");});}function phDownload(){var content=_phCode||_phAll;if(!content){var vc=document.getElementById("panel-content");if(vc)content=vc.innerText||vc.textContent||"";}if(!content){alert("No content to download.");return;}var fn=_phFname;if(!_phCode&&fn.endsWith(".txt"))fn=fn.replace(/\.txt$/,".md");var a=document.createElement("a");a.href="data:text/plain;charset=utf-8,"+encodeURIComponent(content);a.download=fn;a.click();}function phDownloadZip(){ var lbl=document.getElementById("ph-zip-lbl"); if(lbl)lbl.textContent="Preparing…"; /* ===== HELPERS ===== */ function cc(s){ return s.replace(/[_-s]+([a-z])/g,function(m,c){return c.toUpperCase();}) .replace(/^[a-z]/,function(m){return m.toUpperCase();}); } function pkgName(app){ return app.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")||"my_app"; } function slugTitle(app){ return app.replace(/_/g," "); } /* Generic code block extractor. Finds marker comments like: // lib/main.dart or # lib/main.dart or ## lib/main.dart and collects lines until the next marker. Also strips markdown fences (```lang ... ```) from each block. */ function extractFiles(txt, pathRe){ var files={}, cur=null, buf=[]; function flush(){ if(cur&&buf.length){ files[cur]=buf.join(" ").trim(); } } txt.split(" ").forEach(function(line){ var m=line.trim().match(pathRe); if(m){ flush(); cur=m[1]; buf=[]; return; } if(cur) buf.push(line); }); flush(); // Strip ```...``` fences from each file Object.keys(files).forEach(function(k){ files[k]=files[k].replace(/^```[a-z]* ?/,"").replace(/ ?```$/,"").trim(); }); return files; } /* General path extractor that covers most languages */ function extractCode(txt){ var re=/^(?://|#|##)s*((?:lib|src|test|tests|Sources?|app|components?|screens?|views?|hooks?|routes?|store|services?|models?|pages?)/[w/-.]+.w+|pubspec.yaml|Package.swift|angular.json|babel.config.(?:js|ts)|vite.config.(?:js|ts)|tsconfig.(?:json|app.json)|app.json|App.(?:tsx|jsx|vue|kt|swift)|MainActivity(?:.kt)?|ContentView.swift)/i; return extractFiles(txt, re); } /* Detect language from combined code+panel text */ function detectLang(code, panel){ var t=(code+" "+panel).toLowerCase(); if(t.indexOf("import 'package:flutter")>=0||t.indexOf('import "package:flutter')>=0) return "flutter"; if(t.indexOf("statelesswidget")>=0||t.indexOf("statefulwidget")>=0) return "flutter"; if((t.indexOf(".dart")>=0)&&(t.indexOf("pubspec")>=0||t.indexOf("flutter:")>=0)) return "flutter"; if(t.indexOf("react-native")>=0||t.indexOf("react_native")>=0) return "react-native"; if(t.indexOf("stylesheet.create")>=0||t.indexOf("view, text, touchableopacity")>=0) return "react-native"; if(t.indexOf("expo(")>=0||t.indexOf(""expo":")>=0||t.indexOf("from 'expo")>=0) return "react-native"; if(t.indexOf("import swiftui")>=0||t.indexOf("import uikit")>=0) return "swift"; if(t.indexOf(".swift")>=0&&(t.indexOf("func body")>=0||t.indexOf("@main")>=0||t.indexOf("var body: some view")>=0)) return "swift"; if(t.indexOf("import android.")>=0||t.indexOf("package com.example")>=0) return "kotlin"; if(t.indexOf("@composable")>=0||t.indexOf("fun mainactivity")>=0||(t.indexOf(".kt")>=0&&t.indexOf("androidx")>=0)) return "kotlin"; if(t.indexOf("@ngmodule")>=0||t.indexOf("@component")>=0) return "angular"; if(t.indexOf("angular.json")>=0||t.indexOf("from '@angular")>=0) return "angular"; if(t.indexOf(".vue")>=0||t.indexOf("