DEV Community

Diven Rastdus
Diven Rastdus

Posted on

I Built an AI SEO Blog Writer That Reads Your Website First

Every business needs blog content for SEO. Most use one of two approaches:

  1. Pay agencies $300-500 per post and wait 2 weeks
  2. Use ChatGPT and get generic content that doesn't match their brand

I built a third option: Blogmatic -- an AI tool that actually reads your website before writing.

The Problem with Generic AI Writing

When you tell ChatGPT "write a blog post about marketing," it produces the same output whether you're a law firm, a SaaS company, or a bakery. There's no brand awareness, no industry context, no understanding of what you've already written about.

How Blogmatic Works

  1. Paste your URL -- that's it, just your website address
  2. Site analysis -- Blogmatic crawls your site using Cheerio, extracting headings, paragraphs, meta descriptions, and internal links
  3. Industry detection -- keyword frequency analysis across 10 industry categories (SaaS, e-commerce, healthcare, finance, etc.)
  4. Tone detection -- analyzes word patterns to determine if your site is formal, conversational, or professional
  5. Keyword extraction -- identifies your top keywords by frequency, filtering stop words
  6. AI generation -- Gemini 2.5 Flash generates a structured blog post using all this context

The output: a 1500-2000 word post with proper title (50-60 chars), meta description (150-155 chars), 5-7 H2 sections, natural keyword density, and a FAQ section ready for schema markup.

The Tech Stack

  • Next.js 14 with App Router and server components
  • Supabase for auth (email + Google SSO), Postgres database with Row Level Security
  • Gemini 2.5 Flash -- fast, cheap, surprisingly good at structured output with responseMimeType: 'application/json'
  • Cheerio for HTML parsing (lightweight, no headless browser needed)
  • Stripe for subscriptions (checkout sessions + webhooks)
  • Vitest for testing (28 tests covering analyzer, API routes, Stripe config)
  • Vercel for hosting

Key Technical Decision: Structured JSON Output

Instead of parsing free-form AI text, I use Gemini's responseMimeType: 'application/json' to force structured output:

const response = await ai.models.generateContent({
  model: 'gemini-2.5-flash',
  contents: prompt,
  config: {
    responseMimeType: 'application/json',
  },
})
Enter fullscreen mode Exit fullscreen mode

This returns clean JSON every time -- no regex parsing, no markdown stripping, no "sometimes it wraps in code fences" issues.

The Site Analyzer

The analyzer is surprisingly simple but effective:

const INDUSTRY_KEYWORDS: Record<string, string[]> = {
  'saas': ['software', 'platform', 'dashboard', 'api', 'integration'],
  'e-commerce': ['shop', 'buy', 'cart', 'product', 'price'],
  // ... 10 industries
}

function detectIndustry(text: string): string {
  let bestMatch = 'general'
  let bestScore = 0
  for (const [industry, keywords] of Object.entries(INDUSTRY_KEYWORDS)) {
    const score = keywords.filter(kw => text.includes(kw)).length
    if (score > bestScore) { bestScore = score; bestMatch = industry }
  }
  return bestMatch
}
Enter fullscreen mode Exit fullscreen mode

No ML model needed. Simple keyword frequency matching across pre-defined industry vocabularies. Works well enough for content generation context.

Try It

Blogmatic is live and free to try (3 posts/month, no credit card):

https://blogmatic.vercel.app

GitHub: https://github.com/astraedus/blogmatic

I'd love feedback -- especially from anyone doing content marketing. What's missing?

Top comments (0)