RAIA™ Specification

Documentation

Every night, RAIA™ (Real estate Artificial Intelligence Agent) checks the popularity and authority of potential landlord and agency websites using a free Ahrefs tool. By checking this score in the background, our sales agents can instantly see

← Back to Developer Hub TEXTBOOK SPECIFICATION
RAIA™ (Real estate Artificial Intelligence Agent) Specification

Every night, RAIA™ (Real estate Artificial Intelligence Agent) checks the popularity and authority of potential landlord and agency websites using a free Ahrefs tool. By checking this score in the background, our sales agents can instantly see

🧩 Section A: In Plain English

Ahrefs Free Domain Rating Integration

This integration pulls Ahrefs free domain rating data to assess the authority and trustworthiness of property listing websites, helping agents prioritize high-quality lead sources.

📘 SECTION 3.24 TECHNICAL SPECIFICATION & ARCHITECTURE BLUEPRINT
🧩 What this page is about

Every night, RAIA™ (Real estate Artificial Intelligence Agent) checks the popularity and authority of potential landlord and agency websites using a free Ahrefs tool. By checking this score in the background, our sales agents can instantly see which leads have the most valuable real estate portfolios—all without manual research or paying for expensive API keys.

2. How it works — operational workflow

RAIA's GTM lead generation pipeline automatically scans Companies House and regional directories to find newly registered property firms and independent agencies. However, raw lists contain thousands of entries, many of which are dormant or low-value. To target our outreach effectively, the system uses the Ahrefs free Domain Rating (DR) API to score the digital authority of each lead's website. High-DR sites correlate with established portfolios, indicating high-value commissions.

Step-by-Step Data Enrichment

  • 1
    Nightly Lead Ingestion

    The nightly cron task pulls newly discovered property agencies from Companies House and writes them as cold leads to the database.

  • 2
    Domain Extraction & Normalization

    The GTM scraper extracts corporate URLs from lead metadata and strips subdirectories, protocols, and query strings to get a canonical domain name (e.g., example.co.uk).

  • 3
    Public Ahrefs Rating Query

    RAIA™ (Real estate Artificial Intelligence Agent) dispatches a direct, unauthenticated GET request to Ahrefs' public API to fetch the domain's authority rating (DR) on a scale from 0 to 100.

  • 4
    Database Storage & Sync

    The returned rating is upserted into the lead's data profile (tbl_organisations_data), instantly updating our systems.

  • 5
    Dashboard Triage for Sales Staff

    When our sales team logs in at 09:00, the admin dashboard displays newly enriched prospects sorted by Domain Rating, allowing them to prioritize high-value companies immediately.

A Day in the Life of the Scraper

The entire enrichment pipeline operates fully autonomously in the background. The table below outlines how the system schedules, executes, and surfaces the scored leads:

Time Event / Trigger Which Agent What Agent Does What You See
02:00 Nightly Cron Wakeup GTM Ingest Agent Imports fresh listings from Companies House New records added to tbl_companies_house_leads
02:30 Lead Pre-processing Enrichment Agent Parses, cleans, and canonicalizes corporate URLs Domain fields populated in lead rows
02:35 Ahrefs REST Query Domain Scraper Agent GET requests sent to the free Ahrefs endpoint Responses processed in milliseconds
02:40 Database Ledger Sync Database Sync Agent Upserts fresh DR values into organization tables Database metrics fully populated
09:00 Daily Login Agency Sales Staff Opens the Sales Portal to manage outreach Dashboard lists leads prioritized by DR badge

Operational Flowchart

1. DATA INGEST Companies House Daily cold leads dump 2. NORMALIZATION Domain Parser Extracts clean domain 3. ENRICHMENT Ahrefs Public API Instant, free DR lookup 4. ACTION Sales Portal Prioritize scored leads

3. Technical — how it works in code

The domain rating scraper is integrated into RAIA's nightly pipeline scripts. By calling Ahrefs' unauthenticated endpoint with the appropriate query string, we bypass the need for paid API tokens, while wrapping calls in retry logic to prevent transient network failures or rate limits.

Repository Code

The live codebase implementation for this specification sits within the following repository folder:

4.477-10-10-10z"/>

Repository Code

The live codebase implementation for the Ahrefs lead rating scraper and cron synchronization sits within:

Active Code Implementation (Python)

Below is the core Python logic used to query Ahrefs' public API and securely update the Supabase database:

import requests
import time

def fetch_ahrefs_domain_rating(domain: str, max_retries: int = 3) -> float:
    """
    Queries Ahrefs' free public Domain Rating endpoint.
    Bypasses the need for API keys while utilizing basic backoff retries.
    """
    url = "https://api.ahrefs.com/v3/public/domain-rating-free"
    params = {"target": domain}
    
    for attempt in range(max_retries):
        try:
            response = requests.get(url, params=params, timeout=10)
            if response.status_code == 429:
                time.sleep(2 ** attempt)  # Exponential backoff on rate limits
                continue
            response.raise_for_status()
            data = response.json()
            return data.get("domain_rating", {}).get("domain_rating", 0.0)
        except Exception as e:
            if attempt == max_retries - 1:
                print(f"Error querying Ahrefs for {domain}: {e}")
                return 0.0
            time.sleep(1)
    return 0.0

Database Schema & Storage Queries

The extracted score is stored directly inside tbl_organisations_data under the JSONB field or dedicated columns. Sales portals query this data directly to build dynamic badges:

-- Upserting lead with updated Domain Rating
UPDATE public.tbl_organisations_data
SET snapshot_static = jsonb_set(
    COALESCE(snapshot_static, '{}'::jsonb),
    '{ahrefs_domain_rating}',
    '45.5'::jsonb
)
WHERE organisation_id = 'org_01jh823528b';

-- Querying and sorting prospects by authority score
SELECT 
    organisation_id, 
    name, 
    (snapshot_static->>'ahrefs_domain_rating')::float AS domain_rating
FROM public.tbl_organisations_data
WHERE (snapshot_static->>'ahrefs_domain_rating') IS NOT NULL
ORDER BY domain_rating DESC
LIMIT 50;

Sequence Diagram & Error States

This sequence diagram documents the end-to-end API exchange, illustrating the exponential backoff loop for rate limits (HTTP 429) and silent failure fallbacks to keep the cron runner robust:

RAIA (Real estate Artificial Intelligence Agent) Scraper Ahrefs Public API Supabase DB GET ?target=domain.com HTTP 429 Too Many Requests Backoff delay (2s) GET ?target=domain.com (Retry) HTTP 200 { "domain_rating": ... } UPSERT DR into tbl_organisations_data

Cross-References & Connected Systems

This pipeline is part of the larger GTM & Lead Enrichment system. Check out these related specs to see how it fits together:

🔧 Section C: Developer Guide

Architecture Details

Integration architecture uses a hub-and-spoke model with a central integration engine that manages API connections, data transformation, and error handling. Each external integration is a self-contained adapter with its own configuration, rate limiting, and health monitoring.

  • Core Component: Integration engine and adapter registry
  • Data Flow: External API → Adapter → Normalisation → Core Processing → Response → Adapter → External API
  • Integration Points: REST APIs, webhooks, OAuth2, rate limiters, circuit breakers

Configuration Reference

Key configuration parameters for this system:

Parameter Type Default Description
integration_timeout integer 15000 API call timeout in milliseconds
rate_limit_rpm integer 60 Maximum requests per minute
circuit_breaker_threshold integer 5 Failure count before circuit opens
INTEGRATION ARCHITECTURE — ADAPTER → NORMALISE → CORE 1. ADAPTER LAYER External API Adapters Auth & Rate Limiting 🔌 Adapters 2. NORMALISATION Data Transformation Schema Mapping 🔄 Normalise 3. CORE ENGINE Business Logic Event Dispatch ⚙️ Core Engine Hub-and-spoke integration: adapters normalise external data, core engine processes and dispatches events Adapter pattern · Rate limiting · Circuit breaker · OAuth2 · Schema mapping Adapters / External Normalisation / Mapping Core / Business Logic Data flow →

Figure 2: Integration architecture — component interaction and data flow.

Troubleshooting

Issue Cause Resolution
API rate limit exceeded High request volume exceeding provider limits Implement request queuing or increase rate_limit_rpm
Adapter connection failure Provider API outage or credential expiry Check provider status page and rotate credentials
Repo Reference RAIA

This component is part of the RAIA (Real estate Artificial Intelligence Agent) platform mono-repo. Implementation details, API contracts, and integration tests are available in the repository.