A full-featured social media dashboard built with MongoDB, Express, React, and Node.js. Ready to deploy on Vercel!
- 🔐 User Authentication - JWT-based login/register
- 📝 Create Posts - Share text and images
- 💬 Comments - Engage with posts
- ❤️ Likes - Like posts and comments
- 👥 Follow System - Follow/unfollow users
- 👤 User Profiles - View and edit profiles
- 📱 Responsive Design - Works on all devices
- 🔔 Real-time Feed - See latest posts
- React 18
- React Router v6
- Axios
- React Icons
- React Toastify
- Vite
- Node.js
- Express.js
- MongoDB with Mongoose
- JWT Authentication
- bcryptjs
- Node.js (v16 or higher)
- MongoDB (local or Atlas)
- npm or yarn
- Clone or navigate to the project
cd e:\PROJECT\FSD- Install dependencies
Install root dependencies:
npm installInstall client dependencies:
cd client
npm install
cd ..- Configure Environment Variables
Create a .env file in the root directory:
MONGODB_URI=your-mongodb-connection-string
JWT_SECRET=your-super-secret-jwt-key-change-this
PORT=5000- Run the Application
Development mode (both frontend and backend):
npm run devOr run separately:
Backend only:
npm run serverFrontend only:
npm run client- Access the Application
- Frontend: http://localhost:3000
- Backend API: http://localhost:5000
- Create a free account at MongoDB Atlas
- Create a new cluster
- Get your connection string
- Whitelist all IPs (0.0.0.0/0) for Vercel
- Install Vercel CLI (optional)
npm i -g vercel- Push to GitHub
git init
git add .
git commit -m "Initial commit"
git remote add origin your-repo-url
git push -u origin main-
Deploy via Vercel Dashboard
- Go to vercel.com
- Import your GitHub repository
- Configure environment variables:
MONGODB_URI: Your MongoDB Atlas connection stringJWT_SECRET: Your secret key
- Deploy!
-
Or Deploy via CLI
vercelIn your Vercel project settings, add:
MONGODB_URI= Your MongoDB Atlas connection stringJWT_SECRET= Your secret key
FSD/
├── server/ # Backend
│ ├── models/ # Mongoose models
│ │ ├── User.js
│ │ ├── Post.js
│ │ ├── Comment.js
│ │ └── Notification.js
│ ├── routes/ # API routes
│ │ ├── auth.js
│ │ ├── users.js
│ │ ├── posts.js
│ │ ├── comments.js
│ │ ├── likes.js
│ │ └── follows.js
│ ├── middleware/ # Custom middleware
│ │ └── auth.js
│ └── server.js # Entry point
├── client/ # Frontend
│ ├── src/
│ │ ├── components/ # React components
│ │ ├── pages/ # Page components
│ │ ├── context/ # Context API
│ │ ├── utils/ # Utilities
│ │ ├── App.jsx
│ │ └── main.jsx
│ ├── index.html
│ └── package.json
├── vercel.json # Vercel configuration
├── package.json # Root package.json
└── README.md
POST /api/auth/register- Register new userPOST /api/auth/login- Login user
GET /api/users/me- Get current userGET /api/users/:username- Get user profilePUT /api/users/profile- Update profileGET /api/users/search/:query- Search users
GET /api/posts- Get all postsGET /api/posts/:id- Get single postPOST /api/posts- Create postPUT /api/posts/:id- Update postDELETE /api/posts/:id- Delete post
POST /api/comments- Create commentDELETE /api/comments/:id- Delete commentPOST /api/comments/:id/like- Like/unlike comment
POST /api/likes/:postId- Like/unlike post
POST /api/follows/:userId- Follow/unfollow userGET /api/follows/:userId/followers- Get followersGET /api/follows/:userId/following- Get following
- Secure authentication with JWT
- Password hashing with bcrypt
- Form validation
- Text posts with optional images
- Real-time feed updates
- Edit and delete your own posts
- Like posts and comments
- Comment on posts
- Follow/unfollow users
- View followers and following
- Customizable profiles
- Avatar and cover photos
- Bio and user information
- View user's posts
Edit client/src/components/Navbar.jsx:
<Link to="/">YourAppName</Link>Edit client/src/index.css to change the color scheme.
- Notifications system (model already created)
- Direct messaging
- Story features
- Search functionality
- Hashtags
MongoDB Connection Error:
- Check your connection string
- Verify IP whitelist in MongoDB Atlas
- Ensure MongoDB is running locally
Vercel Deployment Issues:
- Verify environment variables are set
- Check build logs for errors
- Ensure MongoDB allows Vercel IPs
CORS Errors:
- Backend is configured to accept all origins
- Check proxy settings in
vite.config.js
MIT License - feel free to use this project for learning and portfolio purposes!
Contributions, issues, and feature requests are welcome!
Built with ❤️ using MERN Stack
Happy Coding! 🚀