Projects / SaaS Template

A production‑ready starter to launch SaaS apps fast: multi‑tenant, RBAC, theming, jobs, storage, payments, and observability out of the box.
Overview
The SaaS Template is the foundation I use to start new products without rebuilding plumbing. It ships opinionated defaults for multi‑tenant apps, role‑based access, design‑system theming, background jobs, object storage, and observability so I can focus on the domain from day one.
My role
Architected the stack, built the core modules, wrote docs and examples, and tuned DX for rapid scaffolding of new features.
Architecture & Stack
- Web: Next.js (App Router), TypeScript, React, shadcn/ui + Radix, Tailwind.
- Auth: Auth.js with JWT/session, organization & workspace models, RBAC.
- Data: Prisma + PostgreSQL, soft‑deletes, audit trails, seed & fixtures.
- Jobs: BullMQ + Redis (queues, retries, backoff) with a QueueScheduler.
- Storage: S3/MinIO adapter (presigned uploads, image processing pipeline).
- Email & Notifications: Provider‑agnostic adapter, templated emails, webhooks.
- Billing: Payment gateway abstraction with webhooks & dunning hooks (plug Stripe/Pagar.me/Mercado Pago).
- Observability: Structured logs, request tracing hooks, health endpoints.
- Theming: Token‑first design using CSS variables with OKLCH support; runtime theme switching (org‑level) via a
ThemeProviderwrapper.
Key features
- Multi‑tenant (org/workspace), invites, membership & roles.
- Feature flags and environment‑based config.
- File management with signed uploads and access policies.
- CLI scaffolds for resources (model, route, service, UI form) to speed up CRUDs.
- Internationalization (EN/PT) ready.
Developer Experience
Hot reload, strict TypeScript, ESLint/Prettier, Vitest, story‑driven UI examples, and a patterns catalog (forms, tables, pagination, dialogs, optimistic UI).
Challenges & solutions
- Tenant isolation: enforced at the Prisma layer (where + RLS‑ready schema) and service guards.
- Theme consistency: OKLCH tokens + semantic aliases to keep contrast accessible.
- Webhook reliability: idempotency keys + outbox pattern via BullMQ.
Outcomes
- Reduced project setup from days to hours and enabled consistent quality across products.
Next
Add code‑mods to migrate between template versions, plus starter recipes (subscriptions, usage‑based billing, org branding).
SaaS Template
https://saas-template.nook-studio.com.br
Results
+60% increase in productivity
+80% reduction in operating cost
Days-to-hours setup time


