A cloud-native video processing platform built with microservices architecture. Upload videos and get them automatically transcoded to multiple resolutions (1080p, 720p, 480p) with cloud storage on Cloudflare R2.
- Video Upload & Processing - Upload videos and automatically transcode to multiple resolutions
- Cloud Storage - Videos and thumbnails stored on Cloudflare R2 with presigned URLs
- Async Job Processing - Celery workers handle video transcoding in the background
- JWT Authentication - Secure user authentication with access tokens
- Responsive UI - Modern React frontend with dark mode support
- Video Player - Built-in Video.js player with quality selection
graph LR
subgraph Client
A[React Frontend<br/>:3000]
end
subgraph Backend
B[FastAPI<br/>:8080]
C[(PostgreSQL<br/>Neon)]
end
subgraph Message Queue
D[RabbitMQ<br/>:5672]
end
subgraph Workers
E[Celery Worker<br/>Transcode]
F[Celery Worker<br/>Upload]
end
subgraph Storage
G[Cloudflare R2]
end
A -->|HTTP/REST| B
B -->|Prisma ORM| C
B -->|Queue Tasks| D
D --> E
D --> F
E -->|FFmpeg| F
F -->|S3 API| G
flowchart LR
A[π€ Upload] --> B[πΎ Store Raw]
B --> C[π Queue Job]
C --> D[π¬ Transcode]
D --> E[1080p @ 5Mbps]
D --> F[720p @ 2.5Mbps]
D --> G[480p @ 1Mbps]
E --> H[βοΈ Upload to R2]
F --> H
G --> H
H --> I[β
Ready]
- FastAPI - Modern async Python web framework
- Prisma - Type-safe ORM for PostgreSQL
- Celery - Distributed task queue for video processing
- FFmpeg - Video transcoding engine
- RabbitMQ - Message broker for Celery
- Cloudflare R2 - S3-compatible object storage
- JWT - Token-based authentication
- React 19 - UI framework with hooks
- TypeScript - Type-safe JavaScript
- Tailwind CSS 4 - Utility-first CSS
- Video.js - HTML5 video player
- React Hook Form - Form management
- Axios - HTTP client
- Docker Compose - Container orchestration
- PostgreSQL - Primary database (Neon serverless)
- Prisma Studio - Database GUI (optional)
- Docker & Docker Compose
- Node.js 22+ (for local frontend development)
- Python 3.12+ (for local backend development)
- Cloudflare R2 bucket with API credentials
-
Clone the repository
git clone https://github.com/yourusername/polymorphix.git cd polymorphix -
Configure backend environment
cp server/.env.example server/.env
Edit
server/.envwith your credentials:DATABASE_URL=postgresql://user:pass@host:5432/dbname JWT_SECRET_KEY=your-secret-key-here R2_ACCOUNT_ID=your-cloudflare-account-id R2_ACCESS_KEY=your-r2-access-key R2_SECRET_KEY=your-r2-secret-key R2_BUCKET_NAME=your-bucket-name R2_PUBLIC_URL=https://pub-xxx.r2.dev ALLOWED_ORIGINS=http://localhost:3000,http://localhost:5173
-
Configure frontend environment
cp client/.env.example client/.env
Edit
client/.env:VITE_API_URL=http://localhost:8080
# Start all services
docker compose up -d
# View logs
docker compose logs -f
# Stop services
docker compose downServices will be available at:
- Frontend: http://localhost:3000
- Backend API: http://localhost:8080
- RabbitMQ Management: http://localhost:15672 (guest/guest)
- Prisma Studio: http://localhost:5555
| Method | Endpoint | Description |
|---|---|---|
| POST | /auth/signup |
Register new user |
| POST | /auth/signin |
Login user |
| GET | /auth/me |
Get current user |
| Method | Endpoint | Description |
|---|---|---|
| GET | /videos |
List user's videos |
| POST | /videos/upload |
Upload new video |
| DELETE | /videos/{id} |
Delete single video |
| DELETE | /videos |
Delete all videos |
| Method | Endpoint | Description |
|---|---|---|
| GET | / |
Welcome message |
| GET | /health |
Health check |
polymorphix/
βββ client/ # React frontend
β βββ src/
β β βββ components/ # Reusable UI components
β β βββ contexts/ # React context providers
β β βββ lib/ # API client & utilities
β β βββ pages/ # Page components
β βββ package.json
β
βββ server/ # FastAPI backend
β βββ app/
β β βββ routes/ # API endpoints
β β βββ services/ # Business logic (R2, etc.)
β β βββ tasks/ # Celery tasks
β β βββ schemas/ # Pydantic models
β βββ prisma/ # Database schema
β βββ pyproject.toml
β
βββ docker-compose.yml # Container orchestration
- Upload: User uploads video via frontend
- Store: Raw video saved to
/video_queuevolume - Queue:
process_videotask dispatched to Celery - Transcode: FFmpeg creates 3 resolution variants
- Thumbnail: Screenshot extracted at 10% of duration
- Upload: Variants uploaded to R2 via
uploadqueue - Ready: Database updated, video available to stream
Configure allowed origins in server/.env:
ALLOWED_ORIGINS=http://localhost:3000,https://yourdomain.comConfigured in server/app/tasks/video_tasks.py:
RESOLUTIONS = [
{"name": "1080", "height": 1080, "bitrate": 5000},
{"name": "720", "height": 720, "bitrate": 2500},
{"name": "480", "height": 480, "bitrate": 1000},
]- 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
This project is licensed under the MIT License - see the LICENSE file for details.
- FastAPI - Modern Python web framework
- Video.js - Open source video player
- Cloudflare R2 - S3-compatible storage
- shadcn/ui - UI component library