Files
anwar-pi-website/web
AHMED 0161924088 Free early-access launch: LAUNCH_MODE policy, CRO, pipeline hardening, AI-SEO, ops
- launch.ts policy: LAUNCH_MODE=free_early_access default; effective access =
  published && (free || early); intended tier (access) never rewritten
- Billing off server-side: /api/subscribe 503 honest copy; subscribe CTAs
  render disabled 'قريباً' from first paint; /subscription early-access panel
  + /api/notify (LaunchNotifications) with honest 503 when mail transport off
- Signup trust: verification email at signup (Users afterChange), no
  confirm-password, 429 message fidelity, typo suggestion, live password hint
- Agent pipeline: pickFields strips access/readingMinutes, sourceId dedup,
  secret-scan 422 (pattern names only), string-content rejected (was silently
  replaced), publish stays explicit opt-in
- lexical.ts: root unwrap fix — lexicalToText/countLexicalWords returned 0
  for real serialized trees (secret scan + readingMinutes were inert)
- llms-full.txt: fetchIndexDocs(true) — bodies were never selected
- Content honesty: contentType/authorName/sourceId fields + migration,
  readingMinutes computed at write (160 wpm) + backfill script, byline,
  'حُدّث' freshness
- SEO/AI-SEO: metadata rewrite (published-only, og:image 1200x630), Article +
  BreadcrumbList + FAQPage + Organization JSON-LD, isAccessibleForFree honest,
  table renderer, robots AI-crawler policy (10 named bots), llms.txt +
  llms-full.txt, /topics/* hubs + sitemap, noindex auth pages, www 301
- Ops: backup-db.sh (restore rehearsed on VPS), docs copies (launch
  readiness + marketing audit + owner-inputs for L-03), GLOSSARY.md entries

Verified: tsc --noEmit 0, npm run build 0, local smoke (ghost VIP read,
subscribe/notify/agent APIs, signup token, 429 on 6th, llms/topics/sitemap,
og:image/JSON-LD)
2026-10-10 18:03:45 +03:00
..

أنور بي آي — web

Next.js 15 + Payload 3 app: Arabic RTL paywalled content site.

Stack

  • Next.js 15.4 (App Router, standalone output) + React 19
  • Payload 3.90 (Postgres adapter, Lexical richText)
  • Stripe subscriptions (35 SAR/month, test mode)

Collections

  • users — auth; role: free | vip | admin, stripeCustomerId
  • posts — title, slug, dek, access (free|vip), teaser, content (lexical), category, cover, readingMinutes, publishedAt, status (draft|published)
  • media — image uploads

Access control: public REST reads only status=published; VIP content is withheld from non-VIP (field-level read rule + paywall page never selects it for them).

Env vars

Var Purpose
DATABASE_URI Postgres connection string
PAYLOAD_SECRET Payload encryption/ signing secret
AGENT_API_KEY Agent API auth (x-agent-key header)
NEXT_PUBLIC_SITE_URL Public URL (baked at build)
STRIPE_SECRET_KEY / STRIPE_PUBLISHABLE_KEY / STRIPE_PRICE_ID / STRIPE_WEBHOOK_SECRET Optional — unset = "pending" mode

Agent API

# create draft (always draft; publish via /admin only)
curl -X POST http://localhost:3000/api/agent/posts \
  -H "x-agent-key: $AGENT_API_KEY" -H 'Content-Type: application/json' \
  -d '{"title":"...","slug":"my-post","dek":"...","category":"وكلاء","access":"vip","teaser":"...","readingMinutes":8,"content":{"root":{"type":"root","children":[],"format":"","indent":0,"version":1}}}'

# update (cannot change status)
curl -X PUT http://localhost:3000/api/agent/posts/my-post -H "x-agent-key: $AGENT_API_KEY" ...

Omitting cover assigns the per-category default cover.

Seed

npm run covers   # regenerate public/covers/*.jpg
npx payload migrate
npx payload run src/seed.ts   # idempotent (skips existing slugs)

Seeds: 12 posts (6 free + 6 VIP, 6 categories), admin admin@anwarpi.ai / AnwarPi-Admin-2026!, test users free@test.anwarpi.ai / Free1234!, vip@test.anwarpi.ai / Vip1234!.

Docker deploy

cp .env.production.example .env.production  # fill secrets
docker compose --env-file .env.production up -d --build
docker compose exec web npx payload run src/seed.ts   # first time

Stripe webhook (testing on LAN)

stripe listen --forward-to localhost:3000/api/stripe/webhook

On production (Railway), point the webhook endpoint at the public URL.