Newsletter Infrastructure

The system behind draft, review, sync, and publish.

The newsletter workflow combines Beehiiv data, local static pages, Firestore source queues, OpenAI-generated drafts, and review-before-publish tooling.

The Problem: publishing should not depend on memory and manual copy-paste.

Beehiiv archive

`sync:beehiiv` writes newsletter content to `assets/beehiiv-posts.json`, with a public-site fallback if the API path fails.

Draft queue

The draft generator reads queued `newsletter_sources` documents from Firestore and stores reviewable drafts.

Publishing gate

The Firebase function creates drafts for review; it does not publish to Beehiiv automatically.

The Current Build

Local scripts

Scripts include `sync:beehiiv`, `generate:newsletter`, and `publish:newsletter` for manual or automated newsletter operations.

Firebase function

`generateScheduledNewsletterDraft` uses scheduled execution, OpenAI, and Firestore collections for source and draft state.

Static pages

The site keeps on-site newsletter pages while also linking to Beehiiv for the hosted publication.

Development Timeline

Issue archive

Publish the first newsletter issue on-site and link it from the site.

Beehiiv sync

Sync Beehiiv publication metadata into local JSON for the site.

Draft worker

Generate reviewable drafts from queued Firestore source documents.

Publish path

Use the Beehiiv publish script only after review, keeping the workflow gated.