Skip to main content

The Big Picture

Trending Society is built on a single-database architecture that powers four distinct business units. Every product shares the same Supabase PostgreSQL database, enabling cross-product queries, unified user identity, and compounding data intelligence.
┌─────────────────────────────────────────────────────────────────┐
│                    Supabase PostgreSQL                          │
│                    67 tables, 1 database                        │
├─────────────────────────────────────────────────────────────────┤
│                                                                 │
│   ┌──────────┐  ┌──────────┐  ┌──────────┐  ┌──────────┐      │
│   │Publisher │  │ Platform │  │  Agency  │  │  Store   │      │
│   │  Blog    │  │ Creator  │  │  Client  │  │ Shopify  │      │
│   │ Network  │  │  Tools   │  │ Services │  │  Sync    │      │
│   └──────────┘  └──────────┘  └──────────┘  └──────────┘      │
│                                                                 │
│   ┌──────────┐                                                 │
│   │  Jarvis  │  Voice Assistant (queries all tables)          │
│   └──────────┘                                                 │
│                                                                 │
└─────────────────────────────────────────────────────────────────┘

Why Single Database?

What You Can’t Do with Separate Databases

ProblemImpact
Join across productsRequires ETL pipelines, sync jobs, stale data
Unified user identityUsers need separate accounts per product
AI contextModels can’t see full picture
MaintenanceN databases = N times the work

What You CAN Do with Single Database

  • One query spans all business units - Join Publisher analytics with Store orders
  • User signs up once - Accesses everything based on role
  • Jarvis has full context - “Your travel posts generated $2,400 in Viator commissions”
  • Every new table benefits all products - Add it once, query everywhere

Database Structure

Project: trendingsociety-production Project Ref: ymdccxqzmhxgbjbppywf Total Tables: 127 custom + 37 Supabase-managed = 164 total
SchemaTablesPurpose
public111Product data (RLS required)
system14Infrastructure (service_role only)
events1Immutable audit logs
Tables are prefixed by domain:
PrefixDomainExample Tables
(none)Sharedusers, tenants, platforms
aiv_AI Visibilityaiv_bot_activity, aiv_citations
system_Infrastructuresystem_checkpoints, system_circuit_breakers
publisher_Blog Networkpublisher_posts, publisher_ig_sources
creator_Platformcreator_profiles, creator_licenses
agency_Client Servicesagency_clients, agency_projects
shopify_Storeshopify_products, shopify_orders
jarvis_Voice Assistantjarvis_conversations, jarvis_messages

Full Table Reference

See all 127 tables with schemas and relationships

The Leverage

Content Example

One blog post in Publisher can:
  1. Generate affiliate revenue (tracked in viator_click_tracking)
  2. Drive Store sales (join with shopify_orders)
  3. Become licensed content on Platform (tracked in creator_licenses)
  4. Train AI models (stored in content_analysis)

User Journey Example

-- Track user from visitor → reader → customer → creator
SELECT 
  u.email,
  COUNT(DISTINCT ae.id) as page_views,
  COUNT(DISTINCT so.id) as purchases,
  SUM(so.total) as lifetime_value,
  cp.creator_tier,
  SUM(clp.amount) as licensing_revenue
FROM users u
LEFT JOIN audience_events ae ON ae.user_id = u.id
LEFT JOIN shopify_orders so ON so.customer_email = u.email
LEFT JOIN creator_profiles cp ON cp.user_id = u.id
LEFT JOIN creator_license_purchases clp ON clp.creator_id = cp.id
GROUP BY u.id, cp.creator_tier;

Tech Stack

LayerTechnology
DatabaseSupabase PostgreSQL
BackendNext.js API Routes, Supabase Edge Functions
FrontendNext.js 14, React, Tailwind
DeploymentVercel (apps), Cloudflare Workers (MCP Gateway)
MonorepoTurborepo, pnpm workspaces
AIOpenAI, Anthropic, Gemini (routed via ai_model_config)

Next Steps