๐Ÿ—๏ธSystem Architecture

@divz.mysterious ยท Eco Resin ยท Crochet ยท Handmade Decor ยท Slow Crafting

Goal: 100K+ followers
D

Frontend

Next.js 14 (App Router) with React Server Components
Recharts for data visualization
TailwindCSS + custom design system
Framer Motion for animations
OAuth redirect handlers per platform
Real-time data subscriptions via Supabase

Backend (API Layer)

Next.js API Routes (serverless functions)
Vercel Cron Jobs for scheduled data fetching
Rate limiter middleware per platform
Token refresh service (background)
LLM orchestration layer (OpenAI / Claude API)
Webhook receivers for real-time platform updates

Data Layer

Supabase (PostgreSQL) with Row-Level Security
Real-time subscriptions for live dashboard updates
Edge Functions for lightweight compute
Supabase Storage for media cache / thumbnails
Automated daily snapshots of analytics data
Full-text search on trending topics

Data Flow Pipeline

OAuth Loginโ†’
Token Storeโ†’
Cron Fetchโ†’
Raw โ†’ DBโ†’
Analytics Engineโ†’
AI/LLM Layerโ†’
Dashboard UI

User authenticates with each platform via OAuth 2.0 flow

Encrypted tokens saved to Supabase with expiry tracking

Scheduled jobs pull analytics from each platform API

Normalized data stored as snapshots and post records

Compute signals, patterns, trends from historical data

Feed processed data to LLM for recommendations

Real-time rendered via Supabase subscriptions

Database Schema

usersโ€” Creator accounts

id (uuid PK), email, name, avatar_url, created_at, updated_at

platform_connectionsโ€” OAuth tokens per platform

id, user_id (FK), platform (enum), access_token (encrypted), refresh_token (encrypted), scopes, token_expires_at, platform_user_id, connected_at

analytics_snapshotsโ€” Daily analytics snapshots

id, user_id (FK), platform, followers, reach, engagement_rate, saves, shares, watch_time_hrs, snapshot_date

content_postsโ€” Individual post performance

id, user_id (FK), platform, platform_post_id, title, type (reel/short/pin/video), views, saves, shares, comments, completion_rate, posted_at, fetched_at

trending_topicsโ€” Trending topic signals

id, topic, platform, category, growth_rate, heat_score, search_volume, detected_at, expires_at

ai_recommendationsโ€” AI-generated content ideas

id, user_id (FK), concept, hook, video_length, shot_list (jsonb), editing_style, music, caption, hashtags (text[]), virality_score, generated_at

viral_patternsโ€” Detected viral patterns

id, user_id (FK), insight, impact, category, data_points, detected_at

creator_watchlistโ€” Tracked trending creators

id, handle, platform, followers, growth_rate, niche, format_description, last_checked

API Endpoints

MethodEndpointDescriptionAuth
GET/api/auth/[platform]Initiate OAuth redirect for given platformPublic
GET/api/auth/callbackHandle OAuth callback, exchange code for tokensPublic
POST/api/auth/refreshRefresh expired platform tokensCron
GET/api/analytics/overviewCross-platform summary metricsAuth
GET/api/analytics/growthHistorical follower growth dataAuth
GET/api/analytics/postsPost-level performance with sorting/filtersAuth
GET/api/analytics/signalsAlgorithm signal scores and benchmarksAuth
GET/api/trends/topicsCurrent trending topics with heat scoresAuth
GET/api/trends/keywordsRising keywords with search volumeAuth
POST/api/ai/recommendGenerate AI content recommendationsAuth
POST/api/ai/patternsRun viral pattern detection analysisAuth
GET/api/creators/trendingList trending creators in nicheAuth
GET/api/opportunitiesContent gap analysis resultsAuth
POST/api/cron/fetch-analyticsScheduled analytics data fetchCron
POST/api/cron/detect-trendsScheduled trend detection pipelineCron

AI Analysis Pipeline

Trend Detection Engine

1

Aggregate search data from Pinterest Trends, YouTube Search Suggest, IG Explore

2

Calculate velocity scores: growth rate over 7/14/30 day windows

3

Cross-reference with creator's niche keywords for relevance scoring

4

Rank by heat score (velocity ร— relevance ร— recency)

Content Recommendation Engine

1

Input: top trends + creator analytics + algorithm signals + top posts

2

LLM prompt: generate content concepts optimized for creator's strengths

3

Score each concept: virality probability based on historical pattern match

4

Output: ranked list with full production briefs (hook, shots, caption, tags)

Viral Pattern Detector

1

Analyze top 50 posts: extract duration, hook timing, camera angle, audio type

2

Statistical correlation: which attributes correlate with high save/share rates

3

Generate natural language insights with confidence intervals

4

Refresh weekly as new content is published

Opportunity Gap Analyzer

1

Demand signal: keyword search volume + engagement on related content

2

Supply signal: count of active creators + content frequency in niche

3

Gap score: demand / supply ratio normalized to 0-100

4

Suggest specific content ideas to fill each gap