# Media Storage Architecture ## Overview MPR stores media file paths **relative to the media root** to ensure portability between local development and cloud deployments (AWS S3, etc.). ## Storage Strategy ### File Path Storage - **Database**: Stores only the relative path (e.g., `videos/sample.mp4`) - **Media Root**: Configurable base directory via `MEDIA_ROOT` env var - **Serving**: Base URL configurable via `MEDIA_BASE_URL` env var ### Why Relative Paths? 1. **Portability**: Same database works locally and in cloud 2. **Flexibility**: Easy to switch between storage backends 3. **Simplicity**: No need to update paths when migrating ## Local Development ### Configuration ```bash MEDIA_ROOT=/app/media ``` ### File Structure ``` /app/media/ ├── video1.mp4 ├── video2.mp4 └── subfolder/ └── video3.mp4 ``` ### Database Storage ``` filename: video1.mp4 file_path: video1.mp4 filename: video3.mp4 file_path: subfolder/video3.mp4 ``` ### URL Serving - Nginx serves via `location /media { alias /app/media; }` - Frontend accesses: `http://mpr.local.ar/media/video1.mp4` - Video player: `