Portfolio / Export application
From lot to shipment, with the invoice in order.
GrassRanch's owner runs a group of three companies that export and import South American beef. Every sale ties together a lot with its RENSPA, a container, a health certificate, an export declaration and a commercial invoice the accountant files afterwards. We designed and built an application that organizes that journey per company and leaves a trail for every change.

01The challenge
An export is five documents that must agree.
Selling a container of frozen beef abroad is more than issuing an invoice. The lot has to come from an approved plant and carry a RENSPA, the cargo leaves with a health certificate, travels with a bill of lading and a packing list, and kosher or halal product needs the certificate for that slaughter. The commercial invoice has to say the same thing as all of them.
The group isn't one company, either: it's three legal entities, each with its own identity, bank and customers. The owner wanted one place where each company works without seeing the others, where he sees the whole picture, and where nobody can make up a number that can't be backed later.
What had to line up
- 01Three companies, each with its issuer and bank
- 02Importer customers per company
- 03NAMP/IMPS catalog with NCM and HS codes
- 04Lots with RENSPA, SENASA plant, slaughter and expiry
- 05Sea and air shipments
- 06Health certificates, B/L, export declaration, kosher and halal
- 07Commercial invoice and annexes
- 08ARCA filing done by the accountant
- 09Own prices against the market
Our role
Product and domain modeling, architecture, visual system and interface, frontend and backend development, PDF package generation, price syncing, auditing, testing, decision records and deployment.
02The rule
The decision that shaped the whole system.
If the data doesn't exist, the system won't invent it.
No fake tax authorization code, no assumed market quote, no destination fee filled with a convenient number. An invoice with no tax filing stays a draft; a category with no quote shows its empty state; a shipment with no fee says “no fee configured”. Catalog tariff codes come in as “unverified” until someone confirms them.
Money follows the same idea: amounts are stored as exact decimals, never floats, and an invoice in another currency requires an explicit exchange rate. A dollar price is never converted silently.
Nothing inventedEvery company isolatedEvery change attributedThe accountant files, the system prepares
03Multi-company
Three companies, one owner.

The owner lands on the group view: billed this month, invoices, active customers and shipments in progress across the three companies, plus what each still has to issue. From there he enters a company to work in it. Companies and amounts in the screenshot are fictitious.

Switching companies rewrites the session, not a screen filter: every query carries the active company and the server refuses writes to another one. The switch is logged in the audit trail.

Invoices and billing for the month, currency split, a six-month series of issued invoices and own prices against the market by commercial category.
04How a sale moves
From the ranch to the paperwork.
Each step builds on the previous one: the shipment reserves kilos from real lots, documents hang off the shipment, and the invoice takes the ports, vessel and lots it prints on its origin sheet from that shipment.
Lot
RENSPA · SENASA · slaughterShipment
Sea or airTrade checklist
Eight document typesInvoice
Draft · issued · voidPDF package
Four sheetsARCA
Filed by the accountant
- 01
Lot
Recorded with product, RENSPA, SENASA plant, slaughter date, expiry and starting kilos. Availability only drops when a shipment reserves it.
- 02
Shipment
Mode, customer, origin and destination ports, quota, export declaration, dates, vessel, container and seal. Assigning a lot deducts its kilos in the same transaction: two people can't sell the same stock.
- 03
Documents
Health and origin certificates, B/L, packing list, export declaration, halal, kosher and other. Each with number, issue date, expiry and file; the shipment shows what's missing.
- 04
Invoice
Issuer, customer, incoterm, payment terms, catalog or free-form lines, freight and insurance, with a live preview. It's saved as a draft and issued from the detail page.
- 05
Package
On issue, the PDF bundles the invoice, payment instructions, the certificate for each category present, and the shipment's origin and traceability sheet.
- 06
Tax filing
The accountant files the invoice with ARCA, Argentina's tax agency, outside the app and can then note the voucher number, authorization code and expiry. The system neither requires nor invents them.
The screenshots that follow use fictitious companies, importers, lots, shipments and certificates, created on a local database that was deleted afterwards.
05Shipments and traceability
Where every container is.

The shipment lists its assigned lots with kilos, price and subtotal, and only offers lots with stock left. Alongside, the dispatch data; below, the trade checklist with what's loaded and what's pending. Vessel, container and lots are made up.

Every document of every shipment: complete, empty slots, expiring within 30 days and expired. An expired certificate no longer clears the shipment, and files are only served to a signed-in user.

Kosher, halal and premium per company, with certifying body, number, plant and validity. An invoice carrying products in that category attaches its sheet. The bodies in the screenshot are “sample” ones.
06Invoicing
An invoice that holds up.

The detail page shows the actual package in a tabbed viewer —full, invoice, payment and banking, certificates, origin—, the ARCA record the accountant fills in, sending to the customer and a history of who did what. Sending is disabled in the screenshot because there was no SMTP.

The 4 sheets the app generated for that invoice: commercial invoice, payment and banking instructions, premium quality certificate, and origin and traceability with the lots, their RENSPA and slaughter dates. Bank, account and certificate are fictitious; every footer reads “Demo document — fictitious data”.

Draft, issued and void. An issued invoice can't be edited: it's voided with a mandatory reason that lands in the audit log. The number is suggested in sequence and rejected if already taken.
07The data model
Six decisions you don't see.
44 tables across 27 versioned migrations. Every weighty decision was written down as an ADR —there are 28— so the next person to touch the system knows why it works this way.
The company rides on every row.
Customers, products, lots, shipments, invoices and documents carry their company. Line items copy their parent's to filter without joins, and writing to a company other than the active one is rejected on the server.
One kilo, one sale.
Assigning a lot to a shipment deducts availability inside the same transaction, and a lot can't appear twice in one shipment. In production, Neon's WebSocket pool allows interactive transactions; the HTTP driver doesn't.
Decimals, not floats.
Amounts as decimal strings with integer arithmetic. The live preview and the saved invoice share the same calculation, so their totals match by construction, not by luck.
Screen, email and PDF.
The document renders from a single typed view. The detail page, the email and the PDF don't recompute totals or pick a currency, so they can't contradict each other.
Before and after, never deleted.
35 tables have a trigger that stores the old and new values, tied to the operation and its author. The audit tables reject UPDATE, DELETE and TRUNCATE.
The app migrates itself.
Code and schema drifting apart broke production more than once. The app now applies pending migrations on startup, behind a Postgres lock so two instances don't collide.
08International price
Own prices against the market.

Conventional, premium, kosher and halal: the average of the own price list against the latest quote, with the percentage above or below market and a six-month series. Quotes in the screenshot are sample values, labeled as such; none is real.
09Where the numbers come from
Quotes with a source and a date.
Conventional, from report 2453.
A GitHub Actions workflow calls a protected endpoint every day that pulls the Choice cutout from USDA's Datamart, converts dollars per cwt to dollars per kilo and stores the series.
Premium, from report 2465.
The Prime grade from the comprehensive report, every Monday. If it fails, only that category degrades; the conventional one stays up.
ECB and EU carcass price.
Another daily workflow pulls the ECB exchange rate and the European Commission's indicative price, to read the list in EUR per kilo and invoice in euros at the day's rate.
Manual, on purpose.
They're slaughter certifications, not quality grades, and nobody publishes their price. They're entered by hand with a source; making up a premium would mean inventing the data.
10Roles and permissions
Seven roles per company.
A user can hold a different role in each company. 7 roles, checked on every page and every server action: hiding a button is never the only barrier.
The whole group.
Group view, companies, users, issuers, integrations and the audit log.
One entire company.
Runs and configures their company, its access and its document design.
Customers and quoting.
Importer accounts and invoice preparation.
Closing invoices.
Issues, voids with a reason and sends invoices.
From lot to port.
Lots, shipments, documents and certificates.
Read everything, file.
Reads operations, records the ARCA filing and is the one who will connect QuickBooks with their own account.
Look, don't change.
Read-only access to the assigned company.
11Audit log
Every change, attributed.

Who, from where, in which company and how much data changed, filterable by date, user, company, module and source. The banner on top is real: it flags changes made outside the app —here, the ones from the script that seeded the demo database.
12Bilingual and mobile
In Spanish, in English and on the phone.

Spanish without a prefix and English under /en, with the chosen language remembered for a year. Routes aren't translated —domain vocabulary is part of the model— and a test checks that both dictionaries share the same keys.

The map and history stack into one column, with navigation in a menu. Spanish interface.

The detail keeps the package viewer and the PDF download.
13Visual system
A pasture green for a serious tool.
Sidebar · Primary action · Headings
- HEX
- #284030
- RGB
- 40 · 64 · 48
Active states · Charts
- HEX
- #3D5F47
- RGB
- 61 · 95 · 71
Accent · Brand on green
- HEX
- #A1BF75
- RGB
- 161 · 191 · 117
Market series · Secondary
- HEX
- #9FBCBF
- RGB
- 159 · 188 · 191
App background
- HEX
- #F9F9F7
- RGB
- 249 · 249 · 247
Surfaces · Hover
- HEX
- #F1F5F2
- RGB
- 241 · 245 · 242
14Architecture
Same locally as in production.
The database is picked by its connection URL: Neon in production, PGlite —embedded Postgres— in development and tests. Both support transactions, so the tests exercise the same SQL that runs on the server.
Next.js 15
App Router · Server ActionsNextAuth
JWT session · TurnstileNeon Postgres
Drizzle · auditingCloudflare R2
Documents and certificatesGitHub Actions
CI · daily pricesSMTP
Invoice with its package
- 01
The interface
Next.js 15.5 with App Router, React 18, strict TypeScript, Tailwind and next-intl. Mutations are Server Actions that first resolve the active company and the permission.
- 02
Access
NextAuth with credentials and bcrypt, login attempt limiting, Cloudflare Turnstile in production —an incomplete setup rejects sign-in rather than leaving it open— and security headers.
- 03
Documents
The PDF is generated on the server with Forme and merged with pdf-lib; fonts ship as bundled TTFs. Evidence and certificates go to R2 and are only served to a signed-in user.
- 04
Scheduled work
Two GitHub Actions workflows sync USDA and European data against token-protected endpoints. CI runs types, lint, tests, build, migration validation, secret scanning, dependency audit and the E2E suite.
- 05
Quality
More than 490 Vitest tests and 6 Playwright E2E suites on desktop and mobile, against a throwaway database.
There's also a private ChatGPT connector over MCP with OAuth and a per-company QuickBooks foundation. The former only switches on with an identity provider configured; QuickBooks isn't connected.
15Evidence of depth
Technical scope, not a sales result.
Figures counted on the repository. They describe the size of what was built, not sales, kilos exported or hours saved.
- 44
- tables across 27 versioned migrations
- 35
- tables with before-and-after auditing
- 7
- per-company roles, checked on the server
- 490+
- automated tests
- 28
- documented architecture decisions
- 72
- commits from August to October 2026
16Where it stands
Deployed, documented and with clear open items.
The first commit is from 9 August 2026 and the last one reviewed from 18 October. Invoicing, master data, traceability, documents, certificates, document design, reference prices, multi-company, auditing and both languages are built, tested and deployed on Hostinger with the database on Neon.
Electronic invoicing was left out at the owner's request: the group doesn't run it from the system. The accountant files with ARCA and records the result if they want to; the AFIP adapter stays in the code, unused, for a future phase. QuickBooks has its per-company structure but no ledger connected, and the GrassRanch website isn't integrated with the app.
Out of scope or pending
- 01Automatic e-invoicing (CAE)
- 02A live QuickBooks connection
- 03Integration with the website
- 04Real certificates per company
- 05Fixing the lot list
17The outcome
What changes when everything agrees.
An invoice you can back line by line.
The group has one place where each company puts its exports together without mixing with the others: the lot with its RENSPA, the container on the map, certificates with their expiry and an invoice that prints exactly what the paperwork says.
And when someone asks who changed a value, when and why, the answer is already written down.
TraceableIsolatedAudited
beleafdesign
Do your invoices say the same thing as your export paperwork?
We design custom systems for operations with their own rules: several companies, documents that expire and numbers that have to hold up. Let's look at how your business runs today.
Let's talk about your project