B2B Partner Ecosystem
Relevant source files
The following files were used as context for generating this wiki page:
- supabase/migrations/20260606130100_ptr002_partner_organizations.sql
- supabase/migrations/20260606130200_ptr003_partners.sql
- supabase/migrations/20260606130500_ptr006_partner_drafts.sql
- supabase/migrations/20260606130800_ptr009_partner_assets_and_storage.sql
- supabase/seeds/partners.seed.sql
- src/lib/supabase/database.types.ts
The B2B Partner Ecosystem is a supply-side infrastructure designed to manage Medellín-based service providers, including hosts, venues, brokers, and agencies. It provides a centralized account management system that bridges diverse business verticals—such as events and short-term rentals—into the unified mdeai platform. Sources: README.md:1-10, supabase/migrations/20260606130200_ptr003_partners.sql:1-5
This ecosystem supports the full lifecycle of a partner, from initial onboarding through a guided signup wizard to active service provision and revenue tracking. It utilizes a multi-tenant architecture where individual user profiles can manage multiple partner accounts across different types. Sources: supabase/seeds/partners.seed.sql:10-15, supabase/migrations/20260606130500_ptr006_partner_drafts.sql:1-5
Core Architecture and Data Model
The ecosystem is built around the partners table, which serves as the primary supply-side account. Each partner is linked to a user profile and can optionally belong to a partner_organization for legal and tax purposes. Sources: supabase/migrations/20260606130200_ptr003_partners.sql:10-25, supabase/migrations/20260606130100_ptr002_partner_organizations.sql:8-15
Entity Relationships
The following diagram illustrates how partner accounts interface with organizational structures and specific supply-side profiles:
The data model uses specialized bridges to link partners to existing vertical-specific schemas, such as the landlord_profiles for rental brokers. Sources: supabase/migrations/20260606130200_ptr003_partners.sql:17-30, supabase/seeds/partners.seed.sql:85-90
Partner Classification
Partners are categorized into distinct types, defined by the partner_type enum. This allows the system to apply specific business logic and service availability based on the partner's vertical. Sources: src/lib/supabase/database.types.ts:2515-2524
| Partner Type | Description |
|---|---|
host | Providers for events or short-term stays. |
venue | Physical locations like nightclubs or rooftops. |
broker | Intermediaries, typically linked to rental supply. |
sponsor | B2B entities linked to sponsorship organizations. |
agency | Professional service organizations. |
vendor | Service providers for events. |
tour | Providers of guided experiences or excursions. |
creator | Content creators or individual service providers. |
Sources: src/lib/supabase/database.types.ts:2515-2524, supabase/seeds/partners.seed.sql:24-34
Onboarding and State Management
To facilitate supply-side acquisition, the system includes a persistence layer for a multi-step signup wizard via the partner_drafts table. Sources: supabase/migrations/20260606130500_ptr006_partner_drafts.sql:8-20
Signup Wizard Persistence
Drafts allow partners to save progress during onboarding. Each draft tracks the current step (1-10) and calculates a completion_score. It also supports integration with AI agents through a thread_id linked to the Mastra runtime. Sources: supabase/migrations/20260606130500_ptr006_partner_drafts.sql:12-23
Service Management and Assets
Partners can enable various digital services and upload necessary business documentation. Sources: supabase/migrations/20260606130800_ptr009_partner_assets_and_storage.sql:1-10
Partner Services
The partner_services system manages feature flags and tier-based access for partners. Common services include ai_event_booking, lead_qualification, and listing management. Sources: supabase/seeds/partners.seed.sql:51-60, src/lib/supabase/database.types.ts:1497-1510
Asset Management
Business assets such as logos, menus, and contracts are stored in a dedicated partner-assets storage bucket. Access is strictly controlled via folder-scoped RLS policies. Sources: supabase/migrations/20260606130800_ptr009_partner_assets_and_storage.sql:40-60
| Table/Storage | Purpose | Constraints |
|---|---|---|
partner_assets | Metadata for uploaded files. | Linked to partner_id. |
partner-assets (Bucket) | Physical file storage. | 10MB limit, specific MIME types. |
Sources: supabase/migrations/20260606130800_ptr009_partner_assets_and_storage.sql:8-15, 45-55
Revenue and Financial Tracking
The ecosystem includes a revenue_ledger to track supply-side earnings from various sources like ticket sales or lead fees. Sources: supabase/seeds/partners.seed.sql:71-76, src/lib/supabase/database.types.ts:1612-1628
Ledger Structure
The ledger is append-only for authenticated users to ensure auditability. It records the gross amount, currency, and the mdeai platform fee. Sources: src/lib/supabase/database.types.ts:1612-1628, src/tests/partner-schema-migrations.test.ts:71-77
-- Example revenue entry for a host ticket fee
insert into public.revenue_ledger (
partner_id,
source_kind,
amount_cents,
currency,
platform_fee_cents
) values (
'partner-uuid',
'ticket',
5000000,
'cop',
250000
);
Sources: supabase/seeds/partners.seed.sql:72-75
Security and Multi-Tenancy
Security is enforced through Row Level Security (RLS) and custom SQL helper functions. Sources: supabase/migrations/20260606130200_ptr003_partners.sql:45-55
Membership Scoping
Access to partner data is determined by membership. The system uses a security-definer function partner_ids_for_user() to resolve all partner accounts where the current user holds a role. Sources: supabase/migrations/20260606130800_ptr009_partner_assets_and_storage.sql:22-26, src/tests/partner-schema-migrations.test.ts:79-83
| Role | Permissions |
|---|---|
owner | Full access to settings, members, and assets. |
admin (System) | Global view/edit rights across all partners. |
service_role | Automated backend processing. |
Sources: supabase/migrations/20260606130200_ptr003_partners.sql:50-70, supabase/seeds/partners.seed.sql:37-41
Conclusion
The B2B Partner Ecosystem provides a robust, multi-vertical framework for managing the supply side of the Medellín discovery platform. By centralizing partner accounts while allowing vertical-specific extensions, the system maintains data integrity while scaling across diverse service offerings like rentals and events. Sources: README.md:5-15, supabase/migrations/20260606130200_ptr003_partners.sql:30-35