PRD-37: SaaS Foundation - Authentication, Workspaces & Billing

Version: 2.0 Status: 🟡 Planning Phase Date: January 20, 2026 Author: DeepAgent Prerequisites: None (Foundation Layer) Blocks: PRD-36 (Composio Integration)


Executive Summary

This PRD establishes the foundational SaaS infrastructure for Automatos using a simplified workspace model:

  1. Clerk Authentication - User auth, SSO, MFA, organizations

  2. Clerk Billing - Subscription plans and payments (beta, ready by launch)

  3. Workspaces - Auto-created on signup, team member invites

  4. Usage Tracking - Token and tool call logging

  5. API Keys - For widget/embed integration

Architecture Decision

Every user gets their own workspace on signup:

  • Solo users → Personal workspace (Starter plan)

  • Small business → Team workspace with members (Business plan)

  • Enterprise → Large team workspace (Enterprise plan)

Key Simplifications from v1.0

v1.0 (Complex)
v2.0 (Simplified)

Tenants → Multi-tenant

Workspaces → Simple

4 roles (owner/admin/member/viewer)

2 roles (owner/member)

Stripe + webhooks

Clerk Billing (unified)

Sub-organizations

Removed (future)

Per-seat billing

Flat plan pricing

Timeline

~9 days implementation (down from 14 days)


Table of Contents


Architecture

User Flow

Data Model

Pricing Plans

Plan
Price
Target
Limits

Starter

Free or $9/mo

Solo users

3 agents, 10 workflows, 5 docs

Business

$29/mo

Small teams

10 agents, 50 workflows, 10 members

Enterprise

$99/mo

Large teams

Unlimited, priority support


Database Schema

New Tables (Add to init_complete_schema.sql)

Migration File

Create: orchestrator/core/database/migrations/037_saas_foundation.sql


Backend Implementation

Requirements.txt Additions

Core Modules

Clerk JWT Verification

Request Context

Workspace Service

Usage Tracking


Frontend Implementation

Package.json Additions

Clerk Setup

API Client with Auth

Workspace Context


Clerk Billing Setup

Clerk Dashboard Configuration

When Clerk Billing is available:

  1. Create Plans in Clerk Dashboard:

    • Starter: $9/mo (or free tier)

    • Business: $29/mo

    • Enterprise: $99/mo

  2. Configure Features per Plan:

  3. Enable Billing Portal for self-service upgrades

Sync Plan to Backend

Fallback: Minimal Stripe (if Clerk Billing delayed)

If needed before Clerk Billing GA, implement minimal Stripe:


Implementation Roadmap

Phase 1: Clerk Auth (Days 1-2)

Phase 2: Workspaces (Days 3-4)

Phase 3: Team Members (Days 5-6)

Phase 4: API Keys & Usage (Days 7-8)

Phase 5: Polish & Deploy (Day 9)


Environment Variables


Success Metrics

Metric
Target

Auth Success Rate

> 99.9%

Workspace Creation

< 500ms

API Key Validation

< 20ms

Data Isolation

100%


Dependencies for PRD-36

After PRD-37, Composio can use:


Document Version History

Version
Date
Author
Changes

1.0

2026-01-20

DeepAgent

Initial PRD (complex)

2.0

2026-01-20

DeepAgent

Simplified: workspaces, Clerk billing, 2 roles

Last updated