← Blog
By Raman Halder··Updated ·8 min read

Building a Trade Calculator App in React Native

How we built FieldDojo — 65 code-cited calculators for electrical, HVAC, plumbing, and construction — with React Native, Expo, and an offline-first SQLite stack.


Key takeaways: Keep calculation logic in pure functions, completely separate from UI — it makes formulas testable, code references trivial, and redesigns cheap. One shared numeric-input hook across 65 calculators beats 65 ad-hoc input handlers. Physical-device QA is non-negotiable for keyboard-heavy apps.

The Problem

Most trade calculator apps own one trade. Wire sizing. Or duct sizing. Or pipe sizing. Never all four. A journeyman electrician who also runs HVAC on small jobs needs three separate apps, and still pulls out a code book to verify results.

We wanted: all four trades, all code-referenced (NEC, ASHRAE, UPC, IRC), free. The full product story is in the FieldDojo case study; this post is the engineering walkthrough.

Tech Stack

  • React Native 0.86 with Expo SDK 57
  • Expo Router with NativeTabs for file-based, per-trade navigation
  • TypeScript throughout
  • Uniwind + Tailwind v4 for styling
  • op-sqlite + Drizzle ORM for local calculation history
  • MMKV for user preferences (unit system, default trade)
  • Hono + Drizzle + Postgres backend with Better-Auth sessions
  • Orval generates the typed React Query client from the backend's OpenAPI spec
  • EAS Build for iOS and Android production builds

Architecture: Separating Calculation Logic from UI

The most important decision we made early: keep calculation logic completely separate from React components.

Each calculator is a pure function. The wire sizing calculator takes current, length, voltage, material, and conduit type as inputs, looks up ampacity from the NEC 310.15 table, calculates voltage drop, and returns the recommended gauge along with the NEC reference. Simplified, the shape looks like this:

function calculateWireSize(input: WireSizeInput): WireSizeResult {
  const ampacity = lookupAmpacity(input.current, input.material, input.conduitType); // NEC 310.15
  const voltageDrop = (2 * K[input.material] * input.lengthFt * input.current) / circularMils(ampacity.gauge);

  return {
    gauge: ampacity.gauge,
    voltageDropPercent: (voltageDrop / input.voltage) * 100,
    formula: "VD = (2 x K x L x I) / CM",
    codeReference: {
      standard: "NEC",
      section: "310.15",
      description: "Ampacities of insulated conductors",
      year: 2023,
    },
  };
}

No React imports, no state, no side effects. This pattern meant:

  1. We could test calculation logic independently of the UI
  2. Showing the formula and code reference was trivial — it came from the function, not the component
  3. Swapping UI without touching logic was easy

The useNumericField Hook

Numeric input on mobile is notoriously painful. We wrote a useNumericField hook that handles:

  • Decimal point edge cases (typing "0." shouldn't immediately evaluate)
  • Preventing leading zeros
  • Allowing empty state during input without triggering calculation
  • Immediate recalculation on every valid change

This single hook is used across all 65 calculators. Consistent behavior everywhere. When QA found a keyboard edge case, the fix landed once and every calculator inherited it — that's the payoff of resisting per-screen input logic.

Navigation: Expo Router + NativeTabs

We used Expo Router's file-based routing with a tab layout. Each trade (electrical, HVAC, plumbing, construction) gets its own tab with nested routes for individual calculators.

NativeTabs gave us native tab bar behavior on both iOS and Android — proper swipe gestures, correct safe area handling, platform-appropriate animations.

Code References: The Differentiator

Every calculation in FieldDojo shows the code standard it's based on. This was non-trivial to implement well.

Our approach: each calculation function returns a codeReference object containing the standard (NEC, ASHRAE, UPC, or IRC), section number, description, and year. The UI renders this consistently across all calculators.

The result is a calculation that says "per NEC 310.15" — something a tradesperson can verify and cite to an inspector. It's also the reason the pure-function architecture matters: the citation lives next to the math it justifies, not in a UI string someone forgets to update.

A Concrete Volume result card in FieldDojo: 5.33 cu yd, the order spec, and IRC Table R402.2 and ACI 332 reference chips
A Concrete Volume result card in FieldDojo: 5.33 cu yd, the order spec, and IRC Table R402.2 and ACI 332 reference chips

History and State Persistence

Calculation history is stored locally in SQLite via op-sqlite, with Drizzle ORM giving us a typed schema and migrations. We store the full calculation parameters and result, so history items can be restored and re-calculated with different inputs. A one-time startup migration moves legacy MMKV history into SQLite on existing installs. Signing in and subscribing to Pro mirrors that history to the FieldDojo API — cloud sync is layered on top of the same offline-first storage, never a replacement for it.

Everything works fully offline — a job site with no signal is the primary environment, not an edge case. That constraint drove the offline-first architecture we use for most mobile builds.

A FieldDojo project page: 11 saved calculations across 4 trades, with the walkthrough card for the same job above them
A FieldDojo project page: 11 saved calculations across 4 trades, with the walkthrough card for the same job above them

EAS Build + App Store Submission

We used EAS Build for both development and production builds. The keyboard edge case QA caught in useNumericField only reproduced on a physical device — the simulator never showed it. We don't submit keyboard-heavy apps without a device pass anymore.

Then It Grew a Walkthrough

Version 1.0.4, out in October 2026, added the part that changed what the app is. You walk a room with the phone, the app stitches the frames into a 360° panorama on-device, and you drop numbered hotspots on the walls for notes, linked rooms and the calculations that belong there. Every room gets a pin on the floor plan. A share link opens the walk in a browser, so the client never installs anything. It is part of Pro.

Architecturally it was the pure-function split paying off again. Rooms, hotspots and pins belong to the same local-first project as the calculation history, so sync, export and the PDF report work on one object instead of two. The stitching is our own Expo module around OpenCV; that build has its own post, including the part where our first packaging choice fell over inside this app.

The FieldDojo walkthrough viewer: a 360° kitchen panorama with hotspots 1 and 2 on the wall and the Hotspots in Kitchen panel below
The FieldDojo walkthrough viewer: a 360° kitchen panorama with hotspots 1 and 2 on the wall and the Hotspots in Kitchen panel below

And Then Drawings

Version 1.5, in November 2026, took the count from 57 calculators to 65 and put a drawing on every result. For 25 calculators the drawing is a 3D model built from the same numbers as the result card; that build has its own post. The same month the app got a desktop version that runs the phone's own calculator files.

A Stair result in FieldDojo 1.5 with the 3D model of the stair drawn below the result card
A Stair result in FieldDojo 1.5 with the 3D model of the stair drawn below the result card

What We'd Do Differently

More aggressive calculation abstraction early. We had some duplication across trade calculators before we extracted the common patterns. The refactor took longer than it should have.

Better unit test coverage on calculation functions. The pure function approach made this easy — we just didn't write enough tests early. Some edge cases in the conduit fill calculation bit us in QA.

Design system earlier. We built the CalculatorSection component partway through and had to retrofit earlier screens. Starting with the component library would have saved time.

The App

FieldDojo is live on iOS and Android. The calculators need no account and no purchase, they work offline, and PDF export is free. Pro adds the 360° walkthrough, share links, sync across devices, the report style and editor, and unlimited projects. Read the full FieldDojo case study for the product side — problem, approach, architecture diagrams, and outcomes.

Built by Notchip — a mobile and web app development agency. If you're building something similar or need a React Native team, get in touch.