Data Vanta – Multi-Tenant Installment Business Management SaaS

A production-grade multi-tenant SaaS designed to enforce financial logic at the database layer — eliminating race conditions, cross-tenant leakage, and subscription bypass risks.

Next.js 15
Supabase (Postgres + RLS)
Production SaaS
Role-based access
Normalized financial schema

Production traits:

Transaction-safe
Race-condition resistant
Multi-tenant secure
DB-enforced business rules

Product Overview

What problem it solves

  • Track installments in Excel
  • Manually calculate profit
  • No real-time cash ledger visibility
  • No tenant-level isolation
  • Cannot enforce subscription-based limits

Data Vanta solves this with

  • Automated profit tracking
  • Cash ledger automation
  • Installment lifecycle tracking
  • Subscription-based limits enforcement
  • Secure multi-tenant isolation

System Architecture

Architecture stack

Frontend

  • Next.js 15 (App Router)
  • Server Actions
  • Optimistic UI updates

Backend

  • Supabase Postgres
  • Security definer RPC functions
  • Row Level Security (RLS)
  • Strict tenant_id scoping

Key design decisions

  • All financial transactions stored in cash_ledger
  • Installments are immutable financial events
  • Profit stored at installment creation (not computed live)
  • Subscription limit enforced at DB level
  • No business logic on client

Why Business Logic Is Enforced at Database Level

  • Client-side validation can be bypassed
  • API-level checks fail under race conditions
  • Only transactional DB-level enforcement guarantees integrity
  • RLS prevents privilege escalation

Core Features

Installment plans engine

Create plans with total price + profit; auto-generate installments; track due / paid / pending; enforced subscription limit at creation.

Cash ledger system

Every financial movement generates a ledger entry. Types: OWNER_INVESTMENT, OWNER_WITHDRAWAL, PRINCIPAL_DEPLOYED, INSTALLMENT_PAYMENT, ADJUSTMENT. Ledger-first architecture for an auditable system.

Multi-tenant security

tenant_id on every table; RLS policies enforce isolation; no cross-tenant leakage; security definer functions prevent privilege escalation.

Dashboard

Total deployed capital, profit paid vs profit due, upcoming installments, cash flow overview.

Ledger-First Financial Architecture

  • All financial events are immutable
  • Dashboard aggregates derive from ledger
  • No recalculated balances
  • Audit-ready model

Technical Challenges & Solutions

Problem

Parallel requests bypassing subscription limits.

Solution

  • Row locking inside a security definer function
  • Active subscription validation inside the same transaction
  • P0001 error returned for invalid cases

This demonstrates database concurrency control and safe limit enforcement at the data layer.

Performance & SEO

  • Target 100% PageSpeed where applicable
  • Edge rendering where required
  • Server components to reduce client JS
  • Minimal heavy client state

Business Impact

  • Eliminates spreadsheet-based reconciliation workflows
  • Prevents subscription limit bypass under parallel requests
  • Guarantees tenant data isolation via RLS
  • Provides auditable financial ledger model

Application Screenshots

Dashboard with total deployed capital, profit paid vs due, and cash flow overview.

Installment plans with total price and profit; subscription limit enforced at creation.

Installment lifecycle view with enforced payment state transitions.

Capital overview and ledger-backed aggregates.