Back to Portfolio
Opal
Multi-platform content distribution worker for scheduling and publishing to Instagram, TikTok, and Pinterest on a per-brand basis.
TypeScriptCloudflare WorkersD1R2

About This Project
Opal is a Cloudflare Worker that acts as middleware between a client web UI and three social platforms. Users select a brand, upload content, configure platform-specific details, and schedule posts.
A cron trigger fires every minute to publish due posts and refresh expiring OAuth tokens. The system supports multiple brands, each with their own platform connections and credentials.
Key features include:
- Multi-brand content scheduling across Instagram, TikTok, and Pinterest
- Platform-specific adapters (IG Graph API, TikTok Content Posting API, Pinterest API v5)
- Encrypted OAuth token storage with AES-GCM via Web Crypto API
- Cron-based publisher with retry logic (3 attempts per post)
- Automatic token refresh per platform expiry rules
- R2 media storage with public URL generation
- Error logging and resolution tracking
- Layered architecture: Routes → Services → Repositories → Adapters → Models