Agency Client Workspaces
1. Purpose & Context (The âWhyâ)
-
Goal: Create and configure client workspaces. Crucial for Agencies managing multiple clients.
-
Feature References:
-
User Journey: Agency signs up â Creates Workspace for âClient Aâ â Invites Client A users.
2. UI Patterns & Components (The âHowâ)
-
Core Components:
-
CardGrid: Visual list of workspaces with health status. -
Modal: For âCreate Workspaceâ flow. -
Tabs: For Workspace Settings (General, Members, Billing).
-
-
Analytics Patterns:
DataCard: âClient Healthâ summary on the card (e.g., â 3 Active Campaignsâ).
-
Layout: Global Context.
3. Route Specifications
| Route | Access | Purpose | State/Data Requirements |
|---|---|---|---|
/dashboard/workspaces | Tenant/Agency | Workspace List | Server Component. List of all accessible workspaces. Agency view shows aggregated stats (Total Revenue, Active Clients). |
/dashboard/workspaces/new | Tenant/Agency | Create Workspace | Client Component. Form: Name, Logo, Plan selection (if separate billing). |
/dashboard/workspaces/[slug]/settings | Admin | Workspace Config | Settings for the specific workspace. Rename, Delete, Transfer Ownership. |
4. Detailed View Descriptions
/dashboard/workspaces - Workspace Command Center
User Story: âAs an agency owner, I want a birdâs-eye view of all my client workspaces with health indicators, so I can proactively manage accounts.â
What Youâll Find:
For Agencies (Multi-Workspace):
-
Header Stats Row (see Analytics UI Patterns):
- DataCards: Total Clients, Active Campaigns (across all), Total Emails Sent (MTD), Aggregated Reply Rate.
-
Workspace Grid:
-
Each Workspace Card Shows:
-
Client Logo (uploaded or initials fallback).
-
Workspace Name.
-
Health Score (0-100):
-
â 90-100: Green âHealthyâ.
-
âť ï¸ 70-89: Yellow âNeeds Attentionâ.
-
â <70: Red âCriticalâ.
-
-
Quick Stats: â3 Active Campaignsâ, â1,200 Leadsâ, â42% Open Rateâ.
-
âView Workspaceâ Button: Navigates to
/dashboard/workspaces/[slug].
-
-
-
Actions:
-
â+ New Workspaceâ Button (top-right).
-
Sort Dropdown: By Name, Health Score, Campaign Count.
-
For Single-Tenant Users:
- Simplified View: Shows single workspace card or skips directly to workspace dashboard.
User Journey Context: Agency dashboard. Daily check-in for client health monitoring.
Related Documentation:
Technical Integration:
-
Aggregated Metrics: Fetched from OLAP database with 1-hour cache.
-
Health Score Calculation: Based on campaign activity, deliverability, reply rates.
/dashboard/workspaces/new - Create Workspace
User Story: âAs an agency, I want to quickly onboard a new client by creating a dedicated workspace, so they have isolated campaigns and settings.â
What Youâll Find:
-
Modal or Full-Page Form:
-
Workspace Name: Input field (âe.g., Acme Corpâ).
-
Logo Upload: Drag-and-drop or file picker (optional).
-
Subdomain/Slug:
-
Auto-generated from name: âacme-corpâ.
-
Editable (with validation for uniqueness).
-
-
Plan Selection (if applicable):
-
Radio buttons: Starter, Pro, Enterprise.
-
Shows pricing and feature comparison.
-
-
-
Actions:
-
âCreate Workspaceâ Button: Creates workspace and redirects to
/dashboard/workspaces/[new-slug]. -
âCancelâ Button: Closes modal.
-
User Journey Context: Onboarding new clients. Must be fast (<1 minute to complete).
Related Documentation:
Technical Integration:
-
Async Creation: Workspace provisioned via background job (creates DB schemas, default settings).
-
Webhook: Triggers notification to admin users.
/dashboard/workspaces/[slug]/settings - Workspace Settings
User Story: âAs a workspace admin, I want to manage workspace details, team members, and billing, so I can maintain control over the account.â
What Youâll Find:
Tabbed Interface:
Tab 1: General
-
Workspace Name: Editable input.
-
Logo: Upload/change logo.
-
Slug: Display only (cannot change after creation).
-
Danger Zone:
-
âDelete Workspaceâ Button: Red button with confirmation modal.
- Warning: âThis will permanently delete all campaigns, leads, and data.â
-
Tab 2: Members
-
Members Table:
-
Columns: Name, Email, Role, Status, Actions.
-
Roles: Owner, Admin, Member.
-
Status: Active, Invited (pending).
-
-
âInvite Memberâ Button:
-
Opens modal with Email + Role selector.
-
Sends invitation email with magic link.
-
-
Row Actions: Change Role, Remove (cannot remove self).
Tab 3: Billing (if workspace has separate billing)
-
Current Plan: Shows plan name and limits.
-
âUpgrade Planâ Button: Redirects to billing flow.
-
Billing Contact: Email for invoices.
User Journey Context: Infrequent access for account maintenance.
Related Documentation:
Technical Integration:
-
RBAC: Only Owners/Admins can access this page.
-
Stripe Integration (if workspace billing):
- Customer portal link for payment method updates.
Workspace Health Score Calculation
User Story: âAs an agency, I want to understand what contributes to workspace health, so I can improve client outcomes.â
Health Score Factors (Weighted Average):
-
Campaign Activity (30%):
-
Active campaigns vs. total campaigns.
-
Recent campaign sends.
-
-
Deliverability (40%):
-
Bounce rate < 5%.
-
Spam complaint rate < 0.1%.
-
-
Engagement (20%):
-
Open rate > 20%.
-
Reply rate > 5%.
-
-
System Health (10%):
-
DNS records verified.
-
Email accounts not blacklisted.
-
Display:
-
Score shown on workspace card and in workspace dashboard header.
-
Tooltip: âHealth Score factors: Deliverability, Engagement, Activity.â
Related Documentation:
Workspace Context Switching (Revisited)
User Story: âAs an agency user working across multiple clients, I want seamless context switching, so I donât lose my workflow.â
Mechanism (as described in Core App Structure):
-
Context Switcher in Sidebar: Dropdown showing current workspace.
-
Quick Switch: Click to change, updates URL and sidebar nav.
-
Persistence: Last workspace stored in localStorage.
Workspace-Specific State:
-
Campaigns, Templates, Domains, Settings all scoped to selected workspace.
-
Global views (Inbox, Leads) aggregate across accessible workspaces.
Related Documentation:
5. Related API Endpoints
| Route | Related API | Description |
|---|---|---|
/workspaces | Workspaces API | GET /api/v1/tenant/workspaces (List), POST (Create). |
/workspaces/[slug] | Workspaces API | GET /api/v1/tenant/workspaces/{id} (Details & Stats). |
/workspaces/[slug]/settings | Workspaces API | PATCH /api/v1/tenant/workspaces/{id} (Update settings). |
/workspaces/[slug]/members | Workspaces API | POST /api/v1/tenant/workspaces/{id}/members (Invite). |
6. Data Strategy
-
Fetching Method:
-
Workspace List: Server Component.
-
Aggregated Stats: Fetched in parallel with list.
-
-
Caching:
-
Workspace List: Cached for 1 minute.
-
Health Scores: Cached for 1 hour (computed via background job).
-
-
Optimistic Updates:
- âCreate Workspaceâ adds card to grid immediately (with loading state while provisioning).
7. Edge Cases & Error Handling
-
Slug Collision: If auto-generated slug exists, append number (e.g.,
acme-corp-1). -
Creation Failure: If background provisioning fails, show error on card and âRetryâ action.
-
Last Admin: Cannot remove self if you are the only admin.
-
Delete Workspace: Requires typing workspace name to confirm (destructive action).
8. Component Architecture
Page Components
-
WorkspaceGrid(Server)-
Props:
workspaces: Workspace[] -
Sub-components:
WorkspaceCard(with stats sparklines).
-
-
MemberInviteForm(Client)-
Props:
workspaceId: string -
Features: Multi-email input, role selector.
-
-
SettingsForm(Client)-
Props:
initialValues: WorkspaceSettings -
Features: Logo upload (Drag & Drop), dirty state tracking.
-
Shared Components
-
RoleBadge: Reused in Team Settings and Admin Users. -
Sparkline: Reused in Workspace Card and Dashboard.