The Diginexus Multi-Tenant Platform Architecture
How our edge-rendered Next.js monorepo orchestrates multi-subdomain routing, automated DNS assignment, and isolated PostgreSQL tenant storage.
Multi-Surface Monorepo Routing
Next.js 15 App Router1. Edge Middleware Host Rewrites (`middleware.ts`)
Every incoming HTTP request hits Vercel Edge Middleware before entering the server components tree. The middleware strips port numbers, inspects the hostname header, and rewrites the request internally to the target route group without redirect latency or URL alteration.
2. PostgreSQL Schema & Row Level Security (RLS)
Data security is enforced directly at the database engine layer via Supabase Row Level Security. Even if an attacker executes arbitrary SQL via the client SDK, the PostgreSQL engine validates `auth.uid() = owner_id`, rendering unauthorized cross-tenant data access mathematically impossible.
3. Automated Custom Domain Provisioning (Vercel REST API)
When a customer enters `theirbusiness.com` in their portal, our server action calls `POST https://api.vercel.com/v10/projects/[projectId]/domains`. The system generates instructions for an A Record pointing to `76.76.21.21` and CNAME to `cname.vercel-dns.com`. Real-time polling verifies DNS propagation and issues Let's Encrypt SSL certificates automatically.