{"skill":{"slug":"social-media-platform","displayName":"Social Media Platform","summary":"Build a plugin-based social media management platform with multi-platform publishing, content calendar, brand voices, AI content generation via LangGraph, an...","description":"---\nname: social-media-platform\ndescription: Build a plugin-based social media management platform with multi-platform publishing, content calendar, brand voices, AI content generation via LangGraph, and analytics. Use when building social media tools, content scheduling systems, or multi-platform publishing pipelines. Covers Facebook, Instagram, YouTube, Twitter/X, TikTok integration patterns.\n---\n\n# Social Media Platform Builder\n\nBuild a complete social media management system with plugin architecture, AI-powered content generation, and multi-platform publishing.\n\n## Architecture\n\n```\n┌─────────────────────────────────────┐\n│         Frontend (5 pages)          │\n│  Dashboard│Compose│Calendar│Analytics│Settings│\n├─────────────────────────────────────┤\n│         API Layer (FastAPI)         │\n│  Posts CRUD│Publishing│Calendar│AI  │\n├─────────────────────────────────────┤\n│      Plugin Registry (per-platform) │\n│  Twitter│Instagram│YouTube│FB│TikTok│Manual│\n├─────────────────────────────────────┤\n│    LangGraph Content Pipeline       │\n│  Voice→Research→Draft→Optimize→Save │\n├─────────────────────────────────────┤\n│         Supabase (6 tables)         │\n└─────────────────────────────────────┘\n```\n\n## Step 1: Supabase Tables\n\nCreate 6 tables:\n- `social_posts` — id, platform, content, status (draft/scheduled/published/failed), media_urls, published_at, post_url, engagement_metrics (JSONB)\n- `platform_connections` — id, platform, account_name, credentials (JSONB), status, scopes\n- `content_calendar` — id, post_id (FK), scheduled_for, platform, status\n- `brand_voices` — id, name, description, tone, example_phrases (JSONB array), is_default\n- `social_analytics` — id, post_id (FK), platform, impressions, clicks, likes, shares, comments, fetched_at\n- `publish_queue` — id, post_id (FK), platform, status, retry_count, error_message\n\nSeed 3-5 brand voices. Example voices:\n- **Primary Voice** (default) — authoritative, clear, educational\n- **Casual** — conversational, friendly, uses contractions\n- **Coach** — motivational, direct, action-oriented\n\n## Step 2: Plugin System\n\nBase class pattern:\n\n```python\nclass SocialPlugin:\n    platform: str\n    def validate_credentials(self, creds: dict) -> bool\n    def publish(self, content: str, media_urls: list = None) -> dict\n    def get_analytics(self, post_id: str) -> dict\n    def format_content(self, content: str, max_length: int) -> str\n\nclass PluginRegistry:\n    _plugins: dict[str, SocialPlugin] = {}\n    def register(self, plugin: SocialPlugin)\n    def get(self, platform: str) -> SocialPlugin\n    def list_active(self) -> list[str]\n```\n\nPlatform-specific implementations:\n- **Twitter**: tweepy or requests to v2 API. 280 char limit. Free tier = 100 posts/month.\n- **Facebook**: Graph API v21.0. Page Access Token required. Post to `/{page_id}/feed`.\n- **Instagram**: Graph API via FB Page Token. Post to `/{ig_user_id}/media` → `/{ig_user_id}/media_publish`. Image required.\n- **YouTube**: google-auth + google-api-python-client. OAuth with youtube.upload scope. Upload via resumable upload API.\n- **TikTok**: Content Posting API (requires app review + demo video). Use Manual mode as fallback.\n- **Manual**: No API — generates copy + suggests optimal posting times. Fallback for any unconnected platform.\n\n## Step 3: LangGraph Content Pipeline\n\n6-node graph:\n\n```\nload_voice → research_context → generate_drafts → optimize_per_platform → finalize → END\n```\n\n- **load_voice**: Pull selected brand voice from Supabase\n- **research_context**: Query knowledge vault / RAG for relevant domain content\n- **generate_drafts**: LLM generates 2-3 draft variants in the voice\n- **optimize_per_platform**: Adapt each draft per platform (length, hashtags, media suggestions)\n- **finalize**: Store drafts in `social_posts` as draft status\n\n## Step 4: API Endpoints\n\nCore routes (~19 endpoints):\n- `GET/POST /api/social/posts` — CRUD\n- `POST /api/social/posts/{id}/publish` — publish to selected platforms\n- `GET/POST /api/social/calendar` — calendar view + scheduling\n- `GET /api/social/analytics` — aggregated metrics\n- `GET/POST /api/social/voices` — brand voice management\n- `GET/POST /api/social/connections` — platform credentials\n- `POST /api/social/generate` — AI content generation (triggers LangGraph)\n\n## Step 5: Frontend Pages\n\n5 pages with shared dark-theme shell (sidebar nav, top bar):\n1. **Dashboard** — post count by platform, recent activity, quick-publish\n2. **Compose** — rich editor, platform multi-select, voice picker, live preview cards per platform\n3. **Calendar** — month view, color-coded by platform, drag-to-reschedule\n4. **Analytics** — Chart.js line/bar charts for engagement over time\n5. **Settings** — platform connection forms (OAuth flows), brand voice editor\n\n## Key Patterns\n\n- **Credentials in JSONB**: Each platform stores different auth shapes (API keys vs OAuth tokens vs page tokens) in a single `credentials` JSONB column\n- **Graceful degradation**: Always include Manual plugin as fallback — generates copy even without API access\n- **Platform content limits**: Enforce per-platform (Twitter 280, IG needs image, YT needs video, FB 63K)\n- **Publish queue with retry**: Failed publishes go to retry queue with exponential backoff\n","topics":["Social Media Management","Calendar","Twitter"],"tags":{"latest":"1.0.0"},"stats":{"comments":0,"downloads":248,"installsAllTime":9,"installsCurrent":0,"stars":0,"versions":1},"createdAt":1771917500277,"updatedAt":1778491624313},"latestVersion":{"version":"1.0.0","createdAt":1771917500277,"changelog":"Initial release: plugin-based multi-platform social media management with LangGraph content pipeline","license":null},"metadata":null,"owner":{"handle":"brandonwadepackard-cell","userId":"s17f5y8stpzc3ms14zwb8qv1t588567a","displayName":"brandonwadepackard-cell","image":"https://avatars.githubusercontent.com/u/227546078?v=4"},"moderation":null}