System Architecture
Architecture & Design Principles
The engineering policies governing Trivio's modular monorepo and financial integrity.
1. Decoupled Monorepo Design
Trivio maintains a strict separation of concerns across its workspaces:
- Framework Independence: The calculation engines are strictly decoupled from web frameworks (NestJS, Next.js, Express) and persistence layers (Prisma, PostgreSQL).
- Zero Runtime Dependencies in Core:
@trivio.ink/corecontains exactly zero dependencies in its production manifest. - Layered Ingestion: The React and Node packages import from Core; Core never depends on upper-level packages.
2. Zero-Float Arithmetic Pipeline
Floating-point numbers (IEEE-754) introduce rounding drift in recurring fee calculations. Trivio enforces integer minor units:
// Correct Trivio representation:
const grossMinor = 1000000n; // Exactly $10,000.00 in minor units
const percentageFeeMinor = (grossMinor * 250n) / 10000n; // 25000n ($250.00)
3. Historical Reproducibility & Ledgers
Payment disputes and tax audits often occur months or years after transaction clearance. Trivio fee calculations produce snapshot records capturing the exact rule version, effective date, and applied rate, guaranteeing immutable historical reproducibility.
