Marketplace Backend
This document describes the backend implementation of the Community Marketplace, focusing on database schema, ownership patterns, install tracking, and the approval workflow. The marketplace allows users to discover and install pre-built agents, recipes, LLM models, and other components from a central repository.
For information about browsing and installing items from the frontend, see Browsing & Installing Items. For publishing workspace items to the marketplace, see Publishing to Marketplace. For API endpoint specifications, see Marketplace API Reference.
Database Schema
The marketplace uses an ownership pattern rather than separate tables. Marketplace items are stored in the same tables as workspace items (agents, workflow_templates, etc.), differentiated by the owner_type column. This design enables code reuse and simplifies the cloning process.
Core Fields
Every marketplace-enabled table includes these columns:
owner_type
VARCHAR
Either 'marketplace' or 'workspace'
owner_id
VARCHAR
Workspace ID for workspace items, NULL for marketplace
workspace_id
UUID
NULL for marketplace items, workspace UUID for workspace items
is_approved
BOOLEAN
Admin approval status for marketplace items
is_featured
BOOLEAN
Whether item appears in featured section
install_count
INTEGER
Number of times installed (marketplace items only)
cloned_from_id
INTEGER
Reference to marketplace item this was cloned from
original_creator_id
INTEGER
DB user ID of original creator
marketplace_category
VARCHAR
Display category (e.g., "Customer Support", "DevOps")
marketplace_icon
VARCHAR
Icon URL or emoji for marketplace display
version
VARCHAR
Semantic version string (e.g., "1.0.0")
tags
JSONB
Array of tags for filtering
Sources: orchestrator/api/marketplace.py:35-80, orchestrator/api/marketplace.py:469-580
Owner Type Pattern
The owner_type field enables a single table to store both marketplace and workspace items. This pattern appears throughout the codebase for multi-tenant isolation.
Marketplace Items
When querying marketplace items, the filter is:
Admin users can see unapproved items (is_approved = FALSE) for moderation purposes.
Workspace Items
Workspace items are isolated by workspace_id in all queries, ensuring multi-tenant security.
Sources: orchestrator/api/marketplace.py:122-231, orchestrator/api/marketplace.py:468-580
Install Flow
When a user installs a marketplace item, the backend creates a workspace-owned copy and records the installation in the marketplace_installs table.
Installation Sequence
Clone Logic
The cloning process copies the item's configuration while swapping ownership fields:
Key behaviors:
Name collision handling: If an agent named "Sales Assistant" already exists in the workspace, the clone is named "Sales Assistant-copy"
Skills copying: For agents, the
skillsmany-to-many relationship is copied directly (skills are shared globally, not workspace-isolated)Tool assignments: Tool assignments are NOT automatically copied—users must reconnect tools in their workspace
Version snapshot: The installed version is recorded for update detection
Sources: orchestrator/api/marketplace.py:468-580
Install Tracking Table
The marketplace_installs table records every installation for analytics and update checking.
Schema
Update Detection
The system detects available updates by comparing installed version against current marketplace version:
This query powers the GET /api/marketplace/updates endpoint, which returns items where installed_version < latest_version.
Sources: orchestrator/api/marketplace.py:645-696
Querying Marketplace Items
The GET /api/marketplace/items endpoint supports filtering and pagination across multiple item types.
Query Parameters
type
str
Filter by type: 'agent', 'recipe', 'skill', 'llm', 'tool'
category
str
Filter by marketplace category
search
str
Search in name and description (case-insensitive ILIKE)
featured
bool
Show only featured items
limit
int
Max results (1-100, default 50)
offset
int
Pagination offset
Cross-Type Queries
When type is None, the endpoint queries both agents and workflow_templates tables and combines results:
This approach ensures global pagination when browsing "All Items" rather than per-table pagination.
Sources: orchestrator/api/marketplace.py:122-308
Response Enrichment
The API enriches marketplace items with additional metadata for frontend display.
Agent Response
Tool names and icons are fetched via a JOIN with composio_apps_cache:
This provides the frontend with visual tool indicators without additional API calls.
Recipe Response
Sources: orchestrator/api/marketplace.py:180-231, orchestrator/api/marketplace.py:260-296
Featured Items
Featured items are admin-curated and displayed prominently in the marketplace homepage. The is_featured flag is set manually by admins.
Featured Query
The GET /api/marketplace/featured endpoint returns up to 8 (configurable) featured items sorted by popularity.
Admin Controls
Admins can toggle featured status via the POST /api/marketplace/items/:id/feature endpoint (not shown in provided files, but referenced in frontend). The flag is stored directly in the is_featured column.
Sources: orchestrator/api/marketplace.py:587-638
Approval Workflow
Items submitted to the marketplace start with is_approved = FALSE and are invisible to non-admin users until approved.
Admin Check
The is_admin() helper determines if a user has admin privileges:
Users with system_role = 'admin' in the users table can:
View unapproved items (
is_approved = FALSE)Approve items via POST /api/marketplace/items/:id/approve
Delete items via DELETE /api/marketplace/items/:id
Toggle featured status
Sources: orchestrator/api/marketplace.py:36-47, orchestrator/api/marketplace.py:122-158
Submission Process
Users submit workspace items to the marketplace via POST /api/marketplace/items/submit (endpoint implementation not shown in provided files, referenced in Publishing to Marketplace).
The submission process:
Duplicate item: Create a copy with
owner_type = 'marketplace'andis_approved = FALSESet creator: Record
original_creator_idfrom current userMetadata: Copy category, tags, and configuration from workspace item
Link: Set
cloned_from_idon marketplace copy to reference workspace original
After approval, the item appears in marketplace listings with install_count = 0.
Item Detail Endpoint
The GET /api/marketplace/items/:id endpoint returns enriched details including dependencies.
Agent Detail
This detailed view is used by MarketplaceItemModal on the frontend to show full configuration before installation.
Sources: orchestrator/api/marketplace.py:315-428
Statistics and Analytics
The marketplace tracks key metrics for display:
Total Items
COUNT(*) WHERE owner_type='marketplace' AND is_approved=TRUE
Featured Count
COUNT(*) WHERE is_featured=TRUE
Total Installs
SUM(install_count) across all marketplace items
Categories
COUNT(DISTINCT marketplace_category)
These are computed on-demand by the frontend's fetchStats() function, which queries GET /api/marketplace/items?limit=100 and aggregates locally.
For production systems with large catalogs, these metrics should be cached in Redis or precomputed.
Sources: frontend/components/marketplace/marketplace-homepage.tsx:54-70
LLM Marketplace
LLM models are seeded into the marketplace via the seed_llm_marketplace.py script. These are treated as read-only marketplace items:
The script inserts models into a marketplace_items table (not shown in provided schema—may be an older implementation) or uses a similar pattern with owner_type = 'marketplace'.
Note: The provided code shows models being stored in marketplace_items table, but the main API endpoints query agents and workflow_templates. This suggests LLM marketplace may use a separate table or be in transition.
Sources: orchestrator/scripts/seed_llm_marketplace.py:1-101
Multi-Table Architecture
The marketplace spans multiple tables with consistent owner_type patterns:
Each item type implements:
owner_typedifferentiationcloned_from_idtrackinginstall_countincrementingis_approvedgatingis_featuredcuration
Sources: orchestrator/api/marketplace.py:1-820
Last updated

