A customer portal for my family’s distributor, designed and built end to end
ESGO supplies cleaning products and foodservice disposables to businesses in Monterrey. Orders used to arrive by WhatsApp and be typed again into the ERP. I built the portal where customers now order at their own negotiated prices, and the tools the team uses behind it.
45screens across the portal, staff admin and public site
56API endpoints behind them
294commits since August 2026
768products, each with a price per customer
01 / THE PRODUCT
Walk through the portal
portal.esgoproveedores.com
BEHIND IT
Sign in. Each business signs in with its client code and a PIN. A personal link fills in the code, but the PIN is always typed, so a forwarded link opens nothing.Start from the last order. The home screen offers to repeat the last purchase and shows a monthly basket built from what this business really buys.Search 768 products. Search ignores accents and plurals, understands brand names and puts what this customer buys most at the top.A product at their price. Presentation, use and precautions for each product, shown at the price this business negotiated.Build the order. Quantities, a running total and suggestions of what similar businesses order. Nothing is sent yet.Confirm, date and repeat. One last review: delivery date, whether to repeat it weekly, every two weeks or monthly, and notes for the driver.Every past order. All purchases in one list, including the ones placed by WhatsApp before the portal existed, each one ready to repeat.Invoices and balance. Balance due, overdue invoices, due dates, PDF and XML downloads and the bank details to pay.Many properties, one view. Property managers see spending and balances for each condominium tower and download a report for the residents’ assembly.
Their price, plus VATEach product shows the price this business negotiated, with VAT spelled out.
A monthly basketWhat they order most, with the usual quantity, one tap from a new order.
Balance at a glancePending invoices and the total due, linked to the list of what is overdue.
Spending across towersThe monthly average for every property a manager runs, from real invoices.
02 / THE SYSTEM
How the pieces connect
FOLLOW ONE ORDERFrom price list to paid invoice
Sources
Master price ExcelAgreements, then lists 1, 2 and 3
MasAdmin ERPThe live system the team works in. Read through reports only
Billing mailboxEvery invoice arrives as CFDI XML
Data
Python import scriptsClean, deduplicate and match recordspandas · 47 scripts
Supabase · PostgreSQLRow-level security: each account only ever reads its own rowssingle source for every screen
App
Next.js on VercelA push to main deploys to productionTypeScript · 56 API endpoints
Public site and lead CRMSector pages, quote forms, lead sources
People
Business customersCondominiums, offices, plants, schools
ESGO teamOrder desk and billing
New businessesArriving from Google and Meta ads
03 / THE TEAM’S SIDE
Tools for the people behind the counter
/admin/pedidos
Orders inbox
Review, edit and confirm each order, then export it as a CSV the ERP imports.
/admin/precios
Prices and promos
Load price lists and create promos for everyone or chosen customers; each discount is frozen on its order.
/admin/accesos
Access log
Who signed in, on what kind of device, and who opened their personal link. Visits from ESGO devices don’t count.
/crm
Lead CRM
One record per person, the ad platform that brought them and the cost per contact.
/admin/radar
Customers cooling off
Flags businesses that stopped ordering or order less than usual, early enough to call them.
/admin/sprint
Monthly dashboard
Invoiced sales, active customers, portal orders and acquisition cost, month by month.
04 / HOW I BUILT IT
Business rules first, AI as the engineering tool
I decide what should exist and why. Claude Code and Codex write it.
rodrigo › 5% off a customer’s first order in the portal. Freeze the % on the order: editing the promo later must never change orders already placed. Discount goes before VAT.claude › Rule in src/lib/promos.ts, tests in tests/promos.test.cjs$ node --test tests/promos.test.cjs✓ discount before VAT, VAT on the discounted amount✓ first order only applies if the customer never ordered✓ the promo that saves the most pesos wins, not the highest %✓ switched off, future or expired promos don’t apply# pass 9 fail 0$ git push origin main→ Vercel: production deployment ready$ node verificar-docs.mjs✓ TODO BIEN(docs current, no keys leaked)
Write the rule in plain words
Usually in Spanish, with the business reason: who it applies to and what must never happen.
Claude Code turns it into code and tests
Business rules live as small functions with their own tests, apart from screens and database.
Check it against reality
Compare the result with the ERP’s reports and the database before trusting it.
Push to deploy
A push to main goes live on Vercel. A checker confirms the docs are current and no keys leaked.
Write down why
Each session ends by updating a status document and a dated log, so the next session starts informed.
The price comes from the agreed list
Never from what was invoiced before, which can carry old mistakes. Without a valid price the portal says “Quote”.
The ERP stays read-only
It is the live system the team works in every day. Data comes out through reports; orders go in only as a file a person imports.
A link that helps, not a key
Personal links fill in the client code, but the PIN is still typed, so a forwarded message cannot open an account.
Measure honestly
Sign-ins from ESGO’s own devices are excluded, and a sign-in is not counted as a visit.
WHAT COMES NEXT
Getting it into the routine
The portal works. The open question is adoption: these customers have ordered by WhatsApp for years. The work now is inviting them in small groups and measuring real orders and repeat use, not accounts created.
Next.js / TypeScriptSupabase / PostgreSQLPython / pandasVercelClaude Code / CodexGoogle and Meta Ads