Back to Systems

Case study // chronicle

Chronicle

A two-service publishing platform combining server-rendered public pages, email-verified accounts, and schema-guarded Gemini AI writing tools.

Problem

Publishing apps with AI features usually trust model output blindly and skip operational basics: verified accounts, transactional email, crawlable rendering, and migration-safe deploys.

Constraints

  • Free-tier hosting requires resilient cold-start handling and boot-time migrations.
  • LLM structured outputs can be malformed and must be schema-validated before reaching the editor.
  • Transactional email delivery must not block or crash core HTTP request paths.

Architecture

Next.js (Vercel) -> REST + JWT -> Express API (Render) -> PostgreSQL (Prisma) + Gemini 2.5 + Brevo Email

Data model

Relational schema modeling users, auth tokens, articles, tags, comments, notifications, and audit events with Prisma ORM on PostgreSQL.

Key decisions and trade-offs

  • Treat the LLM as an untrusted dependency with JSON mode, Zod validation, and uniform failure handling.
  • Execute Prisma migrations at server boot time before opening the port to prevent schema drift outages.
  • Handle transactional email as a non-blocking asynchronous side effect with backoff retries.

Failure modes

  • Malformed AI responses trigger a safe 503 fallback instead of breaking the editor state.
  • Failed database migrations abort startup cleanly to prevent runtime P2021/P2022 500 errors.
  • Unreachable email provider logs retry telemetry without blocking user HTTP requests.

Result

A production-grade, two-service publishing platform deployed across Vercel and Render with verified accounts, crawlable SEO, and schema-guarded AI assistance.

Lesson learned

Backend reliability and strict boundary validation matter more than raw prompt complexity when building production software.