myTrellis

myTrellis

TypeScript NestJS React Prisma PostgreSQL Multi-tenant SaaS Stripe Connect Google Cloud Terraform GitHub Actions Next.js

On this page

TLDR;

DimensionDetails
Role and scopeSole designer and engineer: product, design system, infrastructure, CI/CD and the closed alpha
TeamMe and a few business partners
StatusStart-up in closed alpha, with around a dozen real users on test tenants
Core stackEnd-to-end TypeScript, NestJS, React, PostgreSQL (Prisma), better-auth, Stripe Connect
InfrastructureGoogle Cloud in Australia, Terraform (development, UAT, production), GitHub Actions
ArchitectureA database per tenant, shared application servers, expand-and-contract migrations
AI integrationMCP server with scoped OAuth and an audit trail of agent activity, plus AI invoice scanning (see the related case study)
Quality and operationsStorybook, visual regression tests, distributed tracing, Sentry, tested restores

The problem and who it’s for

myTrellis is an invoicing platform for sole traders and small businesses.

It started with my own freelance admin. For over a decade I edited an invoice template by hand in Adobe InDesign, and I couldn’t justify $30 to $75 a month for enterprise platforms when freelance income fluctuates. Friends and tradies were hacking invoices together too, or paying for platforms and using a fraction of them.

The customer app overview, running on demo data.

How this came together

Between working full-time and becoming a dad, building a SaaS on the side felt out of reach… however, AI assisted development tools gave me the leverage to make it finally happen. These tools accelerated the development work whilst I could focus on high-level architectural decisions. As long as the foundations were in place, such as ensuring end-to-end TypeScript, visual regression tests and Terraform plans caught regressions to allow easier refactoring and tackle technical debt as they come in at unprecedented pace.

Agentic workflows with access to tools which was used to help write tech specs and with low-level implementation plans, combined with project management tools to create PRDs and CI/CD processes like automated-code reviews allowed us to move fast but responsibly with a small team.

High-level feature development workflow

Whenever a new feature or enhancement is introduced into the application, it starts with myself setting the goals, making sure the architecture decisions and what is shipped is to the quality I set. Agents and automation do the drafting, building and checking in between.

The darker boxes is where I intervene, the white being AI agents

Architecture

A simplified view of the platform: shared servers, one database per customer and a small directory that knows which customer is which.

Shared application servers, one PostgreSQL database per customer and a small directory that tracks which customer is which. Every request is scoped to a single customer before any data is touched.

Key decisions

  • PostgreSQL over Firestore and other NoSQL. Invoicing data is deeply relational and has to stay consistent, so I wanted real transactions, constraints and joins. Firestore is quick to start, and I have used it in production, but filtering and reporting became painful as the product grew. In Postgres, a new report is just a new query over the data I already have.
  • JSONB where data is flexible. Addresses, bank details and other custom structures vary in shape and are read and written as a whole, so they live as JSONB in the same database. Each shape is defined once as a Zod schema, which validates the data and gives me the TypeScript type from database to front end.
  • A database per customer. Stronger isolation than row-level tenancy, and simple per-customer backup, restore and deletion. The cost is operational: every schema change has to reach every database (see below).
  • Data stays in Australia. The servers, customer databases and backups all run in Australia, with backups copied to a second Australian location, and AI model processing happens here too. The exceptions are the third-party services for payments and email.
  • Traceability by design. For financial records, “what happened, who did it and when” is a feature. In the app, quotes and invoices carry an activity timeline and documents keep frozen snapshots of client and business details, so editing an address never rewrites history. In the back end, an audit trail records who acted (an administrator or an AI agent), what they did and to what, and tracing follows requests across the apps and APIs.
  • better-auth over Supabase. better-auth runs inside my own API, so identity lives in my own Postgres with no separate vendor holding users and sessions. It suits a model where one identity spans the customer and console apps but sessions are scoped to a single customer, and its two-factor, token and OAuth plugins cover sign-in and the flow AI assistants use to connect. The trade-off is that I own more of the security upkeep.
  • Stripe Connect. Each business keeps its own Stripe account and funds go straight to them. Stripe handles card details, never in myTrellis. Webhooks are used to transition invoice states based on transaction events.

Engineering problems faced

Schema changes across many databases

With a database per customer, “run the migration” is not one operation. A fan-out runner migrates every active customer, retries transient connection errors and fails the deploy before the new code goes live if any customer fails. Migrations only move forward, so changes follow an expand-and-contract pattern: old and new code can coexist, and risky changes are split into small, reversible steps.

Payments in an isolated-data world

Stripe delivers every connected account’s events to one endpoint, with no customer identity attached. Each event is signature-verified, mapped back to the right customer through a small shared index, then checked again independently before any payment is credited, so a routing bug cannot credit the wrong customer. Processing is idempotent, so Stripe’s retries are safe, and failures are recorded and retried.

Provisioning and recovering safely

Creating a customer means creating and migrating a database, which can fail halfway. Provisioning is an explicit state machine (pending, active, failed) with automatic retries and backoff, an alert when failures cluster and a retry from the console. Per-customer backups are restored into an isolated environment and reviewed first, so one customer can be recovered without touching the others.

Application design

Two applications on one platform:

  • Platform app: where each business (tenant) manages clients, quotes, invoices, recurring invoices, expenses and reporting, sends invoices with payment options and syncs statuses with payment providers.
  • Console app: internal tooling for operating the product and monitoring customers. During the alpha it also provisions tenants manually and triggers the onboarding workflow.

From quote to invoice

Quotes are drafted, sent and accepted, then converted into invoices in one step that keeps a link to the source quote. Behind the flow, each document freezes the client and business details at the moment it is created, payments are processed idempotently, and every invoice PDF carries a QR code for its pay link.

An accepted quote, ready to convert. The activity timeline records each step.

The PDF invoice, with a QR code for paying online.

The design system and type safety

  • Typed end to end. Zod schemas are shared between the back end and front ends, which use generated API clients, so an API change shows up as a compile error rather than a production bug.
  • A design system. Roots is a Storybook-documented component library, with design tokens that generate both the web CSS and a mobile theme.
  • Safe imports. CSV import shows a validation preview before anything is committed, and can be rolled back.

Roots in Storybook: compound components, such as this data table with status cards, are documented and interaction-tested.

CSV import: every row is validated and any problems are listed before anything is imported.

How it’s built and run

myTrellis runs on Google Cloud, with infrastructure defined in Terraform and every deployment run by GitHub Actions, so nothing is changed by hand.

  • Environments. Development, UAT and production share the same Terraform modules. Changes are planned before they are applied, production applies a reviewed plan, and drift is checked on a schedule.
  • Releases. Production changes are deployed with no traffic, health-checked and only go live when a person promotes them, with a backup required before risky changes.
  • Quality and security. Unit, integration, interaction and visual regression tests, tracing and error monitoring, plus two-factor authentication, role-based access and secrets kept out of the codebase.

A second monorepo holds the marketing site at mytrellis.io, currently a holding page during the alpha, and the product documentation at docs.mytrellis.io, built with Fumadocs. The docs are a step-by-step guide for non-technical testers, written around what a business owner is trying to do rather than feature names.

docs.mytrellis.io: a Fumadocs site written as a task-based alpha user guide.

What I learned

The closed alpha taught me more than any amount of planning, and mostly about things other than code.

  • Monitoring comes first. Foundations like Sentry showed me bugs that test users rarely report. Most people hit a problem, shrug and move on.
  • Alpha tests real behaviour. It was the first real test of the multi-tenant design, confirming that no tenant could see another tenant’s data, and it exercised the whole onboarding flow: welcome emails and the password and account set-up journeys.
  • Costs need watching early. Around a dozen tenants showed me the baseline storage and compute cost of each, so I could keep it tight.
  • Release discipline matters once people use it. Testers were working in UAT, so I could no longer deploy features there whenever I liked.
  • Know what an alpha is for. It is about readiness, not feedback volume. Friends and family are generous, but they rarely use a product without being prompted, so set expectations accordingly.

Next case study: myTrellis AI

The AI work sits on the same platform, with the same guardrails: an MCP server with scoped OAuth and an audit trail of agent activity, and an invoice scanner where a person approves every record. It has its own case study.