Nafiz Anam.

All case studies
SaaS / AgricultureSaaSAgTechServerlessAWSXero

Broker Note: A Multi-Tenant Contract and Invoicing Platform for Australian Grain Brokers

How I built Broker Note, a serverless multi-tenant SaaS that turns one grain deal into a GTA-style broker note, emailed PDFs, a Xero invoice and a seller RCTI for Australian brokers.

Services provided: SaaS, AgTech, Serverless, AWS, Xero, Multi-tenant, PostgreSQL, Terraform, Next.js, SEO

See How We Helped

Client

Broker Note (grainbrokernote.com.au)

My Role

Lead Full-Stack & Cloud Engineer

Key Outcome

Serverless multi-tenant platform that turns one deal into notes, PDFs, invoices and RCTIs

Broker Note: A Multi-Tenant Contract and Invoicing Platform for Australian Grain Brokers: case study cover image for Broker Note (grainbrokernote.com.au)

Short answer: what is Broker Note?

Broker Note (grainbrokernote.com.au) is a multi-tenant SaaS for Australian grain brokers. A broker enters a deal once, and the platform produces a GTA-style broker note, emails branded PDFs to the seller and the buyer, and raises the buyer invoice and the seller's RCTI in Xero. It replaces retyping the same deal into Word, email and accounting software.

This case study covers the problem, the serverless architecture, the hard engineering decisions, and how the marketing site was built to be found and understood by search engines and AI assistants.

Project snapshot

ProductBroker Note, broker note, RCTI and invoicing software for Australian grain brokers
Live sitegrainbrokernote.com.au
My roleLead Full-Stack & Cloud Engineer
ModelMulti-tenant SaaS for brokers, with counterparties receiving PDFs without needing an account
Build windowFirst commit August 2026, shipping continuously through November 2026
Scale of the codebase70,000+ lines of TypeScript across the backend, web app and landing site, with 275+ backend commits
StackAWS Lambda, API Gateway, Cognito, RDS PostgreSQL with RLS, Drizzle, Hono, EventBridge, SQS, S3, SES, Terraform, Next.js, Astro, Cloudflare

What problem does Broker Note solve?

A grain broker negotiates a deal between a grower and a buyer, then has to document it. In practice that meant:

  • Typing every deal several times: once for the contract note, again for the buyer's invoice, again for the seller's recipient-created tax invoice (RCTI).
  • Getting the terms right: commodity, grade, delivery and conveyance terms, GTA contract options and settlement terms, all with legal weight.
  • Chasing paperwork: PDFs emailed by hand, with no clear record of which notes were invoiced or completed.
  • Keeping accounts in sync: invoices copied into Xero manually, with errors that surface at tax time.

The brief: enter the deal once, get correct documents and accounting entries out of it, and keep a trustworthy record.

What did I build?

The broker note wizard

A five-step wizard covers 14 Australian commodities with multi-grade spreads, delivery and conveyance terms, GTA contract options, settlement terms and custom special terms. Validation is shared between the API and the UI through common Zod schemas, so a note that passes in the browser is a note the server accepts.

Counterparty directories

Seller and buyer records store ABN, NGR, farm and silo locations and separate trading and accounts contacts, so a deal can be started from saved details.

Documents and email

Branded PDF broker notes and RCTIs are rendered in the background, stored securely and emailed to each party from the broker's own Google Workspace address or the platform sender, using customisable templates. Bounces and complaints are handled automatically.

Xero invoicing

Brokers connect Xero over OAuth 2.0. Buyer sales invoices and seller RCTIs are raised from the note, with token refresh running on a schedule so connections do not quietly expire.

Registry, dashboard and billing

A notes registry tracks Draft, Invoiced and Completed states and supports duplicating, emailing and invoicing. A dashboard shows notes created, tonnes traded, brokerage earned and remaining quota. Subscriptions run through Stripe Billing with a free tier of two notes, and a separate platform admin panel manages tenants across the whole system.

How is it architected?

The backend is serverless on AWS, defined entirely in Terraform, with one account per stage.

  • One function per trust boundary. The broker-facing API and the platform admin API are separate Lambda functions with separate database roles, so a bug in one cannot leak data across tenants.
  • Hono on Lambda behind API Gateway, with a Cognito JWT authorizer for email and Google sign-in. Signature-verified webhook receivers sit on their own unauthenticated route.
  • PostgreSQL 17 with row-level security and an RDS Proxy. Tenant isolation is enforced by the database. The Drizzle ORM defines tables, migrations and policies.
  • Event-driven async work. Anything slow or unreliable (PDF rendering, email, Xero, billing) runs off the request path: an event is published to EventBridge, a durable SQS queue holds it, and a worker processes it. Every queue has a dead-letter queue and an alarm.
  • Layered packages: shared schemas, database, pure domain services with no cloud imports, HTTP middleware, PDF, email and observability modules.
  • Web application: a Next.js app built as a static export and served from Cloudflare, calling the API over HTTPS.
  • Marketing site: a separate, fully static Astro site on Cloudflare.

What were the hard engineering decisions?

How do you isolate brokers' data?

Brokerage deals are commercially sensitive. Rather than rely on a tenant filter in every query, isolation is enforced by Postgres row-level security under a restricted role, while only the admin function uses a role that bypasses it. Tests run against real policies, not a superuser that hides mistakes.

Why serverless, and why separate functions?

Traffic is spiky and tied to the trading day, so paying per request fits better than idle servers. Splitting functions by trust boundary rather than by route keeps the security model simple: two roles, two blast radii.

How do you integrate an accounting system reliably?

Xero tokens expire and APIs rate-limit, so calls never run in the request. A scheduled refresher keeps tokens alive every twenty minutes, and invoice creation runs through queues with retries and dead-letter handling. A failure becomes a visible, retryable job instead of a lost invoice.

How do you produce documents people can trust?

PDFs are generated from the stored note, not from the form, so what the broker sent is exactly what is on record. Documents are stored privately and shared through presigned links.

How is it operated?

Sentry captures errors in every function and worker, CloudWatch alarms watch the dead-letter queues, and CI audits dependencies, type-checks, tests and builds before each deploy to staging or production. A local end-to-end script brings up real Postgres policies and emulated AWS services for development.

How was Broker Note built for SEO, AEO, GEO and AIO?

Brokers search for specific, practical things: "grain broker note template", "RCTI calculator", "GTA contract". The marketing site is built around those intents.

Classic SEO

  • A fully static Astro site: no framework runtime, self-hosted fonts and a single small bundled script, so pages load fast and are easy to crawl.
  • Generated robots.txt and sitemap.xml, built from the same single source file as the page content.
  • Security headers and a content security policy, with CI that fails the build if any page ships an inline script other than structured data.
  • Two free tools that target real searches: a grain contract template and a per-tonne brokerage and RCTI payout calculator.

AEO: answer engine optimization

  • A FAQ written from one shared data file feeds both the visible page and the structured data, so the questions answered in the page are the same ones machines read.
  • Pricing, plan limits and supported commodities stated as plain facts, with an example deal that shows exactly how brokerage and payout are calculated.

GEO and AIO: generative and AI-overview optimization

  • A JSON-LD graph describes the product, organization, offers and FAQ with consistent naming.
  • A 90-second demo video with chapter markers and a full transcript, so assistants can quote the product walkthrough without watching it.
  • Localised specifics (Australian terms such as ABN, NGR, GTA and RCTI, AUD pricing, Sydney data hosting) that tie the product to the market it serves.

Results

  • A working multi-tenant platform that turns one deal entry into a broker note, emailed PDFs, a buyer invoice and a seller RCTI.
  • Database-enforced tenant isolation and an event-driven backend with dead-letter queues and alarms on every path.
  • A static, fast and structured marketing site with free tools aimed at the exact searches brokers make.
  • Staging and production environments defined as code and deployed through CI, delivered in roughly three months.

Figures on the Broker Note site, such as "a note in 90 seconds", are the product's own claims, and the example deal numbers and document numbers are illustrative. I do not restate them here as audited results.

Frequently asked questions

What does Broker Note do?

It lets an Australian grain broker enter a deal once, then generates a GTA-style broker note, emails PDFs to the buyer and seller, and raises the buyer invoice and seller RCTI in Xero.

How much does it cost?

There is a free plan with two broker notes. Paid plans have unlimited notes, billed as AUD $4,999 a year or $499 a month at launch pricing, which the site says rises from 1 January 2027.

What tech stack is it built on?

AWS Lambda with Hono and PostgreSQL row-level security through Drizzle, EventBridge and SQS for background work, Cognito for sign-in, Stripe for billing, Terraform for infrastructure, and Next.js and Astro on Cloudflare for the web app and marketing site.

Can I hire the person who built it?

Yes. I build serverless SaaS platforms, accounting and invoicing integrations, and document workflows. Book a call to talk through your project.

Start a Project

Planning something similar?

Let's talk about your goals and how we can turn them into a scalable, production-ready system.

Send a MessageExplore Services