A lightweight, scalable media processing pipeline built with Go and Python. MPiper provides a robust API for uploading media assets and a distributed worker system for processing images and videos with automatic variant generation.
- RESTful API Server - High-performance Go server built with Chi router
- Asynchronous Processing - Redis-based job queue for scalable media processing
- Multi-Cloud Storage - Support for Google Cloud Storage (GCS) and AWS S3
- Image Processing - Automatic generation of optimized image variants (thumbnails, different formats)
- Video Processing - Video transcoding and optimization
- Database-Backed - PostgreSQL for reliable metadata and job tracking
- Docker Ready - Containerized deployment with Kubernetes support
- Production Ready - Structured logging, error handling, and recovery middleware
βββββββββββββββ ββββββββββββββββ βββββββββββββββ
β Client ββββββββββΆβ Go API ββββββββββΆβ Redis β
β β β Server β β Queue β
βββββββββββββββ ββββββββββββββββ βββββββββββββββ
β β
βΌ βΌ
ββββββββββββββββ βββββββββββββββ
β PostgreSQL βββββββββββ Python β
β Database β β Worker β
ββββββββββββββββ βββββββββββββββ
β β
βΌ βΌ
ββββββββββββββββββββββββββββββββββββ
β Cloud Storage (GCS/S3) β
ββββββββββββββββββββββββββββββββββββ
Flow:
- Client uploads media via REST API
- Go server generates signed upload URL and creates job
- Client uploads directly to cloud storage
- Job is queued in Redis
- Python worker processes media (resize, transcode, optimize)
- Variants are stored back to cloud storage
- Database is updated with asset status and metadata
- Go 1.24 or higher
- Python 3.10 or higher
- PostgreSQL 12 or higher
- Redis 6 or higher
- Task (optional, for build automation) - Installation guide
- Cloud storage account (GCS or AWS S3)
git clone https://github.com/rndmcodeguy20/mpiper.git
cd mpiperCreate a .env file in the project root:
# Server Configuration
SERVER_HOST=localhost
SERVER_PORT=8080
ENV=development
# Database
DB_HOST=localhost
DB_PORT=5432
DB_USER=postgres
DB_PASSWORD=your_password
DB_NAME=mpiper
DB_SSLMODE=disable
# Redis
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_PASSWORD=
REDIS_DB=0
# Storage (GCS)
STORAGE_PROVIDER=gcp
GCS_BUCKET=your-bucket-name
GCS_CREDENTIALS_PATH=.secrets/service-account.json
# Worker
TEMP_DIR=/tmp/mpiper
STREAM_NAME=media:jobs
JOB_POLL_INTERVAL=1# Create database
createdb mpiper
# Run migrations
psql -d mpiper -f db/migrations/001_seed.sqlGo Server:
go mod downloadPython Worker:
pip install poetry
poetry installOr using pip directly:
pip install -r requirements.txtOption A: Using Task (Recommended)
# Run API server
task dev
# Run worker (in another terminal)
poetry run python -m workerOption B: Manual
# Run API server
go run cmd/server/main.go
# Run worker
python -m workercurl -X POST http://localhost:8080/api/v1/assets/upload \
-H "Content-Type: application/json" \
-d '{
"fileName": "image.jpg",
"contentType": "image/jpeg",
"size": 1024000
}'# Build API server
docker build -t mpiper-api:latest -f deploy/docker/mpiper.dockerfile .
# Build worker
docker build -t mpiper-worker:latest -f deploy/docker/worker.dockerfile .docker-compose up -dkubectl apply -f deploy/k8s/Endpoint: POST /api/v1/assets/upload
Request:
{
"fileName": "example.jpg",
"contentType": "image/jpeg",
"size": 2048576
}Response:
{
"uploadUrl": "https://storage.googleapis.com/...",
"assetId": "550e8400-e29b-41d4-a716-446655440000",
"method": "PUT",
"headers": {
"Content-Type": "image/jpeg"
},
"objectPath": "media/raw/550e8400-e29b-41d4-a716-446655440000",
"publicUrl": "https://storage.googleapis.com/...",
"expiresAt": 1702468800
}Endpoint: POST /api/v1/assets/{assetId}/uploaded
Response:
{
"message": "Asset marked as uploaded",
"assetId": "550e8400-e29b-41d4-a716-446655440000"
}mpiper/
βββ cmd/
β βββ server/ # API server entry point
βββ internal/
β βββ config/ # Configuration management
β βββ database/ # Database connections
β βββ handler/ # HTTP handlers
β βββ middleware/ # HTTP middleware
β βββ models/ # Data models
β βββ queue/ # Redis queue implementation
β βββ repository/ # Database repositories
β βββ router/ # Route definitions
β βββ server/ # Server setup
β βββ service/ # Business logic
βββ pkg/
β βββ errors/ # Error handling
β βββ utils/ # Utility functions
βββ worker/
β βββ consumer/ # Job consumer
β βββ processing/ # Media processing logic
β βββ storage/ # Storage adapters
β βββ utils/ # Worker utilities
βββ db/
β βββ migrations/ # SQL migrations
βββ deploy/
βββ docker/ # Docker files
βββ k8s/ # Kubernetes manifests
Go tests:
go test ./...Python tests:
poetry run pytest# Using Task
task build-prod
# Manual
CGO_ENABLED=0 go build -ldflags="-w -s" -o build/mpiper cmd/server/main.goThe server can be configured via environment variables or a configuration file. See internal/config/env.go for all available options.
MPiper supports multiple cloud storage providers:
- Google Cloud Storage (GCS) - Default, recommended for production
- AWS S3 - Coming soon
- Azure Blob Storage - Coming soon
Configure worker behavior in worker/consumer/config.py:
- Processing pipelines (image/video)
- Variant generation rules
- Storage destinations
- Concurrency settings
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Write tests for new features
- Follow Go and Python best practices
- Update documentation as needed
- Ensure all tests pass before submitting PR
This project is licensed under the MIT License - see the LICENSE file for details.
Shantanu Mane
- Website: rndmcode.in
- Email: hi@rndmcode.in
- GitHub: @rndmcodeguy20
- Built with Chi - Lightweight Go router
- Uses Pillow for image processing
- Powered by Redis for job queuing
- Data stored in PostgreSQL
- Support for AWS S3 storage
- Support for Azure Blob Storage
- Video transcoding with FFmpeg
- Webhook notifications
- Admin dashboard
- Batch processing API
- CDN integration
- Advanced image optimization (WebP, AVIF)
- Real-time processing status via WebSockets
Please use the GitHub Issues page to report bugs or request features.
- Go Documentation
- Python Documentation
- PostgreSQL Documentation
- Redis Documentation
- Task Documentation
Made with β€οΈ by Shantanu Mane