Back to writing
8 min read

Architecting an Autonomous pSEO Pipeline: Merging Next.js 16, CrewAI, and Gemini

In the modern web ecosystem, flashy UIs are commodities. The true competitive moat is structured, verified, and enriched data. When I set out to build highly profitable, niche online directories, I realized that human bottlenecking—specifically in data acquisition and content generation—was the single biggest barrier to scale.

To solve this, I architected DirectoryAgent: an 8-phase, autonomous AI pipeline that leverages CrewAI, Google Gemini 2.5 Flash, and Next.js 16 to deploy localized, programmatic SEO (pSEO) at scale. Here is how the architecture is constructed.

The Philosophy: Solve High-Value, "Boring" Problems

Generative AI is often wasted on writing generic blog posts. I wanted to apply agentic workflows to high-transaction, low-transparency niches. Take Commercial Kitchen Fire Suppression (NFPA 96 compliance). A single lead for an ANSUL system installation is worth $50-$100 to a contractor. The data is messy, highly localized, and deeply technical. It is the perfect target for an AI agent.

The Agentic Layer: CrewAI & Gemini 2.5 Flash

The backend of DirectoryAgent operates autonomously using a Python-based CrewAI pipeline backed by Gemini 2.5 Flash and local SQLite storage.

  • Phase 1: Raw Acquisition: We utilize Outscraper APIs to pull 15,000+ raw leads across target geographies.
  • Phase 2: The Verification Crawler: A swarm of AI agents uses tools like Crawl4AI to visit every single URL. If a contractor's site explicitly says "Residential Only" or resolves to a 404, the agent drops the row.
  • Phase 3: Deep Enrichment: This is where Gemini shines. The agents parse the verified DOMs to extract deep schema attributes: Are they UL 300 certified? Do they offer 24/7 emergency recharges? Do they service food trucks? This data is formatted into strict JSON.

The Presentation Layer: Next.js 16 App Router

A database is only as good as its delivery mechanism. The enriched JSON is fed into a Next.js 16 frontend.

  • Strict Async Params: Utilizing Next.js 16's strict asynchronous route parameters (const { slug } = await params;), we programmatically generate thousands of City Hubs (e.g., /tx/dallas/food-truck-fire-systems).
  • JSON-LD Schema Injection: Every contractor profile dynamically injects LocalBusiness and AggregateRating schema. The knowsAbout array is populated with the specific certifications (e.g., "NFPA 96") extracted by our Gemini agents in the previous step.
  • Authority Generation: To avoid Google's thin-content penalties, our pipeline automatically writes 500+ word "Authority Articles" (e.g., "The Complete Guide to Restaurant Fire Codes in Dallas") for every city hub.

The Result

By combining the reasoning capabilities of Gemini 2.5 Flash with the rendering speeds of Next.js 16, DirectoryAgent doesn't just build websites; it builds localized, self-sustaining data moats. It is a testament to the power of programmatic architecture applied to real-world, high-value problems.

Building tech for faith & family.

Fam Kit is a growing collection of free, privacy-first micro-apps built for Christian families — Scripture memory, family prayer walls, life planning tools, and more. No tracking. No subscriptions required to use. Built with purpose.

Explore Fam Kit →