Local SEO and Competitor Intelligence
This area covers two related growth tools: local business directory/citation management (DirectoryListings.tsx) and competitor analysis (Competitors.tsx), backed by the citation-audit, citation-build and competitor-intelligence edge functions.
Directory listings and citations
DirectoryListings.tsx manages one or more business_locations per user — business name, address, city, postcode, phone, website, description and categories — each checked against a fixed list of 45 major UK and global directories (Google Business Profile, Bing Places, Yell, Thomson Local, Yelp, Facebook, FreeIndex, Scoot, Cylex UK, Hotfrog, Foursquare, Brownbook, Bark, Checkatrade, TrustATrader, Trustpilot, and around 30 more).
Citation audit
Clicking "Scan" on a location calls the citation-audit function with the locationId. It checks the business against the directory list and returns an audit_results payload including a listed_count, missing_count and a health_score, plus a per-directory status (listed/missing/unknown). The page shows this as a progress bar and a "Found on X/45 directories" summary, and stores the result with a last_audited_at timestamp.
Citation build
The "Build" action calls citation-build, which reads the location's most recent audit, filters to directories marked missing or unknown, and produces a submission plan: for the directories where Rank Pilot AI SEO has a known submission URL (a hard-coded map of ~19 major directories), it marks the entry submitted and provides a direct link plus pre-filled instructions using the business's name, address and phone; for the rest it marks manual_required and suggests a search query (e.g. "Directory Name add business"). The result — total missing, count auto-linkable vs manual, and the full submission list — is saved to build_results with a last_built_at timestamp.
Locations can be added via BusinessListingForm, edited, or deleted. Each location card shows a pro_status badge (tied to a Stripe payment for citation-building, where relevant) alongside the audit health score.
Competitors
Competitors.tsx lets a user track named competitor domains per website (stored in the competitors table) and run either a quick analysis or a full competitor intelligence report.
Competitor intelligence pipeline
The full report runs through a staged pipeline, shown to the user as a step tracker: SERP Research → Client Analysis → Competitor Analysis → Directory Scout → Synthesis & Roadmap → Complete. This is powered by the competitor-intelligence edge function, which:
- Calls the AI gateway (OpenRouter first, Lovable AI Gateway fallback) with tool-calling to produce structured JSON output at each stage rather than free text.
- Fetches and reads live page HTML/meta for the client site and each competitor via a safe fetcher that blocks SSRF-risky URLs (loopback, private ranges, CGNAT, link-local,
.internal/.localhosts) before requesting, using aRankPilotBot/1.0user agent with a 10-second timeout. - Synthesises findings into impact-rated opportunities and prioritised action items, each tagged
high/medium/lowand colour-coded in the UI (red/amber/green).
Results are rendered through a set of dashboard "JSON cards" — CompetitorJSONCard, AnomalyDetectionJSONCard, SEOInsightsJSONCard and WeeklyRecapJSONCard — which present structured competitor findings, anomalies, SEO insights and a recap in a consistent card format, reused elsewhere in the app (e.g. in Reports).
Adding a competitor requires only a domain (the app strips any protocol and trailing slashes) and an optional display name and seed keyword; from there a user can trigger quick or full analysis for that domain against the current website.