Overview
Rankloop's founder came to us with a bold idea: build a platform where businesses could automate their entire SEO content strategy end-to-end — from keyword research to AI-generated articles to one-click publishing — and then amplify results through an automated backlink exchange network that had never been built before. The tagline says it all: "Ahrefs shows you the problem. We fix it."
The scope was significant. The platform needed integrations with three LLM providers for content generation, six CMS platforms for publishing, external SEO data APIs for keyword intelligence, Stripe for subscription billing, and a completely novel peer-to-peer backlink trading system.
Our team designed and developed the entire platform from scratch as a multi-tenant Rails 7 SaaS application. The final delivery included 46 database models, 48 service objects, 57 background jobs, and an autonomous AI agent framework — an enterprise-grade SEO automation platform that handles everything a full content team would do, but autonomously.
💡
The Challenge
Building Rankloop pushed us across every layer of the stack. Here are the key technical challenges we had to solve:
Multi-LLM Content Generation Pipeline
The AI content engine needed to work with Claude, GPT, and Gemini at the same time — each with different APIs, token limits, response formats, and pricing models. Content generation is a multi-step pipeline (keyword analysis, outline creation, full article, images, link injection, metadata) where each step can take 30 to 60 seconds, requiring careful background job orchestration.
Six-Platform CMS Publishing
Each CMS — WordPress, Webflow, Notion, Shopify, Hygraph, and custom APIs — has entirely different APIs, content formats, image handling, and authentication mechanisms. The WordPress integration alone grew to a 142 KB service to cover all edge cases including featured image upload, category mapping, custom field support, and automatic retry logic.
Backlink Exchange Matching Algorithm
No off-the-shelf solution existed for automated backlink trading. We needed to design a matching engine from scratch that evaluates semantic relevance between source articles and target pages, weighs domain authority, enforces safety rules to avoid toxic link neighborhoods, manages a credit-based economy, and handles the full lifecycle from matching through post-publication verification.
AI Visibility Tracking Across Seven Platforms
Monitoring how brands appear in AI-generated responses (ChatGPT, Perplexity, Google AI Overview, Claude, Copilot, Reddit, Google Search) required platform-specific querying strategies, response parsing, mention classification into explicit, implicit, and cited categories, and competitor comparison — all running on recurring daily schedules.
Concurrency and Race Conditions
With 57 background jobs running in parallel — content generation, backlink matching, verification cycles, visibility snapshots — preventing race conditions was critical. Two matching jobs running at the same time could assign the same backlink credit twice. Two publishing jobs could create duplicate CMS entries for the same article.
Multi-Tenant Data Isolation
Every database query, every background job, every API call must be scoped to the correct workspace. A backlink matching run must never leak data between workspaces. Content generation must respect workspace-specific brand voice settings, CMS credentials, and domain profiles.
⚡
Our Solution
We architected Rankloop as a modular Rails 7 application with clear service boundaries and robust concurrency controls at every level.
Multi-LLM Abstraction Layer
We built dedicated client wrappers (AnthropicClient, OpenAiClient, GeminiClient) that normalize API differences behind a common interface. The content generation pipeline uses an 18-service architecture:
- ContentGenerationService orchestrates the entire pipeline from keyword to published article
- OutlineBuilder generates hierarchical article structures that can be reviewed and edited before writing
- DraftBuilder produces the full long-form article content with SEO optimization
- RefinementEngine handles link injection, CTA placement, and final optimization passes
- ImageGenerator creates AI-powered featured images and in-article visuals
- YoutubeVideoFinder discovers and embeds relevant videos to enrich each piece
Each step runs as an independent operation, so a failed image generation does not force regeneration of the entire article.
Platform-Specific CMS Services
Each CMS integration is a self-contained service (ranging from 13 KB to 142 KB) handling:
- Authentication and credential management scoped to each workspace
- Content format transformation — converting between HTML, Markdown, and platform-specific block formats
- Image upload with platform-specific size requirements and format conversion
- Metadata mapping for tags, categories, custom fields, and schema markup
- Error handling with exponential backoff retry and publishing status tracking
Backlink Exchange Engine
The matching system (BacklinkMatchingService at 89 KB) runs on a daily schedule and executes a multi-step process:
- Collects all eligible source articles and target pages across the entire network
- Computes semantic relevance scores between every potential source-target pair
- Weights matches by domain authority using fresh Ahrefs DR data
- Applies safety rules via BacklinkSafetyRulesService to avoid toxic link neighborhoods
- Assigns credit costs based on DR tiers, so higher-authority sites earn and cost proportionally more
- Creates placement records and queues injection jobs for content generation
- Runs post-publication verification through headless Chrome (Ferrum) to confirm links are live
- Handles automatic rotation when links go stale or get removed
PostgreSQL Advisory Locks
We used the with_advisory_lock gem throughout the codebase to prevent concurrent job execution. Every matching run, verification cycle, and content generation job acquires a workspace-scoped advisory lock before proceeding. This eliminates race conditions without reducing overall throughput — jobs for different workspaces still run in full parallel.
AI Visibility Monitoring
The visibility tracking system uses a suite of specialized services:
- SnapshotService queries each AI platform with tracked keywords and captures raw responses
- GapAnalysisService identifies queries where competitors are mentioned but the client brand is absent
- ShareOfVoiceService calculates brand visibility percentage with trend tracking over time
- BrandRadarOnboardingService integrates Ahrefs data for automatic competitor discovery
- One-click content generation that directly targets identified visibility gaps
Agent Framework
Autonomous agents with full lifecycle management:
- Execution state stored in agent_runs with JSONB parameters for flexible configuration
- Cron-based scheduling for ambient agents (visibility monitor, competitor watcher, campaign tracker)
- On-demand execution for interactive agents (content generator, SEO optimizer, keyword researcher)
- Complete audit trail via agent_logs with timestamped entries for every action taken
Stripe Billing Integration
Full subscription lifecycle management through a dedicated StripeService (27 KB):
- Plan selection with configurable trial periods and usage limits
- Promotional code support with validation and tracking
- Webhook handling for all subscription state changes (created, updated, cancelled, payment failed)
- Self-service billing portal integration for plan changes and payment method updates
- One-time purchases for premium backlink credits outside the subscription
📈
Results & Impact
Rankloop launched as a fully operational SaaS platform with strong technical depth across every area of the product.
Platform Scale
- 46 database models with over 155 migrations tracking the full schema evolution
- 48 service objects encapsulating all core business logic outside of controllers
- 57 Sidekiq background jobs with advisory lock protection at the workspace level
- 54 controllers organized across public, dashboard, admin, and API namespaces
- A full REST API (v1) powering external integrations and the mobile-ready frontend
Content Generation Capabilities
- Multi-LLM support with Claude, GPT, and Gemini, including automatic fallback if a provider is unavailable
- End-to-end SEO optimization covering headings, internal links, CTAs, images, YouTube embeds, and schema markup
- Configurable brand voice, tone, and CTA settings on a per-workspace basis
- Content scheduling with automatic publication at specified dates and times
Publishing Reach
- One-click publishing to WordPress, Webflow, Notion, Shopify, Hygraph, and any custom REST API
- Automated image processing and upload tailored to each platform's specifications
- Post-publish verification confirming that content is live and correctly formatted
Backlink Network Performance
- AI-powered matching with semantic relevance scoring producing high-quality link pairs
- Credit-based economy weighted by domain authority that keeps the marketplace fair for all participants
- Automated contextual injection that places links naturally within article content
- Headless browser verification confirming every link is live after publication
- Rotation engine that maintains link freshness and replaces removed placements automatically
AI Visibility Intelligence
- Real-time monitoring across ChatGPT, Perplexity, Google AI Overview, Claude, Copilot, and Reddit
- Share of Voice analytics with competitor benchmarking and historical trend tracking
- Gap-to-content pipeline that identifies where the brand is invisible and generates targeting content in one click
Infrastructure and Operations
- Docker Compose deployment with separate web, Sidekiq worker, and Redis containers
- PostgreSQL with composite indexing and advisory locks for safe concurrent processing
- AWS S3 for image storage with MiniMagick processing and on-the-fly resizing
- Google OAuth2 and magic link authentication for passwordless sign-in
- Rollbar integration for exception tracking with full stack trace context
Business Impact
The platform handles the full SEO content workflow that typically requires a team of content writers, SEO specialists, and outreach managers — all running autonomously. The backlink exchange network creates mutual value for every participant through intelligent matching. The AI visibility tracking provides competitive intelligence that is not available in any existing SEO tool on the market.
Technical Deep-Dive
Service Architecture
Rankloop follows a service-object pattern where controllers stay thin and all business logic lives in dedicated service classes. The largest services reflect the areas of highest complexity:
- WordpressPostingService (142 KB) — full WordPress REST API integration covering every publishing edge case
- BacklinkMatchingService (89 KB) — the AI-powered link matching engine with relevance scoring and safety checks
- ContentSchedulingService (72 KB) — content calendar orchestration with automatic publication triggers
- BacklinkPlacementService (52 KB) — link placement lifecycle from creation through verification and rotation
- BacklinkContentInjectionService (50 KB) — contextual link insertion that reads article content and finds natural placement points
Database Design
Key design decisions that keep the platform performant and maintainable:
- JSONB fields for flexible storage of agent parameters, backlink metadata, and raw AI responses without schema rigidity
- PostgreSQL advisory locks at the database level for concurrency control across all background jobs
- Composite indexes on high-traffic column pairs (workspace_id + status) for fast filtered queries
- Soft deletes for users and workspaces with full restoration support to prevent accidental data loss
- Enum-based state machines tracking content through the pending to published lifecycle with guard clauses on transitions
Background Job Strategy
With 57 job types, we organized them into three priority tiers:
- Critical — content generation, publishing, and payment webhooks run with immediate retry on failure
- Important — backlink matching, verification cycles, and visibility snapshots run on scheduled daily cadences
- Background — domain rating tracking, email nudges, and analytics aggregation run at low priority during off-peak hours
Every job acquires a workspace-scoped advisory lock before execution, guaranteeing that no two instances of the same job type run concurrently for the same workspace while still allowing full parallelism across different workspaces.
Security and Multi-Tenancy
- Pundit policies enforce workspace-scoped authorization on every controller action without exception
- API keys with scoped permissions for external integrations, each key tied to a specific workspace
- Admin impersonation feature for support debugging, with full audit logging of impersonated sessions
- Google OAuth2 combined with magic link authentication for a passwordless sign-in experience
- Stripe webhook signature validation on every incoming event to prevent spoofed payment notifications
Monitoring and Observability
- Rollbar integration for exception tracking with grouped errors and deployment markers
- Agent execution logs providing a complete audit trail for every autonomous action
- Domain rating history tracking with email alerts sent when a workspace's DR improves
- Admin health check dashboard showing workspace diagnostics, job queue depth, and integration status
- UTM analytics for marketing attribution across landing pages and referral sources
Technology Stack
Ruby on Rails 7
PostgreSQL
Redis
Sidekiq
Stimulus JS
Tailwind CSS
Hotwire
Turbo
Stripe
AWS S3
Docker
Anthropic Claude API
OpenAI API
Google Gemini API
Ahrefs API
Google Search Console API
Ferrum
Nokogiri