A YouTube clone built with FastAPI and React. Videos are transcoded to HLS adaptive bitrate streams, stored in Cloudflare R2, and streamed directly to the client.
- User registration and JWT-based authentication
- Video upload with real-time processing progress
- HLS adaptive bitrate streaming (hls.js with native Safari fallback)
- Likes and comments with per-video moderation
- View count tracking
| Layer | Technology |
|---|---|
| Backend | FastAPI + Uvicorn |
| ORM | SQLModel (SQLAlchemy + Pydantic) |
| Database | PostgreSQL via Supabase |
| Auth | JWT (python-jose) + bcrypt |
| Video processing | python-ffmpeg-video-streaming + FFmpeg |
| Storage | Cloudflare R2 (boto3 S3-compatible) |
| Migrations | Alembic |
| Frontend | React + TypeScript + Vite |
| Styling | Tailwind CSS |
PyTube/
├── backend/
│ ├── app/
│ │ ├── api/
│ │ │ ├── deps.py # Dependency injection (auth, session)
│ │ │ └── endpoints/ # auth, users, videos, upload, stream, likes, comments
│ │ ├── models/ # SQLModel DB models
│ │ ├── schemas/ # Pydantic request/response schemas
│ │ ├── services/ # auth, storage, video processing
│ │ └── tests/
│ └── alembic/ # DB migrations
└── frontend/
└── src/
├── api/ # Axios API clients
├── components/ # Shared UI components
├── context/ # Auth context
├── pages/ # Route-level page components
├── types/ # TypeScript interfaces
└── utils/ # Shared utilities
Backend — from backend/:
.venv/bin/uvicorn app.main:app --reloadRuns on http://localhost:8000. API docs at http://localhost:8000/docs.
Frontend — from frontend/:
npm run devRuns on http://localhost:5173.
Copy the example files and fill in your values:
cp backend/.env.example backend/.env
cp frontend/.env.example frontend/.envFrom backend/:
.venv/bin/pytest app/tests/