A full-stack application for downloading and clipping Twitter/X videos. Simply paste a tweet URL, download the video, and optionally create custom clips with precise timestamps.
- π₯ Download videos from Twitter/X posts
- βοΈ Clip downloaded videos with custom start/end times
- π Fast processing with async operations
- π¨ Modern, responsive UI
- π Organized file management
- π³ Production-ready Docker deployment
- π Rate limiting and security features
- β‘ Redis-backed caching
- Next.js 14 - React framework with App Router for server-side rendering and optimized performance
- React 18 - Component-based UI library for building interactive interfaces
- TypeScript - Type safety and better developer experience
- Tailwind CSS - Utility-first CSS framework for rapid UI development
- Axios - HTTP client for API communication with the backend
- FastAPI - Modern Python web framework for building APIs with automatic OpenAPI documentation
- Uvicorn/Gunicorn - Production ASGI server for running async Python applications
- yt-dlp - Robust video downloading tool supporting Twitter/X and other platforms
- FFmpeg - Industry-standard tool for video processing and clipping
- Redis - In-memory data store for caching and rate limiting
- SlowAPI - Rate limiting middleware for API protection
- Docker - Containerization for consistent deployments
- Docker Compose - Multi-container orchestration
- GitHub Actions - CI/CD pipeline automation
clip-it/
βββ client/ # Next.js frontend application
β βββ app/ # Next.js App Router pages
β βββ components/ # React components (VideoClipperForm)
β βββ Dockerfile # Production Docker configuration
β βββ .next/ # Build artifacts (auto-generated)
βββ server/ # FastAPI backend application
β βββ main.py # FastAPI server entry point
β βββ downloads/ # Storage for downloaded videos
β βββ Dockerfile # Production Docker configuration
β βββ __pycache__/ # Python bytecode cache
βββ .github/
β βββ workflows/
β βββ ci-cd.yml # CI/CD pipeline configuration
βββ docker-compose.yml # Multi-container orchestration
βββ DEPLOYMENT.md # Comprehensive deployment guide
βββ README.md # This file
- Node.js 18+ and npm/yarn
- Python 3.8+
- FFmpeg installed on your system
- pip (Python package manager)
- Docker & Docker Compose (for containerized deployment)
-
Navigate to server directory:
cd server -
Create Python virtual environment:
python3 -m venv venv
-
Activate virtual environment:
# On Linux/macOS source venv/bin/activate # On Windows # venv\Scripts\activate
-
Install Python dependencies:
pip install -r requirement.txt
-
Configure environment variables:
cp .env.example .env
-
Start the FastAPI server:
uvicorn main:app --reload
-
To deactivate virtual environment when done:
deactivate
Server runs at http://localhost:8000
API docs at http://localhost:8000/docs
See detailed instructions in server/server_readme.md
-
Navigate to client directory:
cd client -
Install Node dependencies:
npm install # or yarn install -
Configure environment variables:
cp .env.local.example .env.local
-
Start the development server:
npm run dev # or yarn dev
Client runs at http://localhost:3000
See detailed instructions in client/README.md
-
Clone the repository:
git clone <repository-url> cd clip-it
-
Configure environment variables:
# Server configuration cp server/.env.example server/.env.production # Edit server/.env.production with your production values # Client configuration cp client/.env.local.example client/.env.production # Edit client/.env.production with your production values
-
Deploy all services:
docker-compose up -d --build
-
Verify deployment:
docker-compose ps docker-compose logs -f
Services will be available at:
- Frontend:
http://localhost:3000 - Backend API:
http://localhost:8080 - Redis:
localhost:6379
See DEPLOYMENT.md for comprehensive deployment instructions.
- User Input: Paste a Twitter/X video URL in the web interface
- Download: Server uses yt-dlp to fetch the video
- Storage: Video is saved to
server/downloads/with a unique ID - Clipping (Optional): Use FFmpeg to extract specific timeframes
- Caching: Redis caches frequently accessed data for performance
- Delivery: Processed videos are served back to the client
See client/.env.local.example for required variables:
NEXT_PUBLIC_API_URL- Backend API endpoint
See server/.env.example for required variables:
PORT- Server port (default: 8080)DOWNLOAD_DIR- Directory for storing videosDOWNLOAD_TTL_SECONDS- File cleanup TTLALLOWED_ORIGINS- CORS allowed originsMAX_CLIP_SECONDS- Maximum clip durationREDIS_URL- Redis connection string (for production)
POST /download- Download video from URLPOST /clip- Create clip from downloaded videoGET /videos/{id}- Retrieve processed videoGET /health- Health check endpoint
Full API documentation available at /docs when server is running.
The project includes a GitHub Actions workflow that automatically:
- Lint and Test: Validates code quality on every pull request
- Build Docker Images: Creates and pushes images to Docker Hub on main branch
- Deploy: Triggers deployment to your infrastructure
Configure these in your repository settings:
DOCKER_USERNAME- Docker Hub usernameDOCKER_PASSWORD- Docker Hub password or access tokenDEPLOY_TOKEN- Deployment platform token
- Build artifacts in
client/.next/are auto-generated - do not edit manually - Downloaded videos are stored in
server/downloads/- ensure sufficient disk space - Python bytecode cache in
server/__pycache__/can be safely deleted - Virtual environment
server/venv/should be added to.gitignore - Always activate the virtual environment before running server commands
Before deploying to production:
- Update all environment variables with production values
- Configure SSL/TLS certificates
- Set up reverse proxy (Nginx/Traefik)
- Configure firewall rules
- Set up monitoring and alerting
- Implement backup strategy
- Review security settings
- Test health checks
- Configure log rotation
- Set up CDN for static assets (optional)
For issues and questions:
- Check existing issues on GitHub
- Review DEPLOYMENT.md for deployment guidance
- Review server/server_readme.md for API details
- Consult FastAPI and Next.js documentation