Matthew Jeter M. Ziemba

Two-way ERP sync

Keeps HubSpot and the Dataforma ERP in step in both directions, after moving the ERP’s history into HubSpot with a ledger that can undo every write.

For
A commercial roofing contractor
When
May 2026 to now
Status
In production since August 2026
Role
Sole engineer, from the audit to production
Systems
Dataforma and HubSpot

Data paths and guards

Slack alertsState storeDataforma, the ERPSlack alertsState storeDataforma, the ERPSync serviceHistory, loaded onceHubSpotChanges, by cursor pollDeals and work ordersHubSpotEdits and card actionsWhole-record writesIds, cursors, dead lettersHealth checksCursor and id watermarkReversible ledgerSigned webhooks onlyFlags, allowlists, recencyRead-back breakersDead-letter ladder SlackState storeDataformaSlackState storeDataformaSyncaHubSpotbcdefg
  1. HubSpot: Where reps work: deals, buildings, work orders and the record cards.
  2. Slack alerts: One alert per cause from the health board.
  3. Sync service: 24 routes on Vercel: the pollers, the webhook inbox and the card endpoints.
  4. State store: Id map, cursors, audit log, dead letters and the migration ledger.
  5. Dataforma, the ERP: Projects, work orders, buildings and estimates.
  6. From Dataforma, the ERP to HubSpot: History, loaded once. Companies, contacts, buildings, deals and work orders from the ERP’s history. One reversible load, before the sync went live.
  7. From Dataforma, the ERP to Sync service: Changes, by cursor poll. ERP records changed since the last cursor, and records with ids past the watermark. Cron schedules on the service.
  8. From Sync service to HubSpot: Deals and work orders. Records created or updated in HubSpot, matched by their ERP id. Each polled change.
  9. From HubSpot to Sync service: Edits and card actions. Rep edits to synced deal fields, and new ERP projects requested from a card. A signed webhook, and a reverse poll every 5 minutes.
  10. From Sync service to Dataforma, the ERP: Whole-record writes. The full ERP record, read first and written back with the edit. A queued edit that passes every gate.
  11. From Sync service to State store: Ids, cursors, dead letters. The id map, cursors, audit log, dead letters and ledgers. Every run.
  12. From Sync service to Slack alerts: Health checks. 12 checks, each alert keyed to its cause. Each health run.
  13. On Changes, by cursor poll: Cursor and id watermark. The poll follows ids as well as dates, because a record that was never edited has no modified date.
  14. On History, loaded once: Reversible ledger. Every migrated write is journaled, so a load can be rolled back.
  15. On Edits and card actions: Signed webhooks only. The inbox accepts only webhook calls that HubSpot signed.
  16. On Whole-record writes: Flags, allowlists, recency. A write runs only where its surface is switched on, the field is allowlisted, a person made the edit and nothing newer came from the ERP.
  17. On Whole-record writes: Read-back breakers. Each write is read back, and 8 breakers stop any surface whose writes do not match.
  18. On Ids, cursors, dead letters: Dead-letter ladder. A failed record retries at 15 minutes, 2 hours and 4 hours, then daily, and the daily lane has no final state.
  • Built by me
  • Platforms I connect to
  • Guards
  • Data paths
  • In production

Data paths
History, loaded once Companies, contacts, buildings, deals and work orders from the ERP’s history
Changes, by cursor poll ERP records changed since the last cursor, and records with ids past the watermark
Deals and work orders Records created or updated in HubSpot, matched by their ERP id
Write-back
Edits and card actions Rep edits to synced deal fields, and new ERP projects requested from a card
Whole-record writes The full ERP record, read first and written back with the edit
Ids, cursors, dead letters The id map, cursors, audit log, dead letters and ledgers
Health checks 12 checks, each alert keyed to its cause
  1. Systems

    Reps work in HubSpot. The ERP keeps projects, work orders and buildings. Between them runs a TypeScript service on Vercel functions, with its state in Supabase Postgres and its alerts in Slack.

  2. Data paths

    The ERP’s history moved into HubSpot once, through a ledger that can undo it: 38,301 work orders and 11,215 deals, with 0 failed writes. After that, the service polls the ERP and writes each change to HubSpot.

    • a History, loaded once
    • b Changes, by cursor poll
    • c Deals and work orders
  3. Write-back

    A rep’s edit, or a new project requested from a card, arrives as a signed webhook, and a reverse poll every 5 minutes makes sure none is missed. The service writes the whole ERP record back and keeps its state in the store.

    • d Edits and card actions
    • e Whole-record writes
    • f Ids, cursors, dead letters
    • g Health checks
  4. Guards

    Nothing writes to the ERP until it passes flags, allowlists and a recency gate, and every write is read back. A failed record climbs a dead-letter ladder that never closes without a fix.

    • Cursor and id watermark on b
    • Reversible ledger on a
    • Signed webhooks only on d
    • Flags, allowlists, recency on e
    • Read-back breakers on e
    • Dead-letter ladder on f
  5. Result

    11,598 deals are linked to the ERP, and a rep’s edit in HubSpot reaches it in about 5 minutes.

Project ids typed by hand, and an ERP with no webhooks

Reps typed ERP project ids into HubSpot by hand, and nothing synced between the two systems on its own. The ERP has no webhooks, replaces the whole record on every update, stamps times with no time zone, and shares one rate limit with the client’s staff.

What I built

What the guards protect against

The risk The guard
Records that were never edited stay invisible to a date window. Cursor and id watermark The poll follows ids as well as dates, because a record that was never edited has no modified date.
A bad load cannot be undone. Reversible ledger Every migrated write is journaled, so a load can be rolled back.
An unsigned call reaches the ERP. Signed webhooks only The inbox accepts only webhook calls that HubSpot signed.
An echo or a stale edit overwrites newer ERP data. Flags, allowlists, recency A write runs only where its surface is switched on, the field is allowlisted, a person made the edit and nothing newer came from the ERP.
A write reports success but never landed. Read-back breakers Each write is read back, and 8 breakers stop any surface whose writes do not match.
A failed record is dropped and forgotten. Dead-letter ladder A failed record retries at 15 minutes, 2 hours and 4 hours, then daily, and the daily lane has no final state.

Decisions

  1. Poll the ERP, and follow ids as well as dates

    Chose
    Poll on a cursor plus an id watermark.
    Instead of
    A window on the last-modified date. A record that was never edited has no modified date, so a date window never sees it.
    Trade-off
    Polling spends the rate limit the client’s staff share: a full reconcile takes 345 requests and about 108 seconds.
  2. Write the whole record back, never a patch

    Chose
    Every write to the ERP reads the record, changes the edited fields and writes the whole record back.
    Instead of
    Sending only the changed fields. The ERP replaces the whole record on every update, so a write that leaves a field out empties it.
    Trade-off
    Every write costs a read first.
  3. Pause the client’s own workflows during the load

    Chose
    A guard paused the client workflows that overlapped the load and restored them when it finished.
    Instead of
    Loading with every workflow running. 13 of 18 enabled deal workflows overlapped the load, and 3 of them ended in emails to customers.
    Trade-off
    The overlapping automations stop while a load runs; the deal load took about 26 minutes.

Results

  • 11,598 deals linked to the ERP.
  • 38,301 work orders and 11,215 deals migrated, with 0 failed writes.
  • 34,251 associations drawn across 11,220 projects, and 3,856 billing offices loaded.

Facts

  • Association-label limit measured at 50 per object pair, against a documented 10
  • Cutover in two steps: deployed with writes off, one cycle watched, then writes switched on
  • Round trip proven in HubSpot’s own screens: a card made an ERP project, and edits crossed both ways
  1. Two-way field-service sync

    Date: Feb 2026

    Fact: 11,683 deals and 8,182 tickets in a two-way sync

    Client: For a commercial roofing service contractor

    Systems: CenterPoint Connect, Zapier, QuickBooks Online and Make.com

    Status: In production

  2. Multi-tenant event processor

    Date: Jun 2026

    Fact: 10,630 events in 7 days through the queue that replaced Make.com

    Client: For a multi-brand roofing company

    Systems: AccuLynx and Make.com

    Status: In production

  3. Desktop accounting connector

    Date: Jun 2026

    Fact: Sales recognition reconciled to the cent across 3,709 deals

    Client: For a residential roofing and solar contractor

    Systems: QuickBooks Desktop

    Status: In production