What is the architecture of a production MERN SaaS?
Six layers: (1) Routing and middleware in Express, handling tenant resolution on every request, JWT authentication, rate limiting per tenant, and Zod request validation. (2) Tenancy layer, enforcing data isolation based on the agreed pattern. (3) Billing layer, Stripe webhook handling, plan entitlement checks before feature access, and dunning state management. (4) Feature flag layer, evaluated in middleware before any handler executes. (5) Application layer, the core business logic in Express route handlers with Mongoose. (6) React frontend with Next.js, consuming the API and respecting tenant theming, feature visibility, and plan-tier access controls.