# MPR - Media Processor A web-based media transcoding tool with Django admin, FastAPI backend, and React timeline UI. ## Architecture ``` Browser (mpr.local.ar) │ nginx:80 │ ┌────┴────┐ │ │ /admin /api, /ui │ │ Django FastAPI ◄── Timeline UI │ │ │ ┌────┘ │ │ └───►│ (job operations) │ gRPC Server │ Celery Worker ``` - **Django** (`/admin`): Admin interface for data management - **FastAPI** (`/api`): REST API and gRPC client - **Timeline UI** (`/ui`): React app for video editing - **gRPC Server**: Worker communication with progress streaming - **Celery**: Job execution via FFmpeg ## Prerequisites - Docker & Docker Compose ## Quick Start ```bash # Add to /etc/hosts echo "127.0.0.1 mpr.local.ar" | sudo tee -a /etc/hosts # Start all services cd ctrl cp .env.template .env docker compose up -d ``` ## Access Points | URL | Description | |-----|-------------| | http://mpr.local.ar/admin | Django Admin | | http://mpr.local.ar/api/docs | FastAPI Swagger | | http://mpr.local.ar/ui | Timeline UI | ## Commands ```bash cd ctrl # Start/stop docker compose up -d docker compose down # Rebuild after code changes docker compose up -d --build # View logs docker compose logs -f docker compose logs -f celery # Create admin user docker compose exec django python manage.py createsuperuser ``` ## Code Generation Models are defined in `schema/models/` and generate: - Django ORM models - Pydantic schemas - TypeScript types - Protobuf definitions ```bash # Regenerate all python schema/generate.py --all # Or specific targets python schema/generate.py --django python schema/generate.py --pydantic python schema/generate.py --typescript python schema/generate.py --proto ``` ## Media Storage MPR stores media file paths **relative to the media root** for cloud portability. ### Local Development - Files: `/app/media/video.mp4` - Stored path: `video.mp4` - Served via: `http://mpr.local.ar/media/video.mp4` (nginx alias) ### AWS/Cloud Deployment For S3 or cloud storage, set `MEDIA_BASE_URL`: ```bash MEDIA_BASE_URL=https://bucket.s3.amazonaws.com/ ``` - Files: S3 bucket - Stored path: `video.mp4` (same relative path) - Served via: `https://bucket.s3.amazonaws.com/video.mp4` **Scan Endpoint**: `POST /api/assets/scan` recursively scans the media folder and registers new files with relative paths. ## Project Structure ``` mpr/ ├── api/ # FastAPI application │ ├── routes/ # API endpoints │ └── schemas/ # Pydantic models (generated) ├── core/ # Core utilities │ └── ffmpeg/ # FFmpeg wrappers ├── ctrl/ # Docker & deployment │ ├── docker-compose.yml │ └── nginx.conf ├── media/ # Media files (local storage) ├── rpc/ # gRPC server & client │ └── protos/ # Protobuf definitions (generated) ├── mpr/ # Django project │ └── media_assets/ # Django app ├── schema/ # Source of truth │ └── models/ # Dataclass definitions ├── task/ # Celery job execution │ ├── executor.py # Executor abstraction │ └── tasks.py # Celery tasks └── ui/ # Frontend └── timeline/ # React app ``` ## Environment Variables See `ctrl/.env.template` for all configuration options. | Variable | Default | Description | |----------|---------|-------------| | `DATABASE_URL` | sqlite | PostgreSQL connection string | | `REDIS_URL` | redis://localhost:6379 | Redis for Celery | | `GRPC_HOST` | grpc | gRPC server hostname | | `GRPC_PORT` | 50051 | gRPC server port | | `MPR_EXECUTOR` | local | Executor type (local/lambda) | | `MEDIA_ROOT` | /app/media | Media files directory | | `MEDIA_BASE_URL` | /media/ | Base URL for serving media (use S3 URL for cloud) | | `VITE_ALLOWED_HOSTS` | - | Comma-separated allowed hosts for Vite dev server | ## License MIT