Files
finance-app/AGENTS.md
siddharthd 5db42f086f
ci / lint-test (push) Failing after 45s
fix(orders): match the card leg by masking, not by card brand
Backfill dry-run over 130 real messages surfaced one 422: 'payments sum to 1.17
but receipt states 16.50'. The receipt is a mixed Uber payment —
Uber Cash $1.17 + Westpac ••••8032 $15.33 — and the card regex only matched
Visa|MasterCard|American Express|Amex, so an issuer-named leg was dropped
entirely. validateOrderTotals correctly refused it rather than recording $1.17
as the cost of a $16.50 order.

Anchors on the ••••NNNN masking instead, which also covers the form already
seen in the corpus ('Mastercard ••••3893 (CBA Ultimate) CHF 51.23'). Fixture
and regression test added.

Also repoints .env.test at the current postgres-personal container IP and
documents why: the container publishes no host port, so the address changes on
every recreate and the whole integration suite fails with connection errors
until it is refreshed.
2026-07-27 01:39:42 +10:00

2.9 KiB

Repository Guidelines

Project Structure & Module Organization

Application code lives in src/. Next.js App Router pages and API route handlers belong in src/app/; reusable UI components are in src/components/; database access, query functions, hooks, authentication, and domain helpers are in src/lib/. Tests are separated into src/__tests__/unit/ and src/__tests__/integration/. PostgreSQL schema and numbered SQL migrations live under prisma/, static assets under public/, operational scripts under scripts/, and design notes under docs/.

Keep data flow consistent: API routes call query functions in src/lib/queries.ts, which use queryRaw() from src/lib/db.ts; client components access APIs through TanStack Query hooks in src/lib/hooks.ts.

Build, Test, and Development Commands

  • npm ci installs the locked dependency set (Node 22 is used in CI).
  • npm run dev starts the local Next.js development server.
  • npm run build creates a production build; npm start serves it.
  • npm run lint runs the Next.js ESLint configuration. Existing lint debt makes CI lint advisory, but new code should pass.
  • npm test runs fast unit tests.
  • npm run test:setup prepares the PostgreSQL test database using .env.test.
  • npm run test:integration runs database-backed tests.
  • npm run test:all runs both test suites.

Coding Style & Naming Conventions

Use strict TypeScript, two-space indentation, semicolons, and double quotes, matching existing files. Name React components and types in PascalCase, functions and variables in camelCase, and files/routes in kebab-case. Use the @/ alias for imports from src/. Preserve owner scoping and prefer transaction overrides with COALESCE in financial queries. Every API route must authenticate before accessing data.

Testing Guidelines

Vitest is the test framework. Name tests *.test.ts and place pure logic tests under unit/; put PostgreSQL-dependent behavior under integration/. Add regression coverage for query, rule, reconciliation, and category changes. No numeric coverage threshold is configured; focus on meaningful edge cases and run npm run test:all before submitting database-related changes.

Database, Security & Configuration

Add schema changes as the next numbered prisma/migrations/NNNN_description/migration.sql. Never commit .env, .env.test, raw statements in dump/, or other financial data. Consult CLAUDE.md and relevant docs/ notes before changing splits, settlements, loans, reconciliation, or statement accounting.

Commits & Pull Requests

History follows concise Conventional Commit-style subjects such as feat(rules): preview rule changes, fix(trips): ..., and docs: .... Keep commits focused. Pull requests should explain behavior and data-model impact, link related issues, list validation commands, and include screenshots for UI changes. Ensure unit tests and the production build pass; call out any known lint warnings or migration steps.