, 1 min read, by Achoai Team
Shipping SaaS faster
Three battles you can stop fighting when your boilerplate already solved them — and where to spend the time you saved.
Every SaaS dev hits the same three walls early. Most kill momentum. Here's how Achoai defuses each one.
1. The multi-tenant migration
Adding orgs and teams late is brutal. Every query needs a WHERE organizationId = ?, every dashboard needs a switcher, every test fixture needs a tenant. We ship withTenant() plus Postgres RLS with FORCE ROW LEVEL SECURITY from day one — the wrong query just returns nothing.
2. The Stripe webhook spaghetti
Better Auth's Stripe plugin handles subscription lifecycle, but invoice events (invoice.payment_failed, invoice.payment_action_required) are on a separate endpoint with its own secret. Idempotency is enforced via a processed_webhooks table so retries don't double-charge anything.
3. The AI token bill of pain
streamText is one line. Costs are not. We instrument every AI call with experimental_telemetry (auto-exported to Langfuse) and enforce a rolling 30-day token cap per organization. When you hit pro 5M tokens, the API responds 429 before you spend $200 by accident.
Bonus: the deploy story
Dokploy in production: the API and the site deploy with no downtime, and the scheduler runs on its own. Migrations run in CI. Done.