AI Editorial Tools for a Publishing Platform
AI editorial tooling inside a news publishing platform: the model drafts the excerpt, SEO title and meta description, the editor approves or rewrites them, and the generation endpoint is guarded so it cannot become someone else’s API bill.
- Built for
- SME Enterprise News
- Industry
- Publishing — UK small-business news
- Status
- live2025
Built with Next.js, TypeScript, Prisma, PostgreSQL, Google Gemini, Upstash Redis, Sentry, Vercel
In this case study
The problem
Every article needs more than its body. It needs an excerpt that earns the click, a title shaped for search without becoming clickbait, and a meta description that fits inside a character budget. The work is repetitive, constrained, and the first thing to be rushed when there are articles to get out.
What was needed
Remove the repetitive drafting of article metadata without moving editorial judgement away from the editor — and without exposing a paid generation endpoint to the internet.
What I built
Three generation actions inside the existing author workflow, each attached to the field it fills. The editor writes the article, presses Generate with AI on a field, and the returned text lands in that field as an editable value.
Nothing is saved or published by generation. Posts default to draft and reach published only when a person does it. The model drafts; the editor decides.
What it does
Per-field generation
Separate actions for the excerpt, the SEO title and the meta description, each scoped to one field.
Editable output
Generated text arrives in the form field, where the editor rewrites or replaces it before saving.
Guarded endpoint
Authentication, sliding-window rate limiting and CSRF validation in front of every generation call.
Mock provider
A no-network provider returns plausible output, so the interface and its error paths can be built without API spend.
Where AI enters the workflow
Nothing reaches a reader automatically
The hard parts
A generation endpoint is a spending endpoint
Any route that calls a paid model can be made expensive by someone who is not you. This one sits behind authentication, a sliding-window rate limit in Upstash Redis — ten requests per ten seconds, and five per fifteen minutes on authentication — and CSRF validation, with violations reported to Sentry rather than silently absorbed. The cost of getting this wrong is an invoice, not a bug report.
Prompt targets are not guarantees
Each task asks for a length range: roughly 150 to 200 characters for an excerpt, 50 to 60 for an SEO title. A model treats that as guidance, not a contract, so the schema validates independently — the SEO title is rejected above 60 characters and the meta description above 160. The prompt shapes the output; the validation decides what is allowed to be saved.
What an abstraction absorbs, and what it does not
The model provider sits behind a configuration module rather than being called from the route, with the provider selectable by environment. When one provider was dropped, that abstraction contained the call site — but not the migration: the dependency came out of the manifest and the old route was rewritten to return a gone response pointing at the working endpoint. An abstraction limits how far a change spreads; it does not make the change free.
Keeping the model on the field, not on the article
Each task is scoped to a single field and works from content the editor has already written. The model is never asked to produce the article, and never decides that anything is finished. Generated text reaches a reader only after a person has read it, kept it and published it.
Architecture
The editor writes the article, then presses Generate on a field. The request passes authentication, a sliding-window rate limit and CSRF validation before it reaches Gemini with a task-specific prompt; the response is returned into the form field, where editing, saving as a draft and publishing are three separate human actions. Per-field generation over one-shot: more prompts to maintain, but a poor result costs one field rather than an article. Generation writes to the form, never to the database.
Where it stands
Live. AI-assisted generation is active inside the editorial workflow.
Three generation actions sit on the fields they fill — the excerpt, the SEO title and the meta description — so a poor result costs one field rather than an article. Generated text arrives in an editable form field and is never written to the database by the generation step itself. Posts default to draft, and reaching a reader is a separate action a person takes. The endpoint that spends money is reachable only behind authentication, a sliding-window rate limit and CSRF validation.