A full-stack YouTube clone application built with React and Node.js, featuring user authentication, video upload, comments, and a modern responsive UI.
- Modern UI/UX: Responsive design with dark/light theme support
- Video Management: Upload, watch, and browse videos
- User Authentication: Sign up, sign in, and Google OAuth integration
- Interactive Features:
- Like/dislike videos
- Comment on videos
- Subscribe to channels
- Search functionality
- Video recommendations
- State Management: Redux Toolkit for centralized state
- Real-time Updates: Dynamic video views and engagement metrics
- RESTful API: Express.js server with organized routes
- Authentication: JWT-based authentication with secure password hashing
- Database: MongoDB with Mongoose ODM
- User Management: User profiles with subscription system
- Video Operations: CRUD operations for videos
- Comments System: Full comment management with user association
- React 19 - UI library
- Vite - Build tool and dev server
- Material-UI (MUI) - Component library
- Redux Toolkit - State management
- React Router - Navigation
- Firebase - Google authentication
- Styled Components - CSS-in-JS styling
- Axios - HTTP client
- Node.js - Runtime environment
- Express.js - Web framework
- MongoDB - Database
- Mongoose - ODM
- JWT - Authentication tokens
- bcryptjs - Password hashing
- Cookie Parser - Cookie handling
- CORS - Cross-origin resource sharing
Before you begin, ensure you have the following installed:
- Node.js (v18.0.0 or higher)
- npm or yarn package manager
- MongoDB (local installation or MongoDB Atlas account)
- Firebase Account (for Google authentication)
git clone https://github.com/NewtonY-dev/youtube-clone.git
cd youtube-clonecd frontend
npm installcd server
npm installCreate a .env file in the server directory:
MONGO=your_mongodb_connection_string
JWT=your_jwt_secret_keyExample:
MONGO=mongodb://localhost:27017/youtube-clone
# or for MongoDB Atlas:
# MONGO=mongodb+srv://username:[email protected]/youtube-clone?retryWrites=true&w=majority
JWT=your_super_secret_jwt_key_hereCreate a .env file in the frontend directory:
VITE_FIREBASE_API_KEY=your_firebase_api_key
VITE_FIREBASE_AUTH_DOMAIN=your_firebase_auth_domain
VITE_FIREBASE_PROJECT_ID=your_firebase_project_id
VITE_FIREBASE_STORAGE_BUCKET=your_firebase_storage_bucket
VITE_FIREBASE_MESSAGING_SENDER_ID=your_firebase_messaging_sender_id
VITE_FIREBASE_APP_ID=your_firebase_app_idcd server
npm startThe server will run on http://localhost:8080
Open a new terminal:
cd frontend
npm run devThe frontend will run on http://localhost:5173 (or the next available port)
youtube-clone/
βββ frontend/
β βββ src/
β β βββ components/ # Reusable UI components
β β β βββ Card.jsx # Video card component
β β β βββ Comment.jsx # Comment component
β β β βββ Comments.jsx # Comments section
β β β βββ Menu.jsx # Sidebar menu
β β β βββ Navbar.jsx # Navigation bar
β β β βββ Recommendation.jsx
β β β βββ Upload.jsx # Video upload component
β β βββ pages/ # Page components
β β β βββ Home.jsx # Home page
β β β βββ Video.jsx # Video player page
β β β βββ Search.jsx # Search results page
β β β βββ SignIn.jsx # Authentication page
β β βββ redux/ # Redux store and slices
β β β βββ store.js
β β β βββ userSlice.js
β β β βββ videoSlice.js
β β βββ utils/ # Utility functions
β β β βββ Theme.jsx # Theme configuration
β β βββ firebase.js # Firebase configuration
β β βββ App.jsx # Main app component
β β βββ main.jsx # Entry point
β βββ package.json
β βββ vite.config.js
β
βββ server/
β βββ controllers/ # Route controllers
β β βββ auth.js
β β βββ user.js
β β βββ video.js
β β βββ comment.js
β βββ models/ # Mongoose models
β β βββ User.js
β β βββ Video.js
β β βββ Comment.js
β βββ routes/ # Express routes
β β βββ auth.js
β β βββ users.js
β β βββ videos.js
β β βββ comments.js
β βββ verifyToken.js # JWT verification middleware
β βββ error.js # Error handling
β βββ index.js # Server entry point
β βββ package.json
β
βββ .gitignore
βββ README.md
POST /api/auth/signup- Register a new userPOST /api/auth/signin- Sign in existing userPOST /api/auth/google- Google OAuth authentication
GET /api/users/:id- Get user by IDPUT /api/users/:id- Update userDELETE /api/users/:id- Delete userPUT /api/users/sub/:id- Subscribe/Unsubscribe to user
GET /api/videos- Get all videosGET /api/videos/:id- Get video by IDPOST /api/videos- Create new video (requires auth)PUT /api/videos/:id- Update video (requires auth)DELETE /api/videos/:id- Delete video (requires auth)PUT /api/videos/view/:id- Increment video viewsGET /api/videos/trend- Get trending videosGET /api/videos/random- Get random videosGET /api/videos/sub- Get subscribed channels' videos (requires auth)GET /api/videos/tags- Get videos by tagsGET /api/videos/search- Search videos
GET /api/comments/:videoId- Get comments for a videoPOST /api/comments- Create a comment (requires auth)DELETE /api/comments/:id- Delete a comment (requires auth)
- Secure password hashing with bcryptjs
- JWT token-based authentication
- Google OAuth integration via Firebase
- Cookie-based session management
- Upload videos with metadata (title, description, tags)
- Video thumbnails and preview images
- View count tracking
- Like/dislike functionality
- Tag-based categorization
- Search and filter capabilities
- User subscriptions
- Comment system with user association
- Channel subscriber counts
- Video recommendations based on tags
npm run dev # Start development server
npm run build # Build for production
npm run preview # Preview production build
npm run lint # Run ESLintnpm start # Start server with nodemon (auto-reload)- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow the existing code style
- Write clear commit messages
- Test your changes thoroughly
- Update documentation if needed
- Ensure ESLint passes without errors
MongoDB Connection Error
- Ensure MongoDB is running locally or your Atlas connection string is correct
- Check that your
.envfile has the correctMONGOvariable
Port Already in Use
- Change the port in
server/index.js(currently 8080) - Or kill the process using the port:
npx kill-port 8080
Firebase Authentication Not Working
- Verify all Firebase environment variables are set correctly
- Check Firebase console for API key and project configuration
CORS Errors
- Ensure backend CORS is properly configured
- Check that frontend proxy settings in
vite.config.jsare correct
Module Not Found
- Delete
node_modulesandpackage-lock.json - Run
npm installagain in both frontend and server directories
This project is licensed under the MIT License.
Copyright (c) 2025 Newton Yetsedaw
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Newton Yetsedaw
- GitHub: @NewtonY-dev
- Repository: youtube-clone
- YouTube for design inspiration
- All open-source contributors and libraries used in this project
β If you find this project helpful, please consider giving it a star!