A complete YouTube-like video processing and sharing platform built with modern technologies, featuring parallel video processing workers, FFmpeg transcoding, thumbnail generation, and containerized deployment.
This platform follows a microservices architecture with distributed video processing:
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β React Frontend β β Go Backend API β β Video Workers β
β (Port: 3000) βββββΊβ (Port: 8080) βββββΊβ (Parallel) β
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β β β
β βΌ β
β βββββββββββββββββββ β
β β MongoDB β β
β β (Port: 27017) β β
β βββββββββββββββββββ β
β β β
β βΌ β
β βββββββββββββββββββ β
βββββββββββββββΊβ Redis Queue ββββββββββββββββββ
β (Port: 6379) β
βββββββββββββββββββ
β
βΌ
βββββββββββββββββββ
β MinIO β
β (Port: 9000) β
βββββββββββββββββββ
- Frontend: React 18 + TypeScript + Tailwind CSS
- Backend: Go 1.21 + Gin + Domain-Driven Design (DDD)
- Workers: Go + FFmpeg for video processing
- Database: MongoDB 7.0 (metadata, user data)
- Queue: Redis 7.0 (distributed job processing)
- Storage: MinIO (S3-compatible, video files)
- Processing: FFmpeg (video transcoding & thumbnails)
- Deployment: Docker Compose
- Docker & Docker Compose
- Git
-
Clone the repository
git clone <repository-url> cd youtube-example
-
Set up environment variables
cp .env.example .env # Edit .env with your preferred settings if needed
-
Start all services
docker-compose up -d
-
Wait for initialization (about 30-60 seconds)
# Check service status docker-compose ps # View logs docker-compose logs -f
-
Access the application
- Backend API: http://localhost:8080
- MinIO Console: http://localhost:9001 (minioadmin/minioadmin)
- Frontend: http://localhost:3000 (when implemented)
π₯ Video Processing Pipeline
- β Video Upload: Multipart upload with validation
- β Distributed Processing: Redis job queue with parallel workers
- β FFmpeg Transcoding: 480p, 720p, 1080p quality options
- β Thumbnail Generation: Automatic thumbnail creation
- β Progress Tracking: Real-time job status monitoring
- β File Storage: Organized MinIO structure (original/processed/thumbnails)
π§ Backend Infrastructure
- β RESTful API: Complete CRUD operations
- β Domain-Driven Design: Clean architecture
- β Job Queue: Redis-based distributed processing
- β Database Operations: MongoDB with proper indexing
- β File Streaming: Direct video streaming with quality selection
ποΈ DevOps & Deployment
- β Docker Compose: Complete containerized stack
- β Auto-initialization: MinIO buckets and permissions
- β Health Checks: Service monitoring endpoints
- β Structured Logging: Comprehensive error tracking
- React Frontend: Upload interface and video player
- User Authentication: JWT-based auth system
- Real-time Updates: WebSocket progress notifications
- Advanced Features: Video search, playlists, comments
# Upload video
POST /api/v1/videos/upload
curl -X POST -F "[email protected]" -F "title=My Video" http://localhost:8080/api/v1/videos/upload
# List videos (paginated)
GET /api/v1/videos?page=1&limit=20
curl http://localhost:8080/api/v1/videos
# Get video details
GET /api/v1/videos/:id
curl http://localhost:8080/api/v1/videos/64a7b8c9d1e2f3a4b5c6d7e8
# Stream video (original or processed)
GET /api/v1/videos/:id/stream?quality=720p
curl http://localhost:8080/api/v1/videos/64a7b8c9d1e2f3a4b5c6d7e8/stream
# Trigger manual processing
POST /api/v1/videos/:id/process
curl -X POST http://localhost:8080/api/v1/videos/64a7b8c9d1e2f3a4b5c6d7e8/process
# Get job status
GET /api/v1/jobs/:id
curl http://localhost:8080/api/v1/jobs/64a7b8c9d1e2f3a4b5c6d7e9
# Get all jobs for a video
GET /api/v1/jobs/video/:videoId
curl http://localhost:8080/api/v1/jobs/video/64a7b8c9d1e2f3a4b5c6d7e8
# Get active processing jobs
GET /api/v1/jobs/active
curl http://localhost:8080/api/v1/jobs/active
# Service health check
GET /health
curl http://localhost:8080/health
Run the complete test pipeline:
./scripts/test-upload.sh
This script will:
- Create a test video (if FFmpeg is available)
- Upload the video via API
- Monitor processing jobs
- Show final results
# 1. Check API health
curl http://localhost:8080/health
# 2. Upload a video
curl -X POST \
-F "[email protected]" \
-F "title=Test Video" \
-F "description=Test upload" \
http://localhost:8080/api/v1/videos/upload
# 3. Monitor processing
curl http://localhost:8080/api/v1/jobs/active
# 4. Check final video status
curl http://localhost:8080/api/v1/videos/{VIDEO_ID}
- Upload β Video uploaded to MinIO (
videos/original/
) - Job Creation β 4 jobs created (1 thumbnail + 3 transcode jobs)
- Queue Distribution β Jobs sent to Redis queue
- Worker Processing β 2 parallel workers process jobs
- FFmpeg Processing β Videos transcoded to multiple formats
- Storage β Processed files saved (
videos/processed/
,thumbnails/
) - Database Update β Video metadata updated with new formats
- Completion β Video status changed to "ready"
Variable | Description | Default |
---|---|---|
PORT |
Backend server port | 8080 |
MONGODB_URI |
MongoDB connection string | mongodb://admin:password@mongodb:27017/youtube?authSource=admin |
REDIS_URI |
Redis connection string | redis://redis:6379 |
MINIO_ENDPOINT |
MinIO server endpoint | minio:9000 |
MINIO_ACCESS_KEY |
MinIO access key | minioadmin |
MINIO_SECRET_KEY |
MinIO secret key | minioadmin |
FRONTEND_URL |
Frontend URL for CORS | http://localhost:3000 |
WORKER_ID |
Unique worker identifier | Auto-generated |
- Supported Input Formats: MP4, AVI, MOV, WMV, FLV, WebM, MKV
- Output Formats:
- 480p: H.264, 1Mbps max bitrate
- 720p: H.264, 2.5Mbps max bitrate
- 1080p: H.264, 4.5Mbps max bitrate
- Audio: AAC, 128kbps
- Max File Size: 1GB
- Parallel Workers: 2 (configurable)
youtube-example/
βββ backend/ # Go backend API (22 files)
β βββ internal/
β β βββ domain/ # Business logic (DDD)
β β β βββ entities/ # Video, Job, User entities
β β β βββ repositories/ # Data access interfaces
β β β βββ services/ # Business services
β β βββ infrastructure/ # External dependencies
β β β βββ database/ # MongoDB client
β β β βββ storage/ # MinIO client
β β β βββ queue/ # Redis client & job publisher
β β β βββ repositories/ # Repository implementations
β β βββ application/ # Application services
β β β βββ handlers/ # HTTP handlers
β β βββ interfaces/ # API layer
β β βββ http/ # Routes and middleware
β β βββ middleware/ # CORS, logging
β βββ pkg/ # Shared packages
βββ worker/ # Video processing workers (10 files)
β βββ internal/
β β βββ processor/ # FFmpeg transcoding logic
β β βββ storage/ # MinIO client
β β βββ queue/ # Redis & MongoDB clients
β βββ pkg/ # Worker configuration
βββ frontend/ # React frontend (future)
βββ scripts/ # Setup and testing scripts
β βββ setup.sh # Complete platform setup
β βββ test-upload.sh # Video upload testing
β βββ init-minio.sh # MinIO initialization
βββ docker-compose.yml # Container orchestration
βββ .env.example # Environment configuration
cd backend
go mod tidy
go run main.go
cd worker
go mod tidy
go run main.go
# Scale to 4 workers
docker-compose up --scale worker1=2 --scale worker2=2
docker-compose ps
# All services
docker-compose logs -f
# Specific services
docker-compose logs -f backend worker1 worker2
- URL: http://localhost:9001
- Credentials: minioadmin/minioadmin
- View uploaded videos and processed files
# MongoDB shell
docker exec -it youtube_mongodb mongosh --username admin --password password --authenticationDatabase admin
# Redis CLI
docker exec -it youtube_redis redis-cli
- β File validation and size limits
- β CORS configuration
- β Error handling and logging
- π§ Authentication system (planned)
- π§ Rate limiting (planned)
- π§ File encryption (planned)
- Container Orchestration: Kubernetes or Docker Swarm
- Load Balancer: Nginx or HAProxy
- Database: MongoDB Atlas or self-hosted cluster
- Storage: AWS S3 or distributed MinIO
- Monitoring: Prometheus + Grafana
- Logging: ELK Stack
- Horizontal scaling of workers
- CDN for video delivery
- Database indexing
- Connection pooling
- Caching strategies
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
This project is licensed under the MIT License.
β
Complete video processing pipeline with distributed workers
β
FFmpeg transcoding and thumbnail generation
β
RESTful API with job monitoring
β
Containerized deployment with Docker Compose
π§ React frontend ready for implementation
Built with β€οΈ using Go, FFmpeg, MongoDB, Redis, and MinIO.