Skip to content

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 ​

LayerChoiceWhy
LanguageTypeScript 5, strict, ESM everywhereOne language across core, API and web
Monorepopnpm workspacespackages/core, packages/db, apps/api, apps/web, apps/docs
Domainpackages/core — pure TypeScript; only zod and decimal.jsTestable without a database or UI; shared by API and web
DatabaseBuilt-in node:sqlite (DatabaseSync), raw SQL, numbered migrationsNo native builds; repository interfaces keep it Postgres-ready
APIFastify 5 + tRPC v11 + zod, cookie sessions, scrypt passwords, TOTP via node:cryptoEnd-to-end types with no code generation
WebVite, React 18, Tailwind 3, Radix primitives, React Router 7, TanStack Query/Table, Recharts, Framer Motion, cmdk, driver.js, sonnerA keyboard-first single-page app
DocsVitePressFast static docs with Vue components for animated walkthroughs
TestsVitest (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 Centre

Binding conventions ​

  • Money is integer minor units (Cents = number). Never add money as floats; use the helpers in money.ts.
  • Quantities and prices are DecimalStrings (e.g. "12.345678") in the data model and computed with Decimal from decimal.js (named import). Cost bases and proceeds are Cents.
  • Calendar dates are ISODate strings (YYYY-MM-DD, entity-local, no time zone); timestamps are ISO-8601 UTC. Never use Date arithmetic on calendar dates — use dates.ts.
  • Ids are strings from newId() (crypto.randomUUID).
  • Schemas: every persisted or transported type has a zod schema in types.ts with an inferred type of the same name (Account / AccountSchema). API inputs are validated with zod.
  • Modules export pure functions from an index.ts barrel. No I/O in core — providers receive an injected fetch-like function. Named exports only; no any.
  • Errors are KeelError (code, message, details); never throw strings.
  • Tests are colocated *.test.ts files 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 in apps/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 ─▶ web

Imports 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 site

Next: API · Self-hosting (developers)

Not tax advice. Mintage provides general information only — it does not consider your personal circumstances. Check with a registered tax agent or licensed financial adviser before acting. Disclaimer