Skip to content

faqirullahafridi/Youtube-clone

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

YouTube Clone - Flask Implementation

A full-featured video sharing platform with YouTube-like functionality built with Flask, React, and modern web technologies.

Features

Authentication & Authorization

  • Email/password registration and login
  • Password reset and email verification
  • JWT-based sessions
  • Role-based access control (user, moderator, admin)

User Profiles & Channels

  • User profiles with avatars
  • Channel pages with banners and descriptions
  • Subscribe/unsubscribe functionality

Video Management

  • Resumable/chunked video uploads with progress tracking
  • Server-side transcoding to multiple resolutions (1080p, 720p, 480p, 360p)
  • Automatic and custom thumbnail generation
  • Metadata extraction (duration, resolution, bitrate)

Storage & Streaming

  • Local file storage for development
  • S3-compatible storage (AWS S3 for production)
  • HLS streaming with master playlists
  • Signed short-lived URLs for secure access

Playback Experience

  • Custom HTML5/JS player
  • Resolution selector
  • Captions/subtitles toggle
  • Playback speed control
  • Picture-in-Picture support
  • Autoplay next video

Social & Engagement

  • Like/dislike functionality
  • Threaded comments with replies
  • Edit/delete for content owners
  • Report system for moderation
  • Watch later playlists
  • User playlists

Search & Discovery

  • Full-text search on titles, descriptions, and tags
  • Trending videos feed
  • Recommended videos based on subscriptions
  • Subscription feed

Notifications

  • In-app notifications for new uploads and comment replies

Admin Dashboard

  • Content moderation
  • User management
  • Report handling
  • Analytics dashboard

Tech Stack

Frontend

  • React with TypeScript
  • Tailwind CSS for styling
  • Responsive design for all device sizes

Backend

  • Flask with Blueprints
  • SQLAlchemy ORM
  • Alembic for database migrations
  • Flask-JWT-Extended for authentication
  • Celery with Redis for background tasks

Workers

  • Celery workers for video processing
  • FFmpeg for transcoding and thumbnail generation

Database

  • PostgreSQL (or SQLite for local development)

Storage

  • Local file system for development
  • AWS S3 for production

Project Structure

youtube-clone/
├── backend/           # Flask API server
├── frontend/          # React frontend
├── worker/            # Celery workers for video processing
├── docs/              # Documentation
└── README.md          # This file

Getting Started (Without Docker)

Prerequisites

  • Python 3.8+
  • Node.js 14+
  • PostgreSQL (optional, can use SQLite for development)
  • Redis
  • FFmpeg
  • Git

Backend Setup

  1. Navigate to the backend directory:

    cd backend
  2. Create a virtual environment:

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
  3. Install dependencies:

    pip install -r requirements.txt
  4. Copy the example environment file:

    cp .env.example .env
  5. Update the .env file with your local configuration:

    # For local development with SQLite
    DATABASE_URL=sqlite:///youtube.db
    
    # For PostgreSQL
    # DATABASE_URL=postgresql://username:password@localhost:5432/youtube_dev
  6. Run database migrations:

    flask db upgrade
  7. Start the backend server:

    flask run

Frontend Setup

  1. Navigate to the frontend directory:

    cd frontend
  2. Install dependencies:

    npm install
  3. Start the development server:

    npm start

Worker Setup

  1. Navigate to the worker directory:

    cd worker
  2. Create a virtual environment:

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
  3. Install dependencies:

    pip install -r requirements.txt
  4. Start the worker:

    celery -A worker worker --loglevel=info

Environment Variables

The application uses environment variables for configuration. See .env.example for all available options.

For local development without Docker, you'll need to:

  1. Install PostgreSQL or use SQLite
  2. Install Redis server
  3. Install FFmpeg
  4. Configure the .env file appropriately

Development

Project Structure Details

Backend (backend/)

  • app.py - Main Flask application
  • config.py - Configuration settings
  • requirements.txt - Python dependencies
  • app/ - Application modules
    • auth/ - Authentication and user management
    • videos/ - Video management and processing
    • users/ - User and channel management
    • admin/ - Admin and moderation features
    • models.py - Database models
  • migrations/ - Database migrations
  • tests/ - Unit and integration tests
  • docs/ - API documentation

Frontend (frontend/)

  • package.json - Node.js dependencies
  • src/ - Source code
  • public/ - Static assets

Worker (worker/)

  • worker.py - Celery worker implementation
  • requirements.txt - Python dependencies

Database Migrations

The application uses Alembic for database migrations:

# Generate a new migration
flask db migrate -m "Description of changes"

# Apply migrations
flask db upgrade

API Documentation

API documentation is available in backend/docs/api.md or by accessing /api/docs when the backend is running.

Testing

Backend Tests

# Run all tests
pytest

# Run specific test file
pytest tests/test_auth.py

Test Coverage

The project aims for >70% test coverage for critical backend functionality.

Deployment

Production Deployment

See docs/deployment.md for detailed deployment instructions.

Environment Differences

  • Development: Uses local file storage, SQLite or local PostgreSQL and Redis
  • Production: Uses AWS S3 for storage, managed PostgreSQL and Redis

Architecture

See docs/architecture.md for detailed architecture diagrams and explanations.

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Write tests for new functionality
  5. Run all tests to ensure nothing is broken
  6. Submit a pull request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

For support, please open an issue on the GitHub repository.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published