A practical architecture guide for teams building B2B SaaS products with Next.js, organizations, roles, billing, audit logs, and admin workflows.
B2B SaaS architecture is mostly about avoiding expensive changes later. The first version can be simple, but the foundation needs room for teams, billing, support, compliance, and enterprise requests.
This is the baseline architecture we recommend before launch.
Even if the first buyer is a single founder, create an organization record. A user can own or belong to one or more organizations, and product data belongs to the organization.
That gives you a clean path for:
Do not attach every important record directly to userId unless it is truly personal.
There are two different permission systems:
An admin support user may be a platform admin without being a member of every customer organization. A customer owner may control billing and members for one organization without seeing platform admin screens.
Keep those concepts separate.
Subscription records should be able to point at the paying organization. A B2B customer may have many users, but one billing relationship.
The subscription layer should store:
This lets your app render billing state without calling the payment provider on every request.
Screenshot placeholder: billing screen with enterprise plan, seat count, and renewal date.
Customer-facing product screens are not enough. You need internal tools for:
If support has to query the database manually, your product is not ready for scale.
Audit logs do not need to capture every click. Start with actions that affect security, billing, permissions, and customer data:
Add metadata, IP address, actor, resource, and timestamp. That is enough for many support and compliance questions.
Feature flags are not only for experiments. They protect launches.
Use flags for:
Every flag should have a name, description, enabled state, and rollout percentage.
If your SaaS sends events to customers or receives billing provider events, you need delivery records.
Track:
Webhook failures are normal. Invisible webhook failures become support incidents.
For B2B SaaS, product analytics should answer organization-level questions:
Store organizationId on events when possible. User-level analytics alone is not enough.
A strong B2B SaaS starter has a clear spine:
That architecture is still lean, but it will survive the first enterprise customer.