Implementation Plan: Recipes Marketplace
Overview
Migrate Workflow Recipes to use the same single-table marketplace architecture as Agents. Currently, recipes exist in workflow_templates table but lack marketplace fields (owner_type, workspace_id, cloning tracking).
Current State
✅ Database model exists (
WorkflowTemplateclass)✅ API endpoints exist (
/api/workflow-recipes)✅ Frontend components exist (recipes-tab, marketplace-recipes-tab)
❌ MISSING: workspace_id, owner_type, marketplace fields
❌ MISSING: Share to Marketplace functionality
❌ MISSING: Install from Marketplace functionality
⚠️ BUG: API already filters by workspace_id (line 52 of workflow_recipes.py) but field doesn't exist in model!
Implementation Steps
1. Database Migration
File: orchestrator/alembic/versions/20260201_add_marketplace_to_recipes.py
Add marketplace fields to workflow_templates table:
workspace_id(UUID, FK to workspaces.id, nullable) - NULL for marketplace, user's workspace for workspace recipesowner_type(VARCHAR(20), default='workspace') - 'workspace' or 'marketplace'owner_id(VARCHAR(255)) - workspace_id for workspace recipes, 'marketplace' for marketplace recipescloned_from_id(Integer, FK to workflow_templates.id) - Tracks clone sourceoriginal_creator_id(Integer, FK to users.id) - Original creatorcreated_by_user_id(Integer, FK to users.id) - User who created this instanceinstall_count(Integer, default=0) - Marketplace install counteris_approved(Boolean, default=false) - Approval status for marketplace itemsmarketplace_category(VARCHAR(100)) - Marketplace-specific categorymarketplace_icon(VARCHAR(500)) - Icon URL for marketplacerecipe_type(VARCHAR(20), default='complex') - 'simple' or 'complex'
Indexes:
idx_recipes_owner_typeon (owner_type, is_approved)idx_recipes_marketplace_featuredon (is_featured, install_count) WHERE owner_type='marketplace'idx_recipes_marketplace_categoryon (marketplace_category) WHERE owner_type='marketplace'idx_recipes_workspaceon (workspace_id, owner_type)
Data Migration:
2. Update Model
File: orchestrator/core/models/core.py (lines 1026-1109)
Add to WorkflowTemplate class:
All new field definitions
Relationships:
cloned_from,original_creator,created_by_userProperty:
is_marketplace_itemreturnsself.owner_type == 'marketplace'Update
to_dict()to include new fields
3. Update API Endpoints
File: orchestrator/api/workflow_recipes.py
Update existing endpoints:
list_workflow_recipes(line 25): Change filter toowner_type='workspace'ANDworkspace_id=ctx.workspace_idget_workflow_recipe(line ~107): Add owner_type filtercreate_workflow_recipe(line ~132): Set owner_type='workspace', workspace_id, owner_idAll other endpoints: Add owner_type filtering
Add new marketplace endpoints:
Update marketplace.py:
Update
list_itemsendpoint to query recipes where owner_type='marketplace'Return recipe items with type='recipe'
4. Frontend Changes
File: frontend/components/workflows/recipes-tab.tsx
Add "Share to Marketplace" button:
File: frontend/components/marketplace/marketplace-recipes-tab.tsx
Add Install functionality:
File: frontend/lib/api-client.ts
Add methods:
File: frontend/hooks/use-recipe-api.ts
Add hooks:
5. Testing Strategy
Backend Tests:
Create workspace recipe with owner_type='workspace'
Submit to marketplace (trusted user → is_approved=true)
Submit to marketplace (untrusted user → is_approved=false)
Install from marketplace (verify clone created in workspace)
Install with dependencies (verify auto-clone)
Name collision handling (verify " (Copy)" suffix)
Frontend Tests:
Share button calls submit mutation
Install button calls install mutation
Success/error toasts display correctly
Warnings for missing dependencies display
Manual Testing:
Critical Files
Backend
orchestrator/alembic/versions/20260201_add_marketplace_to_recipes.py- NEW migrationorchestrator/core/models/core.py(lines 1026-1109) - Update WorkflowTemplate modelorchestrator/api/workflow_recipes.py- Add submit/install endpoints, update existingorchestrator/api/marketplace.py(line 97+) - Add recipe support to list_items
Frontend
frontend/components/workflows/recipes-tab.tsx- Add Share buttonfrontend/components/marketplace/marketplace-recipes-tab.tsx- Add Install buttonfrontend/lib/api-client.ts- Add submit/install methodsfrontend/hooks/use-recipe-api.ts- Add marketplace hooks
Clone-with-workspace_id Pattern
Workspace Recipe (user-created):
Marketplace Recipe (shared):
Installed Recipe (cloned from marketplace):
Verification
After implementation:
Create a workspace recipe
Submit to marketplace (verify in DB: owner_type='marketplace', workspace_id=NULL)
Install from marketplace (verify clone created with owner_type='workspace', workspace_id set)
Check install_count incremented on marketplace recipe
Verify marketplace_installs table has record
Test dependency auto-clone (recipe with agent dependencies)
Test name collision handling
Deployment Steps
Backup database
Run migration:
alembic upgrade headVerify indexes created
Deploy backend code
Deploy frontend code
Verify existing recipes still work
Test marketplace flow end-to-end
Monitor logs for errors
Last updated

