
A SaaS product gets maybe four decisions that are genuinely hard to reverse. Who owns a row. What the AI is allowed to read. What a single request is permitted to cost. And how money is counted. Everything else, the framework, the component library, the hosting, can be changed later by somebody having a reasonable week.
This is about those four. The earlier piece on AI-driven SaaS covered why the category is shifting; this one is the part you draw on a whiteboard before anyone writes a migration.
Tenancy Is the One You Cannot Undo
There are three usual answers: one database with a tenant column on every table, one schema per tenant, or one database per tenant. The honest version of the trade-off is that the first is cheapest to run and the easiest to get wrong, and the last is the opposite.
What decides it is rarely scale. It is compliance and blast radius. Healthcare and finance work usually settles the question for you. For everything else, a shared database with tenant scoping enforced in one place, not in each query, is the pragmatic answer.
The sharper point is that tenancy and roles are the same design. Our travel-operations platform is multi-tenant by design with an org to user to role model enforced by RBAC and Keycloak SSO, because a tour operator, a sub-agent, a hotel and a driver all need the same workspace with different truths visible in it. The PropTech platform runs five roles, agent, buyer, lawyer or valuer, caretaker and tenant, from one Flutter codebase and one FastAPI backend using role-scoped JWTs and RBAC middleware, with no duplicated code per role. The Swiss field-service platform does it with four: Field Worker, Dispatcher, Manager and Admin, each scoped to quoting, billing, dispatch and analytics.

None of those three could have had roles added afterwards without a rewrite, which is the whole argument for deciding it in week one.
Scope the AI, Not Just the Queries
Tenant scoping on your SQL is the part everyone remembers. The part that bites is retrieval. A vector index is a bag of text with no idea who owns it, so an answer can be perfectly grounded and still quote another customer's document back at them.
Two rules keep that from happening. Retrieval filters by tenant before similarity, not after, and the tenant identifier travels with the request rather than being looked up inside the AI service. We keep vectors in pgvector next to the rows they belong to for exactly this reason: the data is already in PostgreSQL, the scoping is already there, and there is no second store to keep in step. The field-service platform computes embeddings in Celery whenever a quote or job is saved, so search stays current without a nightly reindex.
If several models are in play, something has to choose between them per request. GoAI Chat rates each incoming question and hands it to whichever model and agent pairing suits it, while every account keeps its own history and settings behind JWT auth, OTP verification and role-based access. More on how that routing is built in the guide to putting an agent into a business.
Put a Ceiling on What a Request Can Spend
Per-seat pricing assumes the cost of a user is flat. The moment AI is in the product that stops being true, and an unmetered feature can quietly turn your best customer into your worst margin.
Our building-code compliance platform is the clearest example of treating this as architecture rather than finance. Before any job is queued it estimates page count, OCR cost and LLM token cost, and shows that estimate to be acknowledged. Each of the six pipeline stages displays its own running cost. A configurable hard ceiling per document is enforced by task gating in Celery, and if a job approaches it mid-pipeline a Sentry alert fires. Duplicate submissions are caught by SHA-256 content hash and rejected before any processing or billing happens at all.
That is a construction product, but nothing about it is construction-specific. Estimate before you spend, show the number, cap it, alert on it, and refuse work you have already done.
Billing Belongs on the Architecture Diagram
Billing bolted on after launch is the second most expensive retrofit in SaaS, behind tenancy. It is also the one teams consistently underestimate, because the demo of it looks like a Stripe checkout button.
What it actually looks like in production: the field-service platform runs Pro, Business and Enterprise tiers on Stripe Subscriptions with trial-to-paid conversion, seat-based pricing, Stripe Connect onboarding and usage tracking. The travel platform carries sub-agent seats, referral codes and automatic commission calculation inside the core billing layer, with multi-currency Stripe checkout and supplier-bill tracking beside it. The PropTech platform has per-role plans, Stripe Connect payouts for agent commissions, and a PostgreSQL ledger recording every payment event, subscription change and refund.

The ledger is the part worth copying. Once money moves through more than one party, an append-only record of what happened is the difference between a support question that takes a minute and one that takes a day.
One Tenant Should Not Spoil Everyone's Afternoon
AI work is bursty and slow. Run it inside the request cycle and the first large job takes the product down with it, so anything that calls a model, parses a document or writes a report belongs on a queue.
We run Celery on Redis across these builds: task chains for multi-stage pipelines, Celery Beat for scheduled follow-ups, Flower for watching the workers, and separate queues so embeddings, notifications and imports do not compete. The compliance platform adds worker replicas for throughput without touching application code, which is the property you want when one customer uploads four hundred drawings on a Tuesday.
What Usually Breaks First
- Tenant scoping written per query. One forgotten WHERE clause is a data leak. Enforce it in one layer and make it impossible to forget.
- Retrieval that ignores tenancy. The SQL is scoped, the vector search is not, and the AI answers with somebody else's document.
- An AI feature with no meter. You discover the unit economics from the invoice instead of the design.
- Synchronous AI calls. Everything is fine until a slow model holds a web worker and the queue of waiting requests becomes the outage.
- Billing added at the end. Pricing then gets designed around what the code can measure rather than what the customer values.
The Stack We Reach For
Across these SaaS builds the shape is consistent. Next.js on the front, FastAPI in Python on the back because the AI libraries live there, PostgreSQL as the single source of truth with pgvector for retrieval, Redis for cache and broker, Celery for anything slow, and Stripe for money. Where a mobile client is part of the product we use Flutter against the same backend, which is covered in the cross-platform comparison.
Choose the boring half deliberately. The interesting risk in an AI product should be the AI, not the question of whether your database can do transactions.
One number worth quoting on the market, with its caveat attached: High Alpha's 2025 SaaS benchmarks found AI was core to the product for 100% of surveyed companies founded that year, against none of those founded in 2016. That is a survey of a self-selecting cohort rather than a census, so read it as direction rather than measurement. Market-size forecasts for 2026 are less useful still, landing anywhere between roughly $370 billion and $490 billion depending on what each firm counts as SaaS.
What It Actually Runs On
Infrastructure advice for SaaS usually arrives as a list of the largest things available: Kubernetes, multiple regions, a service mesh. Every platform named in this piece serves paying customers, and not one of them has needed that yet.
What they run on is containers and a reverse proxy. The field-service platform and the compliance platform both deploy through Coolify, which is managed Docker Compose, on DigitalOcean: Python 3.11-slim and Node 20-alpine images from multi-stage builds, nginx in front of one and Traefik in front of the other, Cloudflare and Let's Encrypt for DNS and TLS, GitHub Actions doing build and release. The travel platform is the same shape, Docker and nginx on Linux servers.
Scaling, when it arrives, is the boring kind first. FastAPI runs under gunicorn with several uvicorn workers. The compliance platform takes more documents by adding Celery worker replicas, with no change to the application code. Redis carries the queue and the pub/sub for live dispatch at the same time. More workers and more headroom answer most growth, and they cost a fraction of what an orchestration layer costs in attention.
The parts worth paying for on day one are the ones that save you at two in the morning:
- Errors you can trace. Sentry across backend and frontend, structlog writing JSON, and a trace id on every request. Without that, a bug report is an anecdote.
- Costs you can explain. The compliance platform logs the cost of each pipeline stage to PostgreSQL, so an invoice can be answered with a query rather than a guess.
- Files behind signed URLs. Never a public bucket. That platform streams 500 MB drawing sets into S3 as pre-signed multipart uploads, hashes each one with SHA-256 to catch duplicates, and expires every download link.
- Migrations that are part of the release. Alembic against async SQLAlchemy, versioned with the code. A schema change nobody can repeat is an outage waiting for a Friday.
Kubernetes earns its place when there are more services than people to look after them, or when a customer's compliance requirement names it. Serverless earns its place for spiky work that tolerates a cold start, which is rarely the request path of an AI product, where the model call is already the slow part. Until one of those is true, the honest answer is a few containers, a proxy, a queue and good logs.
Five Questions From Every Scoping Call
Do we need multi-tenancy in the first version?
You need it in the data model. You may not need the operational machinery around it yet. A tenant column from day one costs nothing; adding one to a live schema with foreign keys and reports hanging off it costs a quarter.
Should the AI be in the same service as the application?
Separate it early, if only by queue. AI work scales on different hardware, fails in different ways and gets replaced more often than the rest of the product.
How do we price an AI feature?
Meter first, price second. Track tokens, calls and processing time per tenant from the first week, then set the plan once you know what a heavy customer actually looks like. A base subscription with usage on top of it is the shape most AI products settle into.
Do we need a separate vector database?
Usually not at the start. pgvector inside the PostgreSQL you already run keeps the scoping and the backups in one place, and the dedicated stores earn their keep later, at a scale most products never reach.
What does the first release have to include?
One AI capability that works, authentication, tenancy, metering and billing. That is a smaller list than most roadmaps and a bigger one than most MVPs.
Your First Two Weeks
Draw the tenant boundary and the role model. Decide where the AI runs and what it may read. Put a meter and a ceiling on the first AI call before it ships. Write the billing events into the schema even if nothing charges yet. Those four take a fortnight and save a rewrite.
If you want a second pair of eyes on that shape, we run free 30-minute consultations, and our scalable SaaS solutions page sets out what a build includes. Metaviz AI has been shipping products since 2020, and our average job feedback on Upwork is 4.99.
One for the comments: if you have shipped a multi-tenant product, which of the four did you leave until too late?

Comments
No comments yet. Be the first to share your thoughts.
Leave a comment