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! π