Appearance
Contributing
Thanks for helping build Mintage. This page gets you from a fresh clone to a passing test run, and covers the conventions every change must follow.
Set up
bash
corepack enable # pnpm 10
pnpm install
pnpm -r build # core → db → api → web → docs
pnpm -r test # Vitest everywhere
pnpm dev # API :4000 + web :5173| Command | What it does |
|---|---|
pnpm dev | API and web dev servers together, with the web app proxying /api |
pnpm -r test | All unit and integration tests |
pnpm typecheck | Type-check every package |
pnpm e2e | Playwright end-to-end tests against the dev servers |
pnpm seed | Load demo data into your local database |
pnpm docs:dev | This Help Centre at http://localhost:5174 |
Node 22.13 or later is required (Mintage uses node:sqlite).
Where things live
Each package owns one layer — see Architecture. Domain logic goes in packages/core as pure functions with no I/O; the API wires it to repositories; the web app calls the API.
packages/core/src/types.ts is the canonical domain model. If you need a new field, change the zod schema there first; the inferred type, the API input validation and the database mapping follow. See Data model.
Conventions
These are binding — review will ask for them.
- Money is integer cents. Use
Centsand the helpers inmoney.ts. Never add or multiply money as floating-point numbers. - Units and prices are
DecimalString. Compute withDecimal(import { Decimal } from 'decimal.js'— the named import) and round once at the end. - Calendar dates are
ISODatestrings (YYYY-MM-DD). Usedates.ts; never doDatearithmetic on calendar dates (time zones and DST will bite). - Validate at every boundary with zod. Every persisted or transported type has a schema with the same name plus
Schema. - Throw
KeelErrorwith acode,messageanddetails— never a string. - No
any. Useunknownand narrow. Exhaustiveswitchstatements end withassertNever. - Named exports only,
readonlywhere sensible, 2-space indentation, semicolons, single quotes, 110 columns. - No new dependencies without discussion — prefer the standard library (
node:crypto,node:sqlite,Intl). - Accessibility: WCAG 2.2 AA, visible focus, 44 px targets, everything reachable by keyboard,
prefers-reduced-motionrespected.
Tests
- Colocate tests as
*.test.tsnext to the code. - Money and tax code needs hand-computed fixtures. Cover the edge cases the spec calls out: the CGT 12-month boundary, discount by entity type, loss ordering, splits, a return of capital above cost base, FX transfers, recurring dates such as the 31st in February and fortnightly across year end, and the reconciliation difference finder.
- Bug fixes come with a test that fails before the fix.
Adding a bank or broker preset
Presets live in packages/core/src/importers.
- Add a sample export (with personal details removed) to
samples/. - Add the preset: its name (e.g.
'ubank'), the import kind (bank_transactionsorbroker_trades), header patterns used for detection, and aColumnMapping(fields, date format, amount sign convention, buy/sell values). - Make header matching tolerant — trim, ignore case and punctuation, accept known variants (
Units/Quantity). - Add a test that parses the sample and checks a few rows exactly, including signs, dates and fees.
- Document it: add the export steps to Bank files or the relevant broker page.
Adding a help article
Every screen in the web app registers a helpKey, and its contextual help lives in apps/web/src/help/<helpKey>.md.
- Create the file with frontmatter
title,key(must equal the file name) anddocsUrl(a docs path without a leading slash, such asguide/transactions). - Use the standard sections: What this screen is for, How to, Tips, Related, and Glossary where finance or tax terms appear.
- In Related, link other help panels as
help:<key>and docs pages asdocs:<path>. - Add the key to
HELP_KEYSinapps/web/src/help/index.ts.
Working on these docs
The Help Centre is a VitePress site in apps/docs.
bash
pnpm docs:dev # live preview
cd apps/docs && npx vitepress build # must pass — dead links fail the build- Write in plain, warm, second-person Australian English.
- Use the global components:
WorkflowAnimation(animated walkthroughs; data in.vitepress/theme/workflows/*.ts),Screenshot,ShortcutandCallout(tip,warning,tax). - Every tax statement carries "general information, not tax advice" — a
taxcallout adds it for you. - Screenshots go in
apps/docs/public/screens/<name>.png; until one exists,Screenshotshows a placeholder.
Pull requests
- Keep changes focused; one feature or fix per PR.
pnpm -r build && pnpm -r testmust pass.- Describe what changed and why, and how you tested it.