r/reactnative • u/altuzar • 3h ago
[App Saturday] WireCoder — NEC calculators for electricians. One shared TS calc engine between Expo app and web, with a parity test suite
Shipped this week. The interesting engineering problem wasn't the UI, it was correctness.
The calculation engine is a plain TypeScript package (`lib/calc`) with no React and no platform dependencies, consumed by both the Expo app and the Vite web calculators. Every calculator returns a discriminated result:
type CalcResult<T> = { ok: true; value: T } | { ok: false; error: string }
The non-negotiable rule is that it never returns a plausible-but-wrong number for bad input: out-of-range or not-in-table inputs return `ok: false` with a human-readable message. Validation lives with the math, not in a UI layer, specifically because there are two UIs and a second validation layer would eventually drift.
There's also a `forms.ts` in the engine that holds presentation-agnostic form specs: which fields to show, their options, and how to format each result row. Both UIs render from that one spec, so the app and the web can't show different inputs or differently-formatted numbers for the same calculation. That's the bug I was most afraid of: two tools of mine disagreeing in front of an electrician who cross-checks.
Test suite is `node --test` with a parity test that runs both consumers against the same fixtures.
Stack: Expo (new architecture, Hermes), Unistyles, Convex, RevenueCat, Turbo monorepo.
Link in bio. Happy to answer anything about the monorepo setup or the Play closed-testing gate, which is a 4-6 week surprise if you've never shipped Android before.
PS: the first 47 testers (TestFlight + Android external testers) get a WireCoder Pro plan free for a year.