TaxPilot

Search the docs

Search the Help centre, Developer docs and Legal centre.

Open TaxPilot

Architecture

See how the web app, the tax engine and the UI kit fit together, where state lives, and what the prototype leaves out.

Updated November 22, 2026

TaxPilot is a pnpm and Turborepo monorepo with one app and three packages. The tax engine is real and heavily tested. Everything around it (sign-in, storage, filing) is a prototype that runs in the browser with no server.

The app writes through act() in lib/store.ts, which runs a pure repository function from packages/t2 and saves the result to localStorage.

The workspace

packages/t2 exports its source directly ("./*": "./src/*.ts" in its package.json), and next.config.ts lists it in transpilePackages. There is no build step for the engine: the app imports @workspace/t2/repo, @workspace/t2/deadlines and so on straight from TypeScript.

The engine and the repository

packages/t2/src has three layers that matter day to day:

  • Forms and evaluation. Each CRA form is a FormDef (src/engine/defs.ts). buildRegistry turns a list of forms into a dependency graph and evaluate computes every field in order. See Tax engine and Forms.
  • Rules releases. A Release (src/repo.ts) bundles forms, a parameter file (src/rules/params/<id>.json), CRA data rules and filing specifications for the tax years it covers. RELEASES holds 2020.1 to 2026.1. See Rules releases.
  • The repository. src/repo.ts is a tenant-scoped repository over an in-memory State. Every read and write takes a Session and is checked against the caller's organization and role. Writes are pure functions that return a new State. See State, actions and permissions.

Money is bigint cents with exact fractions (src/money.ts). test/no-float.test.ts blocks new floating-point arithmetic in forms, e-file and rules code.

The web app

The app is a client-heavy Next 16 app. lib/store.ts keeps one snapshot of State and Session in memory, exposes it through useStore() (a useSyncExternalStore hook), and saves it to localStorage. Screens read through useSession() in lib/use-return.ts, which adds the current user, firm, role and a can(action) helper, and evaluate returns with evaluateCached.

Screens are built from the house design system in components/app/ds (PageHeader, PageContainer, EntityTable, StatTile, …) on top of @workspace/ui. The public Help centre, Developer docs and Legal pages are typed content in lib/docs drawn by components/docs.

What happens on a change

  1. A screen calls act(fn, success?).fn receives the current State and Session and calls a repository function such as setInput or submitForReview.
  2. The repository checks access and rules.It throws AccessError for a role that lacks the permission and LockedError for an approved, filed or cancelled return. It appends an AuditEntry for every change.
  3. The store saves and notifies.act refuses the write if another tab saved first, saves to localStorage, and re-renders subscribers. Any thrown error becomes a toast, and the state is unchanged.
  4. Screens re-evaluate.Because the state is immutable, evaluateCached evaluates each corporation and return pair once, however many components read it.

Prototype limits

  • The audit trail lives in the same localStorage blob as the data, so it is not evidence until it moves to an append-only server log.
  • docs/schema.sql is the PostgreSQL schema the records move to in milestone M7 (backend, real authentication, row-level tenant isolation). Nothing reads it yet.
  • There is no Revenu Québec filing adapter. The CO-17 is calculated and printed only.
  • The 2026 CRA data rules were extracted from a commercial product, not downloaded from CRA.

Deeper reading

These markdown files are in the repository, not on this site: docs/build-plan.md (architecture, decisions, milestones), docs/data-model.md (entities, value layers, provenance), docs/rules-engine.md (releases, parameters, CRA rules, audit) and docs/developer-guide.md (the short version of this section).