# CLAUDE.md This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. ## Directives - **Zero CDN dependencies.** No external JS, CSS, fonts, images, or `cdn.*` URLs. `npm run build` fails on any CDN reference via `scripts/check-no-cdn.mjs`. - **Persian/RTL first.** All UI copy is Persian. Layouts assume `direction: rtl`; use logical CSS properties, not left/right. - **Frontend uses APIs only.** Never call the database from frontend code. All persistence goes through `/api/v1/*` at the backend. Frontend API clients may pass unversioned `/api/*` paths because `src/lib/api.js` rewrites them to `/api/v1/*`. `teknav-data.js` and `teknav-store.js` are seed/reference data — never use them as admin-panel fallbacks. - **No mock admin data.** Admin/writer/reviewer/dashboard/media views must use real backend APIs and show empty/error states when data is missing. - **Production is native Linux/systemd + nginx.** No Docker unless explicitly asked. See `DEPLOY.md`. - **Protect credentials.** `ACCOUNTS.md` is gitignored and nginx-blocked. Never move it into `public/` or `dist/`. Seed credentials are in `backend/prisma/credentials.json`. - **Port and registry are fixed.** Vite dev/preview → port `3009`; npm registry → `https://npm.devneeds.ir/`. - **Reuse shared styling.** Use `src/styles/global.css` keyframes/utilities — do not redefine animation primitives. - **Phase 15 is current.** Keep `ARCH.md`, `AGENTS.md`, `DEPLOY.md`, and `SECURITY.md` aligned when schema, SEO, trust, retention, or monetization flows change. Phase 14 Linux validation (pgvector + LMS) is still pending before full production go-live. - **Production hardening.** Run `npm run preflight:prod` before deploy; run `TEST_REQUIRE_SERVER=1 npm test` in `backend/` against a live backend to enforce endpoint contracts. ## Commands **Frontend** (repo root): ```bash npm run dev # Vite dev server → port 3009, proxies /api → localhost:3010 npm run build # Full pipeline (see Build Pipeline Order) npm run preview # Preview dist/ on port 4173 npm run preflight:prod # Static pre-deploy audit npm run seo:sitemap # Regenerate sitemap.xml, robots.txt, feed.xml npm run og:images # Generate OG images into public/images/og/ (Linux only) npm run check:seo # Audit Persian articles for indexability gaps npm run smoke:prod # Smoke-test all public endpoints ``` **Backend** (`cd backend` first): ```bash npm run dev # tsx watch → port 3010 npm run build # TypeScript compile npm run prisma:generate # Regenerate Prisma client after schema changes npm run prisma:apply # Apply schema (migrations if present, else db push) npm run seed # Seed PostgreSQL + Persian FTS npm run publish:due # Publish scheduled articles + fan out notifications npm test # Skips endpoint tests when no backend running TEST_REQUIRE_SERVER=1 npm test # Strict contract tests against a live backend ``` **Startup order:** PostgreSQL + Redis → `cd backend && npm run dev` → `npm run dev` **Schema change workflow:** edit schema → `npm run prisma:generate --prefix backend` → `npm run prisma:apply --prefix backend` → backend build. **Article data change workflow:** edit `teknav-data.js` → `npm run check:seo` → `npm run seo:sitemap` → `npm run build`. ## Build Pipeline Order ``` seo:sitemap → og:images → vite build → check-no-cdn → check-responsive → generate-article-pages → generate-web-stories → generate-comparison-pages → generate-company-pages → generate-en-page → generate-author-pages → generate-semantic-pages → compress-dist ``` All `generate-*` scripts produce static HTML that nginx serves directly — never manually edit files under `dist/`. `generate-article-pages` must run after `vite build` (needs `dist/index.html` as template) and before `compress-dist` (so `.gz`/`.br` pairs are created). Phase 15 scripts output: `dist/stories/{slug}/` (web stories), `dist/compare/{slug}/` (comparisons), `dist/directory/{slug}/` (company directory). ## SEO Invariants - **No `hreflang="en"`.** `?lang=en` is a UI preference only; canonical always points to the clean URL. - **No placeholder verification codes.** Never commit `INSERT_GOOGLE_VERIFICATION_CODE` or similar strings. - **Static article pages** under `dist/article/{slug}/index.html` are build-time generated — do not edit manually. - **Sitemap lastmod must not be future-dated.** `capDate()` in `generate-seo.mjs` enforces this. - **Organization schema:** `['Organization', 'NewsMediaOrganization']` — required for Google News. - **Article schema:** `['NewsArticle', 'TechArticle']` — required for Google Article rich results. - **Run `npm run check:seo`** after any article metadata or content change. - **Proven content formula** (article `ai-data-centric-2026` ranked #1 on Google, above Wikipedia): `
` opening, numbered `