Appearance
Architecture
Mintage is a TypeScript monorepo: a pure domain core shared by a Fastify/tRPC API and a React web app, with SQLite for storage. This page summarises docs/ARCHITECTURE.md in the repository, which is the binding reference.
Stack
| Layer | Choice | Why |
|---|---|---|
| Language | TypeScript 5, strict, ESM everywhere | One language across core, API and web |
| Monorepo | pnpm workspaces | packages/core, packages/db, apps/api, apps/web, apps/docs |
| Domain | packages/core — pure TypeScript; only zod and decimal.js | Testable without a database or UI; shared by API and web |
| Database | Built-in node:sqlite (DatabaseSync), raw SQL, numbered migrations | No native builds; repository interfaces keep it Postgres-ready |
| API | Fastify 5 + tRPC v11 + zod, cookie sessions, scrypt passwords, TOTP via node:crypto | End-to-end types with no code generation |
| Web | Vite, React 18, Tailwind 3, Radix primitives, React Router 7, TanStack Query/Table, Recharts, Framer Motion, cmdk, driver.js, sonner | A keyboard-first single-page app |
| Docs | VitePress | Fast static docs with Vue components for animated walkthroughs |
| Tests | Vitest (unit and integration), Playwright (end-to-end and recordings) |
Repository layout
text
money-manager/
docs/ SPEC.md, ARCHITECTURE.md, API.md, PLAN.md
samples/ sample import files (nabtrade, IRESS, bank CSVs, OFX, QIF, events)
packages/core/src/
money.ts dates.ts ids.ts locale.ts errors.ts types.ts index.ts shared contract
ledger/ balances, transfers, splits, rules, payee normalisation, recurring, reconciliation, fingerprints
budgets/ periods, actuals, pacing, safe-to-spend, rollover, envelopes, needs/wants
forecast/ cashflow, scenarios, goal projection, loans, debt snowball/avalanche, super
reports/ net worth, income/expense, category, GST/BAS, VAT, tax-deductible, ageing
insights/ anomalies, subscriptions, streaks, achievements, nudges
investments/ parcels, trade allocation, corporate actions, dividends/AMIT, valuation, watchlists
tax/ TaxJurisdiction, AU CGT engine, discount & loss ordering, strategies, what-if, 2027 regime
performance/ TWR (daily chain-linked, Modified Dietz), XIRR, benchmark replication, allocation
fx/ rate table, conversion, cross rates, realised FX
importers/ CSV, OFX/QFX, QIF, CAMT.053, mapping engine, bank & broker presets, prices, events, dividends
feeds/ PriceProvider, FxProvider, FeedProvider interfaces and implementations
packages/db/ SQLite open/migrate, schema, typed repositories, seed/demo data
apps/api/ Fastify server, tRPC routers, auth, uploads, jobs, backup/restore
apps/web/ React app: design system, shell, routes per module, help panel (src/help/*.md)
apps/docs/ this Help CentreBinding conventions
- Money is integer minor units (
Cents = number). Never add money as floats; use the helpers inmoney.ts. - Quantities and prices are
DecimalStrings (e.g."12.345678") in the data model and computed withDecimalfromdecimal.js(named import). Cost bases and proceeds areCents. - Calendar dates are
ISODatestrings (YYYY-MM-DD, entity-local, no time zone); timestamps are ISO-8601 UTC. Never useDatearithmetic on calendar dates — usedates.ts. - Ids are strings from
newId()(crypto.randomUUID). - Schemas: every persisted or transported type has a zod schema in
types.tswith an inferred type of the same name (Account/AccountSchema). API inputs are validated with zod. - Modules export pure functions from an
index.tsbarrel. No I/O in core — providers receive an injectedfetch-like function. Named exports only; noany. - Errors are
KeelError(code,message,details); never throw strings. - Tests are colocated
*.test.tsfiles and must cover the edge cases called out in the spec (CGT 12-month boundary, discount by entity, loss ordering, return of capital above cost base, FX transfers, recurring dates such as the 31st in February). - Help text: every web route registers a
helpKey, and its article lives inapps/web/src/help/<helpKey>.md.
More detail: Contributing and Data model.
Data flow
text
file / clipboard ─▶ importers (parse → map → validate → fingerprint) ─▶ ImportBatch preview
─▶ repositories ─▶ ledger / investments recompute ─▶ tRPC ─▶ web
price / FX providers ─▶ feeds (fetch injected) ─▶ repositories.prices
─▶ investments valuation ─▶ performance ─▶ webImports are always two-phase: a preview creates an ImportBatch with parsed rows, validation errors and duplicate flags; commit writes the rows; revert removes everything the batch created.
Commands
bash
pnpm install
pnpm -r build # core → db → api → web → docs
pnpm -r test # vitest everywhere
pnpm dev # API on http://localhost:4000 + web on http://localhost:5173
pnpm e2e # Playwright against the dev servers
pnpm docs:dev # this siteNext: API · Self-hosting (developers)