A FastAPI-based video streaming platform that supports user management, video uploads, and real-time video playback with advanced streaming features.
- User registration and authentication
- User login/logout functionality
- User profile management and information updates
- Video upload functionality for registered users
- Video management dashboard for content creators
- Real-time video streaming and playback
- Streaming analytics and metrics
- Buffering optimization
- Playback position tracking and resume
- View count tracking and analytics
- Real-time streaming support
- Backend: FastAPI (Python)
- Database: MySQL
- Package Manager: uv
- Containerization: Docker
- Frontend: (To be determined based on implementation needs)
The application follows a modern microservices architecture:
- FastAPI backend for API endpoints
- MySQL database for persistent data storage
- Docker containers for deployment and development
- Real-time streaming capabilities for video content
- Docker and Docker Compose
- uv (Python package manager)
- MySQL 8.0+
-
Environment Setup
# Install uv if not already installed curl -LsSf https://astral.sh/uv/install.sh | sh
-
Project Setup
# Clone and navigate to project cd video-serving-experiment # Install backend dependencies using uv uv sync # Install frontend dependencies cd frontend npm install cd ..
-
Docker Setup
# Build and start all services (backend, frontend, database) docker-compose up --build -
Database Migration
# Run database migrations (after containers are running) uv run alembic upgrade head -
Access the Application
- Frontend: http://localhost:5173
- Backend API: http://localhost:8000
- API Documentation: http://localhost:8000/docs
POST /api/auth/register- User registrationPOST /api/auth/login- User loginPOST /api/auth/logout- User logoutGET /api/auth/me- Get current user infoPUT /api/auth/profile- Update user profile
POST /api/videos/upload- Upload videoGET /api/videos- List videosGET /api/videos/{video_id}- Get video detailsDELETE /api/videos/{video_id}- Delete video (owner only)PUT /api/videos/{video_id}- Update video metadata
GET /api/stream/{video_id}- Stream video contentPOST /api/videos/{video_id}/view- Record video viewGET /api/videos/{video_id}/analytics- Get video analytics
Environment variables:
DATABASE_URL- MySQL connection stringSECRET_KEY- JWT secret keyUPLOAD_PATH- Video file storage pathMAX_UPLOAD_SIZE- Maximum video file size
- Follow FastAPI best practices
- Use uv for dependency management
- Containerize all services with Docker
- Implement proper error handling and logging
- Follow REST API conventions
- Use MySQL for persistent storage
video-serving-experiment/
├── app/ # FastAPI Backend
│ ├── api/
│ │ ├── auth/ # Authentication endpoints
│ │ ├── videos/ # Video management endpoints
│ │ └── streaming/ # Video streaming endpoints
│ ├── core/
│ │ ├── config.py # Configuration
│ │ ├── database.py # Database setup
│ │ └── security.py # Security utilities
│ ├── models/ # SQLAlchemy models
│ ├── schemas/ # Pydantic schemas
│ └── services/ # Business logic
├── frontend/ # Svelte Frontend
│ ├── src/
│ │ ├── routes/ # Svelte pages
│ │ ├── components/ # Reusable components
│ │ ├── stores/ # State management
│ │ └── lib/ # API integration
│ ├── package.json
│ └── Dockerfile
├── alembic/ # Database migrations
├── docker-compose.yml # Multi-container setup
├── Dockerfile # Backend container
└── pyproject.toml # Python dependencies