Skip to content

langscot/deadarticles

Repository files navigation

Dead Articles

An AI-powered article generator that creates realistic-looking but entirely fabricated news articles on demand — a playful experiment inspired by the dead internet theory.

Built as a learning project to explore two things:

  1. Google's Gemini Flash models — the new generation of fast, lightweight models that can generate full articles in seconds, making on-demand content generation feel instant.
  2. Cloudflare Workers and the broader Cloudflare ecosystem — Workers, KV storage, Turnstile, Pages, and AI Gateway. The whole edge-first, serverless approach to building web apps.

The result is a site where any URL path becomes a fully generated article. Visit /the-rise-of-sentient-toasters and you'll get a convincing, styled article about sentient toasters — streamed to your browser in real time.

How It Works

  1. A user visits a URL like /some-article-title
  2. If the article is cached in Cloudflare KV, it's served instantly via SSR
  3. If not, the user completes a Cloudflare Turnstile challenge
  4. The title is sent to Gemini 2.0 Flash Lite, which streams back a full markdown article
  5. The article is checked against OpenAI's moderation API for content safety
  6. The result is cached in KV and rendered with one of 5 random visual themes

Features

  • Streaming generation — articles appear progressively as the AI writes them
  • Edge caching — cached articles are served instantly from Cloudflare KV
  • Content moderation — OpenAI moderation prevents harmful content
  • Multiple themes — 5 different article styles, randomly assigned
  • Turnstile protection — prevents automated abuse without annoying CAPTCHAs
  • Debug mode — append ?debug to see generation timing metrics

Tech Stack

  • Runtime: Cloudflare Workers
  • AI Generation: Google Gemini 2.0 Flash Lite
  • Moderation: OpenAI omni-moderation
  • Storage: Cloudflare KV
  • CAPTCHA: Cloudflare Turnstile
  • Frontend: Vanilla JS + markdown-it
  • Language: TypeScript
  • Package Manager: pnpm

Getting Started

Prerequisites

  • Node.js with pnpm
  • A Cloudflare account (with KV namespace and Turnstile site configured)
  • Google AI Studio API key
  • OpenAI API key

Setup

pnpm install
pnpm start

The dev server runs at http://localhost:8787.

Environment Variables

Set these as secrets in your Cloudflare Workers environment:

  • GOOGLE_AI_STUDIO_TOKEN
  • GOOGLE_AI_GATEWAY_URL
  • OPENAI_API_KEY
  • TURNSTILE_SECRET_KEY

Deploy

pnpm deploy

Disclaimer

All articles are AI-generated fiction. Any resemblance to real events or persons is coincidental.

About

AI-generated articles on demand, powered by Gemini Flash and Cloudflare Workers

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors