HFlow - Enterprise Payroll Platform
Multi-tenant payroll with country plugins
HFlow is a multi-tenant payroll platform where pay rules are modeled as data and each country is a plugin. We built the calculation engine, the audit trail, approvals and permissions on a TypeScript monorepo with a Fastify, tRPC and Postgres backend.
- Industry
- HR Tech / Payroll
- Year
- 2025
- Countries
- Dominican Republic
- Platforms
- Web
- Our role
- Full-stack development & architecture

The challenge
Payroll looks like arithmetic until a second country, a new tax rule or an audit shows up. Many small and mid-size companies run it on spreadsheets, and the rules end up buried in formulas nobody dares to touch.
Our client needed a payroll product that calculates correctly, can explain every number later, and lets each company have its own team, roles and approvals without seeing anyone else's data.
What we built
We built HFlow as a multi-tenant platform. Each workspace manages its employees, contracts, pay schedules and pay definitions. A payroll run evaluates a period for a batch of employees, someone with the right permission reviews it, and approved runs feed monthly reports and payment batches.
The project is a pnpm and Turborepo monorepo. The frontend is Vite with React 19 and TanStack Router; the backend is Fastify with tRPC and Drizzle on Neon Postgres, with better-auth for sessions and Stripe for subscriptions. Payroll rules are not hardcoded: they live in the data and in country plugins, with the Dominican Republic and the US built in.
Key decisions
- 01
Pay rules as a graph
A pay definition is a graph of earnings, deductions and taxes with explicit dependencies. The engine checks it is acyclic, sorts it and evaluates it in order, and the same check runs on every edit so a broken definition cannot be saved.
- 02
Country plugins
A registry maps each country code to a plugin with its components and templates, plus a default fallback. Contribution caps and progressive tax brackets are configuration read by generic calculators, not code branches.
- 03
Every run is evidence
Each evaluation stores its result with the full context it ran on (contract, period, assignments, overrides), including failures. Pay definitions are versioned with effective dates, so any past run can be explained.
- 04
One approved run per period
Approving a run rejects any other approved run for the same schedule and period inside a single database transaction, so the rule holds no matter how many people click at once.
- 05
Exact money math and scoped permissions
Calculations use decimal arithmetic instead of floating point, and each API procedure declares the permissions it needs, checked against the member's role in the active workspace.
Results
HFlow gives each company its own workspace with employees, contracts, schedules, versioned pay definitions, reviewed and approved runs, monthly reports and payment batches. Every line of a payslip can be traced back to the component that produced it and what it depended on.
Because rules are modeled as data, adding a country is a content problem instead of a refactor, and the calculation engine stays small and testable.
Screens
Stack
- React
- Vite
- tRPC
- Fastify
- PostgreSQL
- Drizzle ORM
Have a similar project?
Tell us what you are building. You talk directly with the senior developers who would build it.
Let's talk