Architecture
See how the web app, the tax engine and the UI kit fit together, where state lives, and what the prototype leaves out.
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.
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).buildRegistryturns a list of forms into a dependency graph andevaluatecomputes 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.RELEASESholds 2020.1 to 2026.1. See Rules releases. - The repository.
src/repo.tsis a tenant-scoped repository over an in-memoryState. Every read and write takes aSessionand is checked against the caller's organization and role. Writes are pure functions that return a newState. 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
- A screen calls
act(fn, success?).fnreceives the currentStateandSessionand calls a repository function such assetInputorsubmitForReview. - The repository checks access and rules.It throws
AccessErrorfor a role that lacks the permission andLockedErrorfor an approved, filed or cancelled return. It appends anAuditEntryfor every change. - The store saves and notifies.
actrefuses 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. - Screens re-evaluate.Because the state is immutable,
evaluateCachedevaluates each corporation and return pair once, however many components read it.
Prototype limits
All data lives in the browser's localStorage. Sign-in is a demo account picker. Nothing is CRA-, Alberta TRA- or Revenu Québec-certified, every rules release is a draft, and the .COR and AT1 files are previews that are never transmitted. Filing happens outside TaxPilot and is then recorded.
- 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.sqlis 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).
Related
- Local setupInstall the workspace, set the rules channel, run the app with demo data, and know which commands exist.
- The tax engineUnderstand how a return is evaluated: the registry, the dependency graph, value types, parameters and diagnostics.
- State, actions and permissionsRead and write firm data through the repository and store, check permissions with can(), and keep the audit trail and undo working.