This is a robust, full-featured backend application built as a part of backend learning using Node.js, Express, and MongoDB. The project implements scalable APIs for managing users, videos, playlists, likes, subscriptions, comments, and even tweets.
mrastatine-backend-learning/
├── package.json
└── src/
├── app.js # Express app setup & route bindings
├── index.js # Entry point + DB connect
├── constants.js # App-wide constants
├── controllers/ # All route logic
├── db/ # MongoDB connection
├── middlewares/ # Auth, multer
├── models/ # Mongoose schemas
├── routes/ # Express routers
└── utils/ # Custom utils (error, responses, etc.)
- 🧑🎓 User Management: Registration, login, profile update, password change
- 🧵 Tweet System: Create, update, delete tweets
- 🎬 Video Module: Upload, manage, and toggle publish status of videos
- 🎥 Playlist Management: Create, edit, and delete user playlists
- 💬 Commenting System: Add/edit/delete comments under videos
- ❤️ Like System: Toggle likes on tweets, videos, and comments
- 📊 Channel Dashboard: Get channel-level stats like views and likes
- 🔔 Subscriptions: Subscribe/unsubscribe to users
- 🔁 Token Refresh: Full JWT-based auth with access/refresh token logic
- ☁️ File Upload: Images & videos stored on Cloudinary
| Tech | Purpose |
|---|---|
| Node.js | Runtime environment |
| Express | Backend framework |
| MongoDB | NoSQL Database |
| Mongoose | ODM for MongoDB |
| Cloudinary | File/media storage |
| Multer | File upload handling |
| JWT | Authentication system |
| bcrypt | Password hashing |
| Prettier | Code formatting |
git clone https://github.com/your-username/mrastatine-backend-learning.git
cd mrastatine-backend-learning
npm installCreate a .env file or set the following environment variables in your system:
PORT=8000
MONGODB_URI=mongodb://localhost:27017
ACCESS_TOKEN_SECRET=your_access_token_secret
ACCESS_TOKEN_EXPIRY=15m
REFRESH_TOKEN_SECRET=your_refresh_token_secret
REFRESH_TOKEN_EXPIRY=7d
CLOUDINARY_CLOUD_NAME=your_cloud_name
CLOUDINARY_API_KEY=your_api_key
CLOUDINARY_API_SECRET=your_api_secret
CORS_ORIGIN=http://localhost:3000npm run dev
All protected routes require a valid JWT in cookies or headers.
POST /api/v1/users/register– Register user with avatar and cover imagePOST /api/v1/users/login– Login with email or usernamePOST /api/v1/users/logout– Logout and clear tokensGET /api/v1/users/current-user– Get current logged-in userPATCH /api/v1/users/avatar– Update avatarPATCH /api/v1/users/cover-image– Update cover imageGET /api/v1/users/c/:username– Get a user’s channel profileGET /api/v1/users/history– Get user watch history
POST /api/v1/video/– Upload a new videoGET /api/v1/video/– List all videosPATCH /api/v1/video/:videoId– Update video infoDELETE /api/v1/video/:videoId– Delete videoPATCH /api/v1/video/toggle/publish/:videoId– Toggle publish status
POST /api/v1/tweet/– Create a tweetGET /api/v1/tweet/:userId– Get user's tweets
GET /api/v1/comment/:videoId– Get comments under a videoPOST /api/v1/comment/:videoId– Add a commentPATCH /api/v1/comment/c/:commentId– Update commentDELETE /api/v1/comment/c/:commentId– Delete comment
POST /api/v1/playlist/– Create playlistGET /api/v1/playlist/user/:userId– Get playlists of userPOST /api/v1/playlist/:playlistId/videos– Add videoDELETE /api/v1/playlist/:playlistId/videos/:videoId– Remove video
POST /api/v1/subscription/c/:channelId– Subscribe/unsubscribeGET /api/v1/subscription/c/:channelId/subscribers– Get subscribersGET /api/v1/subscription/c/:channelId/subscribed-channels– Get followed channels
POST /api/v1/like/toggle/v/:videoId– Like/unlike a videoPOST /api/v1/like/toggle/c/:commentId– Like/unlike a commentGET /api/v1/like/videos– Get liked videos
Akshat Tripathi