A full-stack Twitter-like social media application built with React, Node.js, Express, MongoDB, and TailwindCSS.
- User authentication (Sign Up, Login, Logout)
- Create, edit, and delete posts
- Like and comment on posts
- Follow/unfollow users
- Notifications for likes and follows
- Responsive design with TailwindCSS
- Real-time updates using React Query
Twitter-Clone/
├── backend/
│ ├── controllers/
│ ├── models/
│ ├── routes/
│ ├── middlewares/
│ ├── utils/
│ └── server.js
├── frontend/
│ ├── src/
│ │ ├── components/
│ │ ├── pages/
│ │ ├── utils/
│ │ ├── hooks/
│ │ └── App.jsx
│ ├── public/
│ ├── index.html
│ └── tailwind.config.js
└── README.md
- Node.js (v16 or higher)
- MongoDB (running locally or on a cloud service like MongoDB Atlas)
-
Navigate to the
backenddirectory:cd backend -
Install dependencies:
npm install
-
Create a
.envfile in thebackenddirectory with the following structure:PORT=5000 MONGODB_URL=<your_mongodb_connection> JWT_SECRET=<your_jwt_secret> CLOUDINARY_CLOUD_NAME=<your_cloudinary_cloud_name> CLOUDINARY_API_KEY=<your_cloudinary_api_key> CLOUDINARY_API_SECRET=<your_cloudinary_api_secret> NODE_ENV=development
-
Start the backend server:
npm run dev
-
Navigate to the
frontenddirectory:cd frontend -
Install dependencies:
npm install
-
Start the development server:
npm run dev
npm run dev: Start the backend server in development modenpm start: Start the backend server in production mode
npm run dev: Start the frontend development servernpm run build: Build the frontend for productionnpm run preview: Preview the production build
PORT=5000
MONGODB_URL=<your_mongodb_connection_string>
JWT_SECRET=<your_jwt_secret>
CLOUDINARY_CLOUD_NAME=<your_cloudinary_cloud_name>
CLOUDINARY_API_KEY=<your_cloudinary_api_key>
CLOUDINARY_API_SECRET=<your_cloudinary_api_secret>
NODE_ENV=developmentThe frontend is configured to proxy API requests to the backend. Ensure the backend is running on http://localhost:5000 or update the proxy settings in frontend/vite.config.js if needed.
- React
- React Router
- React Query
- TailwindCSS
- DaisyUI
- Vite
- Node.js
- Express.js
- MongoDB
- Mongoose
- Cloudinary (for image uploads)
- JSON Web Tokens (JWT) for authentication
POST /api/auth/signup: Register a new userPOST /api/auth/login: Login a userPOST /api/auth/logout: Logout a userGET /api/auth/me: Get the authenticated user's details
GET /api/users/profile/:username: Get a user's profilePOST /api/users/follow/:id: Follow/unfollow a userPOST /api/users/update: Update user profileGET /api/users/suggested: Get suggested users to follow
GET /api/posts/getPosts: Get all postsGET /api/posts/following: Get posts from followed usersGET /api/posts/liked/:id: Get liked posts of a userGET /api/posts/user/:username: Get posts by a specific userPOST /api/posts/create: Create a new postPOST /api/posts/like/:id: Like/unlike a postPOST /api/posts/comment/:id: Comment on a postDELETE /api/posts/:id: Delete a post
GET /api/notifications: Get notifications for the authenticated userDELETE /api/notifications: Delete all notifications
- Deploy the backend to a cloud platform like Heroku, AWS, or Render.
- Ensure the
.envvariables are set in the deployment environment.
-
Build the frontend:
npm run build
-
Deploy the
distfolder to a static hosting service like Vercel, Netlify, or AWS S3.