Skip to content

Repository files navigation

firefly

Modern blog platform. Next.js 16 + Cloudflare D1 + R2. Deployed on Railway.

Migrated from WordPress.

Documentation

See docs/ for architecture and design documents.

Development

Prerequisites

  • Bun (runtime & package manager)
  • Node.js 20+
  • Cloudflare account (for D1, R2, Workers)
  • Google OAuth credentials (for admin auth)

Setup

# 1. Clone and install
bun install
# 2. Copy environment variables
cp .env.example .env
# Edit .env with your Cloudflare and Google OAuth credentials# 3. Start dev server
bun run dev # Webpack dev server (port 7028)

Environment Variables

Copy .env.example to .env and configure:

VariableRequiredDescription
CF_ACCOUNT_IDCloudflare account ID
CF_API_TOKENCloudflare API token with D1/R2 access
CF_D1_DATABASE_IDProduction D1 database ID
WORKER_URLD1 proxy Worker URL
WORKER_SECRETWorker authentication secret
AUTH_SECRETNextAuth.js secret (32+ chars)
AUTH_URLSite URL for auth callbacks
AUTH_GOOGLE_IDGoogle OAuth client ID
AUTH_GOOGLE_SECRETGoogle OAuth client secret
AUTH_ALLOWED_EMAILSComma-separated allowed admin emails
R2_ACCESS_KEY_IDR2 S3-compatible access key
R2_SECRET_ACCESS_KEYR2 S3-compatible secret key
R2_BUCKET_NAMER2 bucket name
R2_PUBLIC_URLR2 public URL for media
R2_KEY_PREFIXOptional path prefix for R2 keys

Testing

bun run test# L1: Unit tests
bun run test:watch # L1: Watch mode
bun run test:coverage # L1: With coverage report (90% threshold)
bun run test:e2e:api # L2: API E2E tests
bun run test:e2e:browser # L3: Browser E2E tests (Playwright)cd worker && vitest run # Worker: Edge Worker unit tests

Quality System

Six-dimensional testing pyramid:

LayerTestsDescriptionTrigger
L11,277Unit + Integration (Vitest)pre-commit
L2191API E2E (real HTTP)pre-push, CI
L324Browser E2E (Playwright)CI
G1-TypeScript 7 + Biome + custom gatespre-commit
G2-Security (gitleaks, osv-scanner)pre-push, CI
Worker96Edge Worker testsCI

Coverage: L1 99%+, L2 100% routes, Worker 100%.

Git Hooks (Husky)

HookRuns
pre-commitG0 lockfile + G1 (tsc + Biome staged + custom gates) + L1 (unit tests)
pre-pushL1 (coverage) + G1 (full lint) + G2 (security)

CI/CD

GitHub Actions runs four parallel jobs on push/PR:

  • quality: L1 + G1 + G2 (from base-ci)
  • api-e2e: L2 API E2E (fully local — wrangler dev + filesystem R2)
  • browser-e2e: L3 Playwright (fully local — wrangler dev + filesystem R2)
  • worker-tests: Worker unit tests

All jobs must pass before merge.

About

🔥 Modern blog platform — Next.js 16 + Cloudflare D1 + R2, migrated from WordPress

Resources

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages