{"id":21769515,"url":"https://github.com/awalhossain/video-streaming-server","last_synced_at":"2025-04-13T16:22:46.093Z","repository":{"id":108615192,"uuid":"475306382","full_name":"AwalHossain/video-streaming-server","owner":"AwalHossain","description":"MERN Video Streaming Web Application","archived":false,"fork":false,"pushed_at":"2025-04-07T13:59:33.000Z","size":1879,"stargazers_count":12,"open_issues_count":3,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-07T14:29:41.686Z","etag":null,"topics":["bullmq","expressjs","mongodb","nodejs","react","reactjs","redis","socket-io"],"latest_commit_sha":null,"homepage":"https://reely.tech/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AwalHossain.png","metadata":{"files":{"readme":"ReadME.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-03-29T06:18:49.000Z","updated_at":"2025-04-07T13:59:36.000Z","dependencies_parsed_at":"2024-05-18T10:38:24.241Z","dependency_job_id":"c0fa93b2-06c7-4377-b797-6b640380ef4b","html_url":"https://github.com/AwalHossain/video-streaming-server","commit_stats":null,"previous_names":["awalhossain/video-streaming-server","awalhossain/video_streaming_service_server"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AwalHossain%2Fvideo-streaming-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AwalHossain%2Fvideo-streaming-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AwalHossain%2Fvideo-streaming-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AwalHossain%2Fvideo-streaming-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AwalHossain","download_url":"https://codeload.github.com/AwalHossain/video-streaming-server/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248741883,"owners_count":21154401,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bullmq","expressjs","mongodb","nodejs","react","reactjs","redis","socket-io"],"created_at":"2024-11-26T14:09:06.265Z","updated_at":"2025-04-13T16:22:46.086Z","avatar_url":"https://github.com/AwalHossain.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🎥 Scallable Video Streaming Platform 🍿 (Work in Progress!)\n\n![Project Architecture](Architecture.png)\n\nHey there! 👋 This project is a cool video streaming service, a bit like a mini-YouTube or Netflix, built using Node.js, Express, React (eventually!), MongoDB, and TypeScript.\n\n**What it does:**\n\n*   Lets users upload videos.\n*   Automatically converts those videos into different quality levels (like 480p, 1080p) using a format called HLS (HTTP Live Streaming). This means smoother playback for everyone, even with slower internet!\n*   Uses a microservices approach, meaning different parts of the system run as separate small services, making it easier to manage and scale.\n\n## 🌟 Cool Features\n\n*   **Smooth Streaming (Adaptive Bitrate):** Videos play nicely by adjusting quality based on your internet speed. No more endless buffering!\n*   **Upload \u0026 Forget:** Just upload your video (any common format), and the system handles the conversion magic in the background.\n*   **Real-time Updates:** See the progress of your video processing as it happens (thanks to Socket.IO and RabbitMQ).\n*   **Cloud Powered:** Videos are stored securely and served efficiently from cloud storage (like AWS S3 or Digital Ocean Spaces).\n*   **Built to Grow (Microservices):** The separate services can be updated or scaled independently.\n\n## 🏗️ How It's Built (The Architecture)\n\nThink of the system like a small team working together:\n\n1.  **📡 API Gateway (The Front Door):**\n    *   Handles all incoming requests from the app (like upload requests).\n    *   Checks if users are logged in (authentication).\n    *   Generates secure, temporary links (pre-signed URLs) so users can upload *directly* to cloud storage (faster!).\n    *   Sends real-time updates back to the user's screen using WebSockets (Socket.IO).\n\n2.  **📚 API Server (The Librarian):**\n    *   Keeps track of all the important info: user details, video titles, descriptions, and processing status.\n    *   Stores everything neatly in a MongoDB database.\n    *   Listens for updates from other services to keep the video status current.\n\n3.  **🎬 Video Conversion Service (The Video Wizard):**\n    *   This is where the heavy lifting happens! It doesn't talk directly to the outside world.\n    *   Grabs newly uploaded videos from cloud storage.\n    *   Uses the powerful **FFmpeg** tool to convert videos to MP4 (if needed) and then into those HLS formats (480p, 1080p, etc.).\n    *   Uses **BullMQ** (with Redis) like a checklist to manage all the conversion steps for each video.\n    *   Uploads the final HLS video files back to cloud storage.\n    *   Sends status updates (\"Processing...\", \"Converting...\", \"Done!\") via **RabbitMQ** (our internal messenger).\n\n**How they talk:**\n\n*   The services mostly send messages to each other asynchronously using **RabbitMQ**.\n*   The **API Gateway** uses **Socket.IO** to send real-time updates directly to the user's browser.\n\n## 🌊 The Flow: From Upload to Playback\n\n![Streaming Sequence Diagram](stream-diagram.png)\n\nHere's a simplified step-by-step of what happens when you upload a video:\n\n1.  **You:** Click \"Upload\" in the app.\n2.  **App:** Asks the **API Gateway** for permission to upload.\n3.  **API Gateway:** Gets a temporary, secure upload link (pre-signed URL) from **Cloud Storage**.\n4.  **API Gateway:** Sends the link back to your **App**.\n5.  **App:** Uploads the video file *directly* to **Cloud Storage** using the special link.\n6.  **App:** Tells the **API Gateway**, \"Okay, the upload is done!\"\n7.  **API Gateway:** Tells the **API Server** to save the video info (title, etc.) in **MongoDB** with status \"Pending\".\n8.  **API Gateway:** Sends a message via **RabbitMQ** to the **Video Conversion** service: \"New video ready!\".\n9.  **Video Conversion:** Gets the message, downloads the video from **Cloud Storage**.\n10. **Video Conversion:** Starts processing the video using **FFmpeg** (managed by **BullMQ/Redis** queue):\n    *   Convert to MP4 (if needed).\n    *   Generate Thumbnail.\n    *   Convert to HLS (multiple qualities).\n11. **Video Conversion:** Sends progress updates (\"Converting 50%...\") via **RabbitMQ**.\n12. **API Gateway:** Gets the progress updates and sends them to your **App** using **Socket.IO**. You see the progress bar move!\n13. **Video Conversion:** Finishes processing, uploads the HLS files (.m3u8 playlist and .ts video chunks) back to **Cloud Storage**.\n14. **Video Conversion:** Sends a final \"Done!\" message via **RabbitMQ**.\n15. **API Server:** Gets the \"Done!\" message and updates the video status in **MongoDB** to \"Success\" and saves the link to the main HLS file (`master.m3u8`).\n16. **You:** Click play on the video in the app. The player asks the **API Server** for the video details, gets the HLS link, and starts streaming smoothly from the **Cloud Storage** (likely via a CDN)!\n\n## 🛠️ Tech Stack\n\n*   **Backend:** Node.js, Express.js, TypeScript\n*   **Database:** MongoDB (with Mongoose ODM)\n*   **Video Processing:** FFmpeg\n*   **Messaging:** RabbitMQ\n*   **Job Queue:** BullMQ (using Redis)\n*   **Real-time Comms:** Socket.IO\n*   **Authentication:** JWT (JSON Web Tokens)\n*   **Cloud Storage:** AWS S3 / Digital Ocean Spaces / Azure Blob Storage\n*   **Containerization:** Docker \u0026 Docker Compose\n\n## 🚀 Getting Started\n\nWant to run this project locally? Here's how:\n\n**1. Prerequisites (What you need first):**\n\n*   **Node.js:** Version 18 or higher (`node -v`)\n*   **Yarn:** (`yarn -v`) or npm (`npm -v`)\n*   **Docker \u0026 Docker Compose:** The easiest way to run everything. [Install Docker here](https://docs.docker.com/get-docker/).\n*   **FFmpeg:** The video tool. Install it on your system (e.g., `brew install ffmpeg` on Mac, or follow guides for Windows/Linux).\n*   **Git:** To download the code (`git --version`).\n\n**2. Clone the Code:**\n\n```bash\ngit clone https://github.com/AwalHossain/video-streaming-server \ncd video-streaming-server\n```\n\n**3. Set Up Environment Variables:**\n\nEach service needs its own configuration (like passwords, API keys).\n\n*   Go into *each* service directory (`api-gateway`, `api-server`, `video-conversion`).\n*   Find the `.env.example` file.\n*   **Copy** it to a new file named `.env` in the *same* directory.\n*   **Edit** each `.env` file and fill in your details (database connection strings, cloud storage keys, JWT secret, etc.).\n\n**4. Run with Docker Compose (Recommended):**\n\nThis starts all services (API Gateway, API Server, Video Conversion) AND the dependencies (MongoDB, RabbitMQ, Redis) in containers.\n\n```bash\ndocker-compose up -d --build\n```\n\n*   `--build`: Builds the Docker images the first time.\n*   `-d`: Runs the containers in the background (detached mode).\n\nYou should see output as the containers start. Check `docker ps` to see running containers.\n\n**5. Run Manually (Alternative):**\n\nIf you only want to run dependencies in Docker:\n\n```bash\n# Make sure you are in the root directory of the project\ndocker-compose up -d mongodb rabbitmq redis\n```\n\nThen, for *each* service (`api-gateway`, `api-server`, `video-conversion`):\n\n```bash\ncd \u003cservice-directory\u003e  # e.g., cd api-gateway\nyarn install            # Install dependencies\nyarn dev                # Start the service in development mode (watches for changes)\ncd ..                   # Go back to the root directory\n```\n\n**6. Accessing the Services:**\n\n*   **API Gateway:** Usually `http://localhost:8000` (check your `.env` file for the port)\n*   **API Server:** Usually `http://localhost:8001`\n*   **Video Conversion:** Usually `http://localhost:8002` (Note: This service might not have many accessible HTTP endpoints itself)\n*   **RabbitMQ Management:** `http://localhost:15672` (User/Pass often guest/guest by default)\n\n## 📝 Project Status\n\nThis project is currently **under development**. Features are being added and improved!\n\n## 📚 Useful Docs\n\n*   [FFmpeg Documentation](https://ffmpeg.org/documentation.html)\n*   [RabbitMQ Documentation](https://www.rabbitmq.com/documentation.html)\n*   [Socket.IO Documentation](https://socket.io/docs/v4/)\n*   [BullMQ Documentation](https://docs.bullmq.io/)\n*   [Mongoose Documentation](https://mongoosejs.com/docs/guide.html)\n\n---\n\nThanks for checking out the project! Stay tuned for more updates.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fawalhossain%2Fvideo-streaming-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fawalhossain%2Fvideo-streaming-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fawalhossain%2Fvideo-streaming-server/lists"}