app/andpages/contain Next.js routes;src/holds most shared logic and UI modules.public/hosts static assets served by Next.js;assets/stores design/media artifacts.tests/includes integration fixtures and outputs; unit tests live alongside code (e.g.,src/**/*.spec.ts).docs/contains project documentation;scripts/holds helper scripts.worker/andtypes/provide background/runtime helpers and shared typings.
pnpm installinstalls dependencies (Node ^22, pnpm ^10.26.1).pnpm devruns the Next.js dev server.pnpm buildcreates the production build;pnpm startserves it.pnpm lintruns ESLint (Next.js + TypeScript rules).pnpm testruns Vitest in non-watch mode.pnpm i18n:extractrefreshes Lingui catalogs inlocales/*/messages.po.pnpm i18n:extract:cleanrefreshes catalogs and removes obsolete#~entries.pnpm i18n:compileregenerates the checked-in compiled catalogs inlocales/*/messages.js.pnpm i18n:statusreports active missing translations and obsolete entries per locale.pnpm i18n:refreshruns the repo’s standard translation maintenance flow: clean extract, then compile.
- TypeScript + React; 2-space indentation is the dominant style.
- Use ESLint for quality gates; unused imports are errors (
eslint.config.cjs). - Test files follow
*.spec.tsnaming (seesrc/lib/civitai.spec.ts). - Prettier is available as a dev dependency; run manually when needed (
pnpm exec prettier).
- Unit tests use Vitest with Testing Library; run via
pnpm test. - Place tests near the code they cover (
src/.../*.spec.ts). - No explicit coverage threshold is enforced; keep new functionality covered.
- Commit history favors Conventional Commits, often with scopes:
feat(pkg): ...,fix(masonic): .... - PRs should include a clear description, linked issues if applicable, and screenshots for UI changes.
- Before opening a PR, run
pnpm lintandpnpm test.
- Use
.env.localfor local secrets. Common variables:BANANA_API_KEY,BANANA_MODEL_KEY,STABLE_DIFFUSION_HOME. NEXT_PUBLIC_variables are baked at build time (set beforepnpm build).REQUIRE_REGISTRATIONandNEXT_PUBLIC_REQUIRE_REGISTRATIONtoggle auth flow behavior.
- Next.js locale routing is configured in
next.config.ts; the app currently servesen-US,he-IL,ja-JP, andfa-IR. - Locale metadata such as language labels and text direction (
ltr/rtl) lives insrc/lib/locales.ts. - Lingui is configured in
lingui.config.jsand extracts messages frompages/andsrc/. - User-facing strings are typically wrapped with
@lingui/macrohelpers such ast,Trans, andPlural. pages/_app.tsxactivates the current locale, andsrc/lib/i18n.tsstatically imports the compiledlocales/*/messages.jscatalogs.- After changing translatable copy, run
pnpm i18n:extractorpnpm i18n:extract:clean, update non-sourcemsgstrentries inlocales/*/messages.po, then runpnpm i18n:compile. scripts/i18n/status.mjsandscripts/i18n/refresh.mjsare the reusable maintenance helpers behindpnpm i18n:statusandpnpm i18n:refresh.