A scalable and production-ready YouTube backend built with Node.js, Express, MongoDB, and Cloudinary for media management.
- User Authentication: Secure login/signup with JWT authentication & bcrypt password hashing.
- Video Upload & Management: Upload, delete, and manage videos using Multer & Cloudinary.
- Comments & Playlists: Add, delete, and organize videos into playlists.
- Pagination & Filtering: Efficient Mongoose Aggregate Pagination for videos and comments.
- Secure Cookies & CORS: Implemented Cookie-Parser & CORS for safe & smooth API access.
- Backend: Node.js, Express.js
- Database: MongoDB & Mongoose
- Authentication: JWT & Bcrypt
- File Uploads: Multer & Cloudinary
- Security: Cookie-Parser, CORS
- Pagination: Mongoose Aggregate Paginate V2
-
Clone the repository:
git clone https://github.com/your-username/03chaibackend.git cd 03chaibackend
-
Install dependencies:
npm install
-
Set up environment variables in a
.env
file:PORT=5000 MONGO_URI=your_mongodb_connection_string JWT_SECRET=your_secret_key CLOUDINARY_CLOUD_NAME=your_cloud_name CLOUDINARY_API_KEY=your_api_key CLOUDINARY_API_SECRET=your_api_secret
-
Run the backend in development mode:
npm run dev
POST /api/auth/signup
→ User signupPOST /api/auth/login
→ User login
POST /api/videos/upload
→ Upload a videoGET /api/videos/:id
→ Get video detailsDELETE /api/videos/:id
→ Delete a video
POST /api/comments/:videoId
→ Add commentDELETE /api/comments/:commentId
→ Delete commentPOST /api/playlists
→ Create a playlistPOST /api/playlists/:playlistId/add
→ Add video to playlistDELETE /api/playlists/:playlistId/remove/:videoId
→ Remove video from playlist
📦 03ChaiBackend
├── 📂 src
│ ├── 📂 controllers # Route logic
│ ├── 📂 models # Mongoose models
│ ├── 📂 routes # API endpoints
│ ├── 📂 middlewares # Auth & validation middleware
│ ├── 📂 config # Cloudinary, DB connections
│ ├── index.js # Entry point
├── .env.example # Environment variable template
├── package.json # Dependencies & scripts
└── README.md # Documentation
- Modular Codebase: Clean and organized structure.
- Scalable Authentication: Secure JWT-based login.
- Production-Ready Code: Optimized for real-world use.
- Easily Switchable Storage: Can replace Cloudinary with any other media service.
- Live Streaming Integration
- AI-Based Video Recommendations
- Advanced Search & Filters
Aditya Singh
If you'd like to contribute, feel free to fork the repo and submit a PR!
This project is ISC Licensed. Feel free to use and modify as needed!