Social Media Platform Builder
Build a complete social media management system with plugin architecture, AI-powered content generation, and multi-platform publishing.
Architecture
┌─────────────────────────────────────┐
│ Frontend (5 pages) │
│ Dashboard│Compose│Calendar│Analytics│Settings│
├─────────────────────────────────────┤
│ API Layer (FastAPI) │
│ Posts CRUD│Publishing│Calendar│AI │
├─────────────────────────────────────┤
│ Plugin Registry (per-platform) │
│ Twitter│Instagram│YouTube│FB│TikTok│Manual│
├─────────────────────────────────────┤
│ LangGraph Content Pipeline │
│ Voice→Research→Draft→Optimize→Save │
├─────────────────────────────────────┤
│ Supabase (6 tables) │
└─────────────────────────────────────┘
Step 1: Supabase Tables
Create 6 tables:
social_posts— id, platform, content, status (draft/scheduled/published/failed), media_urls, published_at, post_url, engagement_metrics (JSONB)platform_connections— id, platform, account_name, credentials (JSONB), status, scopescontent_calendar— id, post_id (FK), scheduled_for, platform, statusbrand_voices— id, name, description, tone, example_phrases (JSONB array), is_defaultsocial_analytics— id, post_id (FK), platform, impressions, clicks, likes, shares, comments, fetched_atpublish_queue— id, post_id (FK), platform, status, retry_count, error_message
Seed 3-5 brand voices. Example voices:
- Primary Voice (default) — authoritative, clear, educational
- Casual — conversational, friendly, uses contractions
- Coach — motivational, direct, action-oriented
Step 2: Plugin System
Base class pattern:
class SocialPlugin:
platform: str
def validate_credentials(self, creds: dict) -> bool
def publish(self, content: str, media_urls: list = None) -> dict
def get_analytics(self, post_id: str) -> dict
def format_content(self, content: str, max_length: int) -> str
class PluginRegistry:
_plugins: dict[str, SocialPlugin] = {}
def register(self, plugin: SocialPlugin)
def get(self, platform: str) -> SocialPlugin
def list_active(self) -> list[str]
Platform-specific implementations:
- Twitter: tweepy or requests to v2 API. 280 char limit. Free tier = 100 posts/month.
- Facebook: Graph API v21.0. Page Access Token required. Post to
/{page_id}/feed. - Instagram: Graph API via FB Page Token. Post to
/{ig_user_id}/media→/{ig_user_id}/media_publish. Image required. - YouTube: google-auth + google-api-python-client. OAuth with youtube.upload scope. Upload via resumable upload API.
- TikTok: Content Posting API (requires app review + demo video). Use Manual mode as fallback.
- Manual: No API — generates copy + suggests optimal posting times. Fallback for any unconnected platform.
Step 3: LangGraph Content Pipeline
6-node graph:
load_voice → research_context → generate_drafts → optimize_per_platform → finalize → END
- load_voice: Pull selected brand voice from Supabase
- research_context: Query knowledge vault / RAG for relevant domain content
- generate_drafts: LLM generates 2-3 draft variants in the voice
- optimize_per_platform: Adapt each draft per platform (length, hashtags, media suggestions)
- finalize: Store drafts in
social_postsas draft status
Step 4: API Endpoints
Core routes (~19 endpoints):
GET/POST /api/social/posts— CRUDPOST /api/social/posts/{id}/publish— publish to selected platformsGET/POST /api/social/calendar— calendar view + schedulingGET /api/social/analytics— aggregated metricsGET/POST /api/social/voices— brand voice managementGET/POST /api/social/connections— platform credentialsPOST /api/social/generate— AI content generation (triggers LangGraph)
Step 5: Frontend Pages
5 pages with shared dark-theme shell (sidebar nav, top bar):
- Dashboard — post count by platform, recent activity, quick-publish
- Compose — rich editor, platform multi-select, voice picker, live preview cards per platform
- Calendar — month view, color-coded by platform, drag-to-reschedule
- Analytics — Chart.js line/bar charts for engagement over time
- Settings — platform connection forms (OAuth flows), brand voice editor
Key Patterns
- Credentials in JSONB: Each platform stores different auth shapes (API keys vs OAuth tokens vs page tokens) in a single
credentialsJSONB column - Graceful degradation: Always include Manual plugin as fallback — generates copy even without API access
- Platform content limits: Enforce per-platform (Twitter 280, IG needs image, YT needs video, FB 63K)
- Publish queue with retry: Failed publishes go to retry queue with exponential backoff