Skip to content
ANGEL FLORES
All work

Gas distributor

Migrating a 10,850-line Windows desktop app that bills gas consumption into a web application — without touching the production database the business runs on.

Playable demo

Under confidentiality: approach and scale, no internal detail.

Client
LP gas distributor, Mexico
Year
2026
Role
Technical lead on the migration — legacy analysis, architecture, domain port and the written recommendation the client approved.
The shape of the system.Two banks and a bridge: the money logic crosses first, with tests, and both apps talk to the same database.
lines of legacy code read
10,850
tests on the money logic
46
secrets in the published repo
0

Playable demo

The bug that would have eaten the balance

C# rounds .5 to the nearest even number. JavaScript rounds it up. Nobody documents this. Run a thousand receipts through both and watch the gap open.

dominio/redondeo.test.ts

One amount

Try amounts ending in 5 on the third decimal: 1234.565, 10.005, 88.125

JavaScript · half up

MX$1,234.57

C# · banker's

MX$1,234.56

One cent apart. On one receipt nobody notices.

1000 receipts

JavaScript · half up
MX$0.00
C# · banker's
MX$0.00
Drift
MX$0.00

Bill a batch and watch the two totals separate.

1000 receipts, deterministic. Amounts carry three decimals because gas is priced per litre.

The problem

A WPF desktop app with roughly 60 screens handled every meter reading, receipt and account balance for the distributor. It only ran on Windows machines in the office, and the money logic it encoded existed nowhere else — no spec, no tests, just the code.

The decisions

  • Rewrite the app. Do not migrate the database.

    The obvious move was a fresh Postgres schema. I argued against it: doing both at once means that when a balance disagrees you cannot tell whether the new code or the new schema is at fault, and it makes running old and new side by side during the cutover impossible without bidirectional sync. The new app talks to the existing SQL database through Prisma. Moving the data is a later, optional phase.

  • Port the money logic first, with tests, before any UI

    The financial rules came out of the desktop app into an isolated domain layer with 46 tests, written before a single screen existed. Screens are cheap to redo; a balance that silently drifts is not.

  • Security triage before the first commit

    Before a single line was committed I audited the inherited code for secrets and access control, moved every credential out to environment variables, and tightened what needed tightening. The legacy source stayed out of the published repository entirely — nobody needs a client's old system in a portfolio repo.

The result

The domain layer and its test suite are done and deployed; the app runs in a demo mode that refuses to write once a real database URL is present. The rounding bug below is the single most valuable thing the port found.

Next caseBanco Azteca

Have a product to build?

I am looking for remote roles and freelance projects. WhatsApp is the fastest way to reach me.