VideoTube is a full-stack web application inspired by YouTube, built with the MERN stack (MongoDB, Express.js, React, Node.js). It allows users to upload, watch, like, comment on videos, and subscribe to channels.
- Features
- Tech Stack
- API Documentation
- Installation
- Environment Variables
- Project Structure
- Contributing
- π JWT Authentication - Secure user registration and login
- π€ Video Upload - Upload videos with thumbnails
βΆοΈ Video Streaming - Watch videos with responsive player- π Like System - Like videos, comments, and tweets
- π¬ Comments - Add, edit, and delete comments
- π Channel Analytics - View channel statistics and metrics
- π Subscriptions - Subscribe/unsubscribe to channels
- π Tweet System - Create and interact with tweet-like posts
- β€οΈ Playlists - Create and manage video playlists
- π± Responsive Design - Works on desktop and mobile devices
- β‘ Performance Optimized - Fast loading with pagination
- React - UI framework
- Tailwind CSS - Styling
- Axios - HTTP client
- React Router - Navigation
- Context API - State management
- Node.js - Runtime environment
- Express.js - Web framework
- MongoDB - Database
- Mongoose - ODM
- JWT - Authentication
- Bcrypt - Password hashing
- Multer - File uploads
- Cloudinary - Media storage (optional)
- Nodemon - Development server
- Postman - API testing
http://localhost:5000/api/v1
All endpoints (except auth endpoints) require JWT authentication via Bearer token.
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
POST |
/users/register |
Register new user | No |
POST |
/users/login |
Login user | No |
POST |
/users/logout |
Logout user | Yes |
POST |
/users/refresh-token |
Refresh access token | No |
GET |
/users/current-user |
Get current user | Yes |
POST |
/users/change-password |
Change password | Yes |
PATCH |
/users/update-account |
Update account | Yes |
PATCH |
/users/avatar |
Update avatar | Yes |
PATCH |
/users/cover-image |
Update cover image | Yes |
GET |
/users/c/:username |
Get channel profile | No |
GET |
/users/history |
Get watch history | Yes |
DELETE |
/users |
Delete account & videos | Yes |
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
GET |
/videos |
Get all videos | No |
POST |
/videos/publish |
Upload video | Yes |
GET |
/videos/:videoId |
Get video details | No |
PATCH |
/videos/:videoId/edit |
Update video | Yes |
DELETE |
/videos/:videoId |
Delete video | Yes |
PATCH |
/videos/:videoId |
Toggle publish status | Yes |
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
POST |
/subscriptions/:channelId |
Toggle subscription | Yes |
GET |
/subscriptions/:channelId |
Get subscribers | Yes |
GET |
/subscriptions |
Get subscribed channels | Yes |
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
GET |
/playlists |
Get user playlists | Yes |
POST |
/playlists |
Create playlist | Yes |
GET |
/playlists/:playlistId |
Get playlist | Yes |
PATCH |
/playlists/:playlistId |
Update playlist | Yes |
DELETE |
/playlists/:playlistId |
Delete playlist | Yes |
PATCH |
/playlists/add/:playlistId/:videoId |
Add video to playlist | Yes |
PATCH |
/playlists/remove/:playlistId/:videoId |
Remove video from playlist | Yes |
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
POST |
/likes/video/:videoId |
Toggle video like | Yes |
GET |
/likes/video/:videoId |
Get video likes count | Yes |
POST |
/likes/comment/:commentId |
Toggle comment like | Yes |
GET |
/likes/comment/:commentId |
Get comment likes count | Yes |
POST |
/likes/tweet/:tweetId |
Toggle tweet like | Yes |
GET |
/likes/tweet/:tweetId |
Get tweet likes count | Yes |
GET |
/likes |
Get user's liked videos | Yes |
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
GET |
/comments/:videoId |
Get video comments | Yes |
POST |
/comments/:videoId |
Add comment | Yes |
PATCH |
/comments/c/:commentId |
Update comment | Yes |
DELETE |
/comments/c/:commentId |
Delete comment | Yes |
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
POST |
/tweets |
Create tweet | Yes |
GET |
/tweets/user/:username |
Get user tweets | Yes |
PATCH |
/tweets/:tweetId |
Update tweet | Yes |
DELETE |
/tweets/:tweetId |
Delete tweet | Yes |
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
GET |
/dashboard/stats/:userId |
Get channel stats | Yes |
GET |
/dashboard/videos/:userId |
Get channel videos | Yes |
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
GET |
/healthcheck |
Health check | No |
- Node.js (v14 or higher)
- MongoDB (local or Atlas)
- npm or yarn
git clone https://github.com/Pranav8206/VideoTube.git
cd videotubecd backend
npm installcd ../frontend
npm installCreate a .env file in the backend directory:
PORT=5000
MONGODB_URI=mongodb://localhost:27017/videotube
JWT_SECRET=your_super_secret_jwt_key_here
JWT_REFRESH_SECRET=your_super_secret_refresh_key_here
CLOUDINARY_CLOUD_NAME=your_cloudinary_name
CLOUDINARY_API_KEY=your_cloudinary_api_key
CLOUDINARY_API_SECRET=your_cloudinary_api_secret
CORS_ORIGIN=http://localhost:5173# Start backend (from backend directory)
npm run dev
# Start frontend (from frontend directory, in a new terminal)
npm startThe application will be available at:
- Frontend: http://localhost:5173
- Backend API: http://localhost:5000
| Variable | Description | Example |
|---|---|---|
PORT |
Backend server port | 5000 |
MONGODB_URI |
MongoDB connection string | mongodb://localhost:27017/videotube |
JWT_SECRET |
Secret key for JWT tokens | your_jwt_secret |
JWT_REFRESH_SECRET |
Secret key for refresh tokens | your_refresh_secret |
CLOUDINARY_* |
Cloudinary credentials for media storage | (Optional) |
CORS_ORIGIN |
Allowed origin for CORS | http://localhost:5000 |
videotube/
|
βββ backend/
β βββ controllers/ # Route controllers
β βββ db/ # Database configuration
β βββ middlewares/ # Custom middleware
β βββ models/ # MongoDB models
β βββ routes/ # API routes
β βββ utils/ # Utility functions
β βββ app.js # Express app setup
|
βββ frontend/
β βββ public/ # Static files
β βββ src/
β βββ components/ # React components
β βββ pages/ # Page components
β βββ context/ # React context API
β βββ utils/ # Utility functions
β
βββ README.md
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the project
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Please ensure your code follows the project's style guidelines and includes appropriate tests.
- Inspired by YouTube
- Built with the MERN stack
- Icons from Lucide icons
- UI components with Tailwind CSS
Note: This is a only portfolio project.