-
-
Notifications
You must be signed in to change notification settings - Fork 1
3. Multi‐Tenancy Approach
This starter project implements a single-database multi-tenant architecture using Angular 18 and Supabase. The approach isolates tenant data within separate schemas of a single database, ensuring data security and scalability.
-
Database Structure
- Single database with separate schemas for each tenant
- Tenant-specific tables in individual schemas
- Shared tables (e.g., 'tenants') in the public schema
-
Row-Level Security (RLS)
- Supabase RLS policies ensure data isolation between tenants
- Policies filter data based on tenant ID
-
Authentication and Authorization
- Supabase Auth for secure user authentication
- Role-Based Access Control (RBAC) for managing permissions within each tenant
-
TenantGuard
andTenantService
in Angular to enforce tenant-specific access
-
Tenant Isolation
- Users can only access data belonging to their assigned tenant
- Angular guards implemented to enforce isolation at the application level
-
Performance Optimization
- Indexing strategies for efficient tenant-specific queries
- Consideration for caching frequently accessed data
-
Scalability
- Database schema and application architecture designed for horizontal scaling
- Connection pooling for efficient database connection management
-
Custom Claims: While not used in this starter project, JWT custom claims can be utilized for storing tenant-specific information and enhancing access control.
-
Data Access: The combination of database schema isolation, RLS policies, and Angular guards ensures that users can only interact with data from their assigned tenant.
-
Extensibility: This starter project provides a foundation for building multi-tenant SaaS applications. You can extend the existing structure to accommodate your specific business requirements and additional features.
To begin using this multi-tenant starter:
- Review the database schema and RLS policies in Supabase
- Familiarize yourself with the
TenantGuard
andTenantService
implementations in the Angular codebase - Customize the tenant onboarding process as needed for your application
- Extend the RBAC system to match your specific permission requirements
Remember to thoroughly test the tenant isolation and access controls as you build upon this starter project.