case-study --pharma-erp
§IV · PLATEPharmulo
Live · in productionA modern retailer-ordering storefront for pharma wholesalers that sits on top of ProfitMaker: live catalog and stock, guarded bill entry, and a read-only Windows agent that keeps the legacy ERP as source of truth.
project-brief --outcome-first
§IV · BRIEFWhat had to change
Let retailers order online without replacing the wholesaler's ProfitMaker ERP, writing directly to its database, or creating a second stock truth for staff to reconcile.
What I shipped
A multi-tenant retailer PWA, wholesaler admin, and auto-updating Windows agent that mirrors 26 ERP entities and drafts guarded bills through ProfitMaker's own UI.
What the business gained
A retailer order can flow from phone to a human-reviewed ProfitMaker bill without re-keying, while stock, fulfillment, and reconciliation continue to derive from the ERP.
systems --under-the-hood
§IV · SCHEMATIC- Read-only ERP mirror26 entities
An auto-updating Windows agent reads 26 ProfitMaker entities through SELECT-only SQL, then syncs typed contracts into the tenant-scoped Postgres mirror.
- Guarded order→bill bridge
The agent claims one order, checks for an existing bill, and drives ProfitMaker's Sales screen under focus and dialog guards; a human reviews the draft and ProfitMaker performs the save.
- ERP-derived fulfillment
Orders become billed only when the saved bill syncs back. Quantities and mismatches derive from its lines, with a reaper surfacing stranded drafts instead of trusting an agent acknowledgement.
- Expiry-aware batch billing
Retailers see only sellable batches, the agent skips expired or unknown-expiry stock during bill entry, and the admin stock view exposes source-data gaps for repair.
- Value-aware reconciliation
Nightly digests fold money and quantity values identically across SQL Server and Postgres, skip no-op writes, and bound any tombstone cleanup so a bad scan cannot erase a mirror.
context --how-it-works
§IV · NOTESPharmulo gives each wholesaler a branded catalog where retailers can browse live availability and place orders from a phone. The wholesaler keeps ProfitMaker, its existing staff workflow, and its database as the operational source of truth.
The bridge spans a Next.js platform, a Node sync worker, a Rust/Tauri desktop shell, SQL Server, Postgres, and guarded Windows UI automation. The agent never writes to ProfitMaker's database; it drafts through the same Sales screen staff already use and aborts when it cannot prove the UI is safe.
The current pilot has completed the order-to-bill loop end to end. Recent releases add expiry-aware stock, 26-entity reconciliation, no-op suppression, safer tombstone guards, background updates, and a retailer onboarding flow for broader rollout.