S
Sheba ISP ERPDOCS
Backend Modules

apps.core — Multi-Tenancy & Platform Foundation

Architectural foundation managing tenant resolution, domains, audit logging, and the SaaS control plane.

apps.core — Multi-Tenancy & Platform Foundation

IMPLEMENTED

  • Location: backend/apps/core/
  • Responsibilities: Tenant resolution, domain routing, company settings, audit logging, distributed locking, and SaaS control plane operations.
  • Non-responsibilities: Business-specific billing logic, subscriber provisioning, or direct router communication.

1. Database Models (10 Models)

Model NamePurposeKey FieldsNullable / Constraints
TenantPrimary multi-tenant organization entityname, subdomain, is_active, tier, created_atsubdomain is unique
TenantDomainMaps external domains / subdomains to a Tenantdomain, tenant, is_primary, is_activedomain is unique
TenantApiTokenMachine-to-machine API tokens for tenant servicestenant, token, is_active, created_attoken is unique
CompanySettingKey-value settings per tenant (branding, ISP profile)tenant, company_name, logo, support_phoneOne record per tenant
AuditLogAppend-only system audit trailtenant, actor_username, action, module, detailsIndexed by timestamp & tenant
TenantOnboardingRequestSelf-service ISP onboarding requestsorg_name, contact_email, status, notesStatus: PENDING, APPROVED, REJECTED
SaaSPackageSaaS subscription plans (e.g. Starter, Pro, Enterprise)name, price_monthly, max_subscribers, featuresUnique plan name
TenantSubscriptionActive SaaS subscription for a Tenanttenant, package, start_date, end_date, statusOne active subscription per tenant
SaaSPaymentBilling records for tenant platform usagesubscription, amount, payment_method, trx_idUnique trx_id
DatabaseBackupBackup metadata and storage URLstenant, filename, file_size, status, created_atTrack backup status

2. Controllers & API Endpoints

  • GET/POST /api/v1/tenants/: CRUD for tenants (SaaS SuperAdmin only).
  • GET/POST /api/v1/tenant-domains/: Domain mapping and verification.
  • GET/PATCH /api/v1/settings/: Company branding and operational configurations.
  • GET /api/v1/audit-logs/: Auditable search logs for security compliance.
  • POST /api/v1/saas/auth/login/: Dedicated SaaS control plane login.
  • GET /api/v1/saas/overview/: SuperAdmin aggregated tenant health and MRR.

On this page