Multi Workspace
Manage multiple workspaces, members, roles, settings, and invitations in your application.
This template supports multi-tenant architecture, allowing users to create and belong to multiple workspaces simultaneously, each with its own members, settings, and resources.
Workspace Overview
Multi-tenancy
Our platform supports multi-workspace management, allowing users to create and belong to multiple workspaces simultaneously. Each workspace functions as a separate environment with its own members, settings, and resources.
Workspace Schema
Database schema for workspaces:
Key Features
Multiple Workspaces
🏢 Users can create and join multiple workspaces, each with separate settings and members
Role-Based Access
🔑 Granular permission system with customizable roles for different access levels
Member Management
👥 Add, remove, and manage workspace members with different permission levels
Invitation System
✉️ Secure email-based invitation system for adding new members to workspaces
Workspace Management
Workspace operations are protected by authentication and authorization checks. Always verify permissions before performing sensitive actions like deleting workspaces or managing members.
Create Workspace
Create a new workspace with custom settings using tRPC:
Update Workspace
Modify workspace settings and details using tRPC:
Delete Workspace
Permanently delete a workspace and all its data using tRPC:
Transfer Ownership
Transfer workspace ownership to another member:
Update Workspace Logo
Update the workspace logo:
Member Management
Collaboration
The member management system allows workspace owners and admins to invite, remove, and manage the roles of workspace members.
Invite Members
Send email invitations to new members:
Change Member Role
Update a member's role and permissions:
Remove Member
Remove a member from the workspace:
Workspace Settings
Available Settings
General Settings
- Workspace name and slug
- Logo and branding
- Default member role
- Workspace visibility
Security Settings
- Invitation expiration time
- Required email domains
- Two-factor authentication
- Session management
Role Management
- Create custom roles
- Assign permissions to roles
- Modify existing roles
- Set default member role
Advanced Features
- Workspace transfer
- Data export/import
- API key management
- Audit logging
Technical Implementation
The multi-workspace system uses a combination of PostgreSQL tables with foreign key relationships to maintain data integrity. Each workspace has its own set of members, roles, and resources.
Database Schema
The multi-workspace system relies on several interconnected database tables:
Workspace Context with React Query
Access current workspace data in components:
TRPC Router Implementation
The workspace functionality is implemented using tRPC routers:
Best Practices
Security Considerations
- Always verify user permissions for workspace operations
- Implement rate limiting for invite operations
- Use transactions for operations that modify multiple tables
- Sanitize and validate all user inputs
Performance Optimization
- Use proper database indexes on workspace_id, user_id fields
- Cache frequently accessed workspace data
- Implement pagination for member lists in large workspaces
- Use optimistic updates for improved UX
Additional Resources
Authentication Integration
See the Authentication documentation for details on integrating workspace access with authentication.
Database Schema
Refer to the Database documentation for more information on the database schema.