Files
anwar-pi-website/docs/adr/0001-comments-route-not-at-api-comments.md
AHMED 165efc3269 Docs: new README (Arabic flows, screenshots, architecture) + AGENT.md for AI agents
- README rewritten for the real Next.js + Payload + Postgres stack
  (old one described the dead static prototype)
- Logo + 4 live screenshots (home, articles, post, subscription)
- Arabic flow explanations with mermaid diagrams: visitor journey,
  content pipeline, request path
- Architecture table, quick start, API reference, security summary,
  deploy commands
- AGENT.md: orientation for future AI agents (data model, trust rules,
  rate limits, routes, env, deploy, house rules)
- GLOSSARY.md and docs/adr committed (linked from README)
2026-10-09 17:23:14 +03:00

1.1 KiB

ADR 0001 — Comments endpoint lives at /api/posts/[slug]/comments, not /api/comments

Date: 2026-10-03

Status

Accepted

Context

The comments API needs a route. The conventional-looking path /api/comments collides with Payload: it auto-mounts REST CRUD for every collection at /api/<slug>. A comments collection therefore already serves /api/comments for the admin panel, and moderation (approve/reject) runs through that panel. An app-router route at the same path would shadow and break the panel's CRUD.

Decision

Comments are created at POST /api/posts/[slug]/comments (src/app/api/posts/[slug]/comments/route.ts), matching the existing /api/posts/[slug]/like pattern. Admin moderation keeps using Payload's own REST/admin panel.

Tests for a real ADR

  • Hard to reverse: the endpoint is a public contract consumed by the client form; moving it breaks every deployed client.
  • Surprising: the collision with Payload's auto-mounted REST is non-obvious — a developer would naturally reach for /api/comments.
  • Real trade-off: a shorter conventional path vs. a working admin moderation panel.