Skip to content

nestarcProduction-ready NestJS modules for SaaS backends

Multi-tenancy, audit logs, feature flags, and more — built on Prisma & PostgreSQL

Why nestarc?

Every multi-tenant SaaS backend needs the same six features. Building them from scratch takes weeks and introduces subtle bugs. nestarc solves them once, correctly.

Tenant Isolation
One misconfigured query leaks customer data across tenants.
PostgreSQL RLS enforces isolation at the database level.
Audit Trail
Manually logging every write is tedious and easy to forget.
Prisma extension auto-tracks CUD with before/after diffs.
Feature Flags
External flag services add latency, cost, and a new dependency.
DB-backed flags with tenant overrides and percentage rollouts.
Soft Delete
deletedAt alone breaks unique constraints and leaks deleted records.
Prisma extension with cascade, restore, and query filtering.
Pagination
Implementing cursor + offset with filters is boilerplate-heavy.
12 filter operators, sorting, and Swagger docs out of the box.
Response Format
Inconsistent API envelopes across endpoints frustrate frontend teams.
Auto-wrapped responses with error codes, pagination, and i18n.

Without nestarc

typescript
// Scattered across 50+ services, easy to forget, hard to audit
async updateUser(id: string, dto: UpdateUserDto) {
  const before = await this.prisma.user.findUnique({ where: { id } });
  await this.prisma.$executeRaw`SELECT set_config('app.current_tenant', ${tenantId}, true)`;
  const after = await this.prisma.user.update({ where: { id, deletedAt: null }, data: dto });
  await this.auditService.log({ action: 'user.update', before, after });
  return { success: true, data: after, timestamp: new Date() };
}

With nestarc

typescript
// Tenant isolation, audit logging, soft-delete filtering, and response wrapping
// are all handled automatically by Prisma extensions and NestJS interceptors.
async updateUser(id: string, dto: UpdateUserDto) {
  return this.prisma.user.update({ where: { id }, data: dto });
}

Build a complete multi-tenant API in 30 minutes.

Full TutorialQuick Start (5 min)

Released under the MIT License.