Architecture & Multi-Tenancy · Backend · Interface· 8 min read
3-tier enterprise SaaS: Platform Admins, Reseller Consultancies, and Client Portals
Architecting a multi-tier B2B ecosystem. How to support Platform Admins, Layer 2 white-label reseller consultancies, and Layer 3 employer clients with custom branding, dynamic entitlements, and audit isolation.
SaaS ArchitectureNestJSMulti-TenancyWhite-LabelEntitlements
On this page
Standard B2B SaaS platforms assume a 2-tier relationship: SaaS Vendor and Customer Organization. In enterprise consultancy domains, such as Complete HR with HRMS Services, this model falls apart. The business requires a 3-tier hierarchy: Platform Owners (Tier 1), HR Consultancies / White-label Resellers (Tier 2), and Employer Client Organizations (Tier 3). Consultancies need their own branded portals to manage retained clients, while Platform Owners require universal governance without compromising tenant isolation.
The three-tier entity hierarchy
- Tier 1 (Platform Admin): Global oversight, global billing, infrastructure health, feature flag rollout, and cross-consultancy SLA monitoring.
- Tier 2 (Consultancy Reseller Workspace): Branded advisory workspace, retainer contracts, billable time-tracking, multi-client employee allocations, and quote generation.
- Tier 3 (Employer Client Organization): Self-service workforce portal, biometric attendance, leave requests, payroll previews, and document vaults.
export interface ScopedHierarchy {
platformId: string;
consultancyId?: string; // Set when operating within Tier 2 reseller
clientId?: string; // Set when operating within Tier 3 client
}
export function buildHierarchicalFilter(hierarchy: ScopedHierarchy) {
if (hierarchy.clientId) {
return { clientId: hierarchy.clientId };
}
if (hierarchy.consultancyId) {
return { consultancyId: hierarchy.consultancyId };
}
return {}; // Platform admin global scope
}Dynamic entitlement models: Software, Advisory, or Hybrid
In Complete HR, different client organizations subscribe under completely different commercial agreements. Client A might subscribe to HRMS Software Only (self-service attendance, leaves, payroll). Client B might purchase HR Advisory Services Only (retained consultancy hours, legal review, grievance investigations). Client C subscribes to a Combined Hybrid Suite. We designed an entitlement matrix where feature guards evaluate subscribed service modules before granting route execution.
@Injectable()
export class EntitlementGuard implements CanActivate {
constructor(private reflector: Reflector) {}
canActivate(context: ExecutionContext): boolean {
const requiredModule = this.reflector.get<string>('module', context.getHandler());
if (!requiredModule) return true;
const req = context.switchToHttp().getRequest();
const entitlements: string[] = req.tenant?.activeModules || [];
if (!entitlements.includes(requiredModule)) {
throw new ForbiddenException(
`Organization has not subscribed to module: ${requiredModule}`
);
}
return true;
}
}