A fully automated TikTok sports content creation and posting system that discovers trending sports videos, creates AI-powered remixes, and posts them automatically with intelligent scheduling.
- Python 3.10+
- ffmpeg (for video processing)
- Git
# Clone and setup
git clone <repository-url>
cd Tik
python scripts/setup.py# Edit .env with your API keys
cp .env.example .env
nano .envRequired API keys:
- Supabase: Database and storage
- Anthropic: Claude AI for content generation
- OpenAI: GPT-4 fallback for content generation
- TikHub: TikTok trending data discovery
- TikTok: Posting videos (optional for testing)
# Deploy to Supabase
python scripts/deploy_schema.py# Test all components
python scripts/validate_system.py# Start web server with dashboard
python main.py serve
# OR start automated scheduler
python main.py schedule
# OR run manual job
python main.py manual nba# Web server (dashboard + API)
python main.py serve [--host 127.0.0.1] [--port 8000] [--reload]
# Automated scheduler
python main.py schedule
# Manual content creation
python main.py manual {nba|nfl|mlb|nhl} [--count 1-3]
# System health check
python main.py health
# Initialize system
python main.py init# Initial setup
python scripts/setup.py [--skip-deps] [--validate-apis]
# Deploy database schema
python scripts/deploy_schema.py [--verify-only] [--with-sample-data]
# System validation
python scripts/validate_system.py [--component database|ai|video|apis|automation]- TikHub API finds trending sports videos (10K+ views)
- Engagement Analysis scores videos by viral potential
- Remix Detection identifies content suitable for remixing
- Theme Extraction identifies records, stats, comparisons
- Insight Generation extracts key statistics and narratives
- Remix Strategy determines best remix angle (historical update, stat breakdown, fact check, fresh perspective)
- Claude/GPT-4 creates engaging video scripts
- Template System structures content for optimal engagement
- Cost Optimization tracks API usage against daily limits
- Template Rendering creates 9:16 vertical videos
- Supabase Storage uploads videos and thumbnails
- Quality Control ensures proper resolution and duration
- TikTok API posts videos with optimized captions
- Intelligent Scheduling spaces posts 3-8 hours apart
- Performance Tracking monitors engagement and metrics
# Supabase (Required)
TIK_SUPABASE_URL=https://your-project.supabase.co
TIK_SUPABASE_KEY=your-anon-key
TIK_SUPABASE_SERVICE_ROLE_KEY=your-service-role-key
# AI Services (Required)
TIK_ANTHROPIC_API_KEY=your-anthropic-key
TIK_OPENAI_API_KEY=your-openai-key
# Content Discovery (Required)
TIK_TIKHUB_API_KEY=your-tikhub-key
# TikTok Posting (Optional)
TIK_TIKTOK_CLIENT_ID=your-client-id
TIK_TIKTOK_CLIENT_SECRET=your-client-secret
# Cost Controls
TIK_DAILY_COST_LIMIT=10.00
TIK_MONTHLY_COST_LIMIT=300.00
# Posting Schedule
TIK_MAX_POSTS_PER_DAY=3
TIK_MIN_POST_INTERVAL_HOURS=3
TIK_DEFAULT_POST_TIMES=06:00,14:00,19:00- Daily Limit: $10 (configurable)
- API Tracking: Every call monitored and logged
- Automatic Throttling: System pauses when limits reached
- Cost Breakdown: Claude ~$0.008/1K tokens, OpenAI ~$0.010/1K tokens
βββ src/
β βββ ai/ # AI content generation (Claude/GPT-4)
β βββ api/ # External API clients (TikHub, TikTok)
β βββ automation/ # Workflow orchestration & scheduling
β βββ data/ # Content analysis & data models
β βββ db/ # Supabase database operations
β βββ utils/ # Logging, error handling
β βββ video/ # Video generation & templates
βββ config/ # Configuration management
βββ database/ # Database schema & migrations
βββ scripts/ # Setup & deployment scripts
βββ main.py # Application entry point
TikHub Discovery β Content Analysis β AI Generation β Video Render β TikTok Post
β β β β β
Trending Videos β Insights β Scripts β MP4 Files β Posted Videos
(10K+ views) (Stats/Themes) (Engaging) (9:16) (Scheduled)
Visit http://localhost:8000 for:
- System Health: Real-time component status
- Daily Metrics: Cost tracking and performance
- Manual Controls: Trigger jobs and manage scheduler
- API Documentation: Interactive API docs at
/docs
GET /health- System health checkGET /status- Detailed system metricsPOST /manual/{sport}- Run manual content creationPOST /scheduler/start- Start automated schedulingPOST /scheduler/stop- Stop automated scheduling
# Setup development environment
python scripts/setup.py
python -m venv venv
source venv/bin/activate # or venv\Scripts\activate on Windows
pip install -r requirements.txt
# Run with auto-reload
python main.py serve --reload# Start full stack (includes Supabase local)
docker-compose up -d
# View logs
docker-compose logs -f tik-app
# Stop stack
docker-compose down# Full system validation
python scripts/validate_system.py
# Component-specific tests
python scripts/validate_system.py --component database
python scripts/validate_system.py --component ai
python scripts/validate_system.py --component video
# Manual test runs
python main.py manual nba --count 1
python main.py health- Fact Validation: AI models cross-check statistics
- Brand Safety: Content filtered for appropriateness
- Copyright Respect: Only remixes with original analysis
- Platform Compliance: TikTok policy adherence
- Cost Controls: Hard daily/monthly spending limits
- Rate Limiting: Respects all API rate limits
- Error Recovery: Automatic retry with exponential backoff
- Shadowban Prevention: Randomized posting patterns
- Daily Output: 1-3 videos automatically
- Processing Time: <2 minutes per video
- Cost Efficiency: $2-5 per video vs $50-100 manual
- Engagement: 9.2% target (vs 4.07% platform average)
- Uptime: 99.5% with automated recovery
- Real-time Metrics: Cost, performance, errors
- Database Logging: All activities tracked
- Health Checks: Automated system validation
- Alert System: Email/webhook notifications
- Single automated post working end-to-end
- Cost tracking and safety controls
- Full error handling and recovery
- Web dashboard and CLI interface
- Multi-model AI validation
- A/B testing framework
- Advanced engagement prediction
- Fact-checking pipeline
- 2-3 posts daily with intelligent spacing
- Shadowban detection and recovery
- Performance feedback loops
- Multi-sport coverage
- Instagram Reels, YouTube Shorts
- Cross-platform analytics
- Format adaptations
- Multi-account management
- Predictive content planning
- Real-time trend integration
- Self-optimizing parameters
- Fully autonomous operation
Setup Issues:
python scripts/validate_system.py --component databaseAPI Connection Problems:
python main.py healthCost Limit Errors: Check Supabase dashboard for daily usage.
Video Generation Fails:
Ensure ffmpeg is installed: ffmpeg -version
- Health Check:
python main.py health - System Validation:
python scripts/validate_system.py - Logs: Check
logs/tik.logfor detailed errors - Dashboard: Visit
http://localhost:8000for status
This project is for educational and research purposes. Please ensure compliance with:
- TikTok Terms of Service
- API provider terms (Anthropic, OpenAI, TikHub)
- Sports data usage rights
- Content creation best practices
Ready to automate your sports content? Run python scripts/setup.py to get started! π