This is the backend for a full-stack real-time social media platform built with Node.js, Express, MongoDB, and Socket.IO.
It supports JWT authentication, user management, post creation, likes, comments, profile updates, and real-time updates through sockets.
- ✅ User Registration & Login with JWT
- 🧑 Unique Usernames
- 🔐 Password Hashing with bcrypt
- 📸 Profile & Cover Photo Upload Support
- 📝 Post Creation, Likes, Comments, and Sharing
- 📰 Real-Time News Feed Updates with Socket.IO
- 🔍 Search Users by Username or Name
- 👥 Follow/Unfollow Users
- 📦 REST API Architecture
- 🔄 Real-time Events (like posts, likes, comments)
- 🧵 Modular Codebase (MVC Pattern)
- Node.js
- Express.js
- MongoDB + Mongoose
- JWT for authentication
- Socket.IO
- Multer for file uploads
- Cloudinary or Firebase Storage (recommended for production)
- deep-share-backend/
- ├── controllers/
- │ ├── authController.js
- │ ├── userController.js
- │ ├── postController.js
- │ └── commentController.js
- ├── models/
- │ ├── User.js
- │ ├── Post.js
- │ ├── Comment.js
- ├── routes/
- │ ├── auth.routes.js
- │ ├── user.routes.js
- │ ├── post.routes.js
- │ ├── comment.routes.js
- ├── middleware/
- │ ├── authMiddleware.js
- │ ├── uploadMiddleware.js
- ├── sockets/
- │ └── socket.js
- ├── utils/
- │ ├── cloudinary.js
- ├── .env
- ├── server.js
- └── package.json
🔐 Auth Routes
- POST
/api/auth/registerRegister user - POST
/api/auth/loginLogin user
👤 User Routes
- GET
/api/users/:usernameGet public profile - PUT
/api/users/updateUpdate profile info - PUT
/api/users/follow/:idFollow a user - PUT
/api/users/unfollow/:idUnfollow a user - GET
/api/users/search?q=Search users
📝 Post Routes
- POST
/api/posts/Create post - GET
/api/posts/feed Getfeed - PUT
/api/posts/:id/likeLike/unlike a post - DELETE
/api/posts/:idDelete post
💬 Comment Routes
- POST
/api/comments/:postIdAdd comment - GET
/api/comments/:postIdGet post comments
Socket events are initialized when a user connects. Examples:
- new-post
- new-like
- new-comment
- user-connected
- notify
These events emit updates to other online users in real-time.