Skip to content

Latest commit

Β 

History

18 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

# πŸ’¬ Chatify β€” Real-Time MERN Chat Application

πŸ” Authentication β€’ πŸ’¬ Real-Time Messaging β€’ 🟒 Online Users β€’ πŸ–ΌοΈ Cloudinary Uploads

Chatify is a full-stack real-time chat application built with Node.js, Express, MongoDB, React, Vite, Socket.IO, Zustand, and Cloudinary.

Live Demo Live Backend

Node.js Express.js MongoDB React Vite Socket.IO Zustand Tailwind CSS Cloudinary

--- ## πŸš€ Live Demo ### Frontend πŸ‘‰ [**Chatify β€” Live Website**](https://chatify-plum.vercel.app/) ### Backend πŸ‘‰ [**Chatify β€” Backend**](https://chatify-backend-4qij.onrender.com/) --- ## πŸ“Œ Overview **Chatify** is a full-stack real-time messaging application built using the MERN stack and Socket.IO. The application provides a modern chat experience with authentication, real-time communication, online user tracking, profile image uploads, and client-side state management. The project uses a separated frontend and backend architecture, with the React frontend deployed on Vercel and the Node.js/Express backend deployed on Render. --- ## ✨ Features - πŸ” Cookie-based JWT authentication - πŸ“ User signup and login - πŸšͺ Secure logout functionality - πŸ’¬ Real-time one-to-one messaging - ⚑ Socket.IO-based communication - 🟒 Online user tracking - πŸ–ΌοΈ Profile picture uploads using Cloudinary - 🎨 Responsive React interface - 🧠 Zustand state management - πŸ”— Axios-based API communication - πŸ—„οΈ MongoDB persistence with Mongoose - 🌐 Separate production frontend and backend deployment --- ## 🧰 Tech Stack ### Frontend | Technology | Purpose | |---|---| | React | User interface | | Vite | Frontend tooling | | Zustand | State management | | Axios | API communication | | Tailwind CSS | Styling | | Socket.IO Client | Real-time communication | ### Backend | Technology | Purpose | |---|---| | Node.js | Runtime | | Express.js | Backend framework | | MongoDB | Database | | Mongoose | MongoDB ODM | | JWT | Authentication | | Socket.IO | Real-time communication | ### Media | Technology | Purpose | |---|---| | Cloudinary | Profile image storage and delivery | --- ## πŸ—οΈ Architecture ```text β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ React Frontend β”‚ β”‚ Vite + Zustand + UI β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ REST API + Socket.IO β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Node.js + Express β”‚ β”‚ β”‚ β”‚ Authentication β”‚ β”‚ REST APIs β”‚ β”‚ Socket.IO Server β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β” β”Œβ”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ MongoDB β”‚ β”‚ Cloudinary β”‚ β”‚ + Mongoose β”‚ β”‚ Media β”‚ β”‚ β”‚ β”‚ Storage β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ``` --- ## πŸ“ Project Structure ```text LIVE_CHAT/ β”‚ β”œβ”€β”€ README.md β”œβ”€β”€ Home.png β”œβ”€β”€ Login.png β”‚ β”œβ”€β”€ Backend/ β”‚ β”œβ”€β”€ src/ β”‚ β”‚ β”œβ”€β”€ app.js β”‚ β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ controllers/ β”‚ β”‚ β”‚ β”œβ”€β”€ authController.js β”‚ β”‚ β”‚ └── messageController.js β”‚ β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ routes/ β”‚ β”‚ β”‚ β”œβ”€β”€ authRoute.js β”‚ β”‚ β”‚ └── messageRoute.js β”‚ β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ middlewares/ β”‚ β”‚ β”‚ └── authMiddleware.js β”‚ β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ model/ β”‚ β”‚ β”‚ β”œβ”€β”€ userModel.js β”‚ β”‚ β”‚ └── messageModel.js β”‚ β”‚ β”‚ β”‚ β”‚ └── lib/ β”‚ β”‚ β”œβ”€β”€ cloudinary.js β”‚ β”‚ β”œβ”€β”€ socket.js β”‚ β”‚ └── token.js β”‚ β”‚ β”‚ β”œβ”€β”€ package.json β”‚ └── .env.example β”‚ └── Frontend/ └── vite-project/ β”œβ”€β”€ src/ β”‚ β”œβ”€β”€ Pages/ β”‚ β”‚ β”œβ”€β”€ HomePage.jsx β”‚ β”‚ β”œβ”€β”€ LoginPage.jsx β”‚ β”‚ β”œβ”€β”€ ProfilePage.jsx β”‚ β”‚ └── SignUpPage.jsx β”‚ β”‚ β”‚ β”œβ”€β”€ components/ β”‚ β”‚ β”œβ”€β”€ ChatContainer.jsx β”‚ β”‚ β”œβ”€β”€ ChatHeader.jsx β”‚ β”‚ β”œβ”€β”€ MessageInput.jsx β”‚ β”‚ β”œβ”€β”€ Messages.jsx β”‚ β”‚ β”œβ”€β”€ Navbar.jsx β”‚ β”‚ β”œβ”€β”€ NoChatSelected.jsx β”‚ β”‚ β”œβ”€β”€ Sidebar.jsx β”‚ β”‚ └── UserChatHeader.jsx β”‚ β”‚ β”‚ β”œβ”€β”€ store/ β”‚ β”‚ β”œβ”€β”€ authStore.js β”‚ β”‚ └── chatStore.js β”‚ β”‚ β”‚ β”œβ”€β”€ lib/ β”‚ β”‚ β”œβ”€β”€ axios.js β”‚ β”‚ └── utils.js β”‚ β”‚ β”‚ β”œβ”€β”€ App.jsx β”‚ β”‚ └── main.jsx β”‚ β”‚ β”‚ └── public/ β”‚ β”œβ”€β”€ vite.config.js └── package.json ``` --- ## πŸ“Έ Preview ### 🏠 Home / Chat ![Chatify Home](./Home.png) ### πŸ” Login ![Chatify Login](./Login.png) --- ## βš™οΈ Getting Started ### Prerequisites Before running the project locally, make sure you have: - Node.js installed - MongoDB Atlas or a local MongoDB instance - Cloudinary account --- ## 1. Backend Setup ```bash cd Backend npm install ``` Create: ```text Backend/.env ``` Use `Backend/.env.example` as the reference for the required variables. For PowerShell: ```powershell Copy-Item .env.example .env ``` Start the backend: ```bash npm start ``` --- ## 2. Frontend Setup Open another terminal: ```bash cd Frontend/vite-project npm install ``` Create: ```text Frontend/vite-project/.env ``` Use the provided environment example as the reference. For PowerShell: ```powershell Copy-Item .env.example .env ``` Start the frontend: ```bash npm run dev ``` --- ## πŸ”‘ Environment Variables ### Backend Create: ```text Backend/.env ``` | Variable | Required | Description | |---|---|---| | `PORT` | No | Backend server port | | `MONGODB_URI` | Yes | MongoDB connection string | | `secretKey` | Yes | JWT secret | | `CLIENT_URL` | No | Frontend URL allowed by CORS | | `CLOUDINARY_CLOUD_NAME` | Yes | Cloudinary cloud name | | `CLOUDINARY_API_KEY` | Yes | Cloudinary API key | | `CLOUDINARY_SECRET_KEY` | Yes | Cloudinary API secret | ### Frontend Create: ```text Frontend/vite-project/.env ``` | Variable | Required | Description | |---|---|---| | `VITE_API_BASE_URL` | Yes | Backend API base URL | | `VITE_SOCKET_URL` | Yes | Backend Socket.IO URL | ### Local Example ```env VITE_API_BASE_URL=http://localhost:5000/api VITE_SOCKET_URL=http://localhost:5000 ``` --- ## 🚒 Deployment ### Backend β€” Render 1. Create a Node.js service on Render. 2. Set the backend root directory to `Backend/`. 3. Install dependencies using `npm install`. 4. Configure the required environment variables. 5. Set `CLIENT_URL` to the deployed Vercel frontend URL. 6. Deploy the backend. ### Frontend β€” Vercel 1. Import the repository into Vercel. 2. Set the frontend root directory to: ```text Frontend/vite-project ``` 3. Configure: ```env VITE_API_BASE_URL=https://chatify-backend-4qij.onrender.com/api VITE_SOCKET_URL=https://chatify-backend-4qij.onrender.com ``` 4. Deploy the frontend. --- ## 🧠 Key Technical Concepts Chatify demonstrates practical experience with: - MERN stack development - REST API architecture - JWT authentication - Cookie-based authentication - MongoDB data modeling - Mongoose - Real-time communication with Socket.IO - Online presence tracking - React component architecture - Zustand state management - Axios API integration - Cloudinary media handling - CORS configuration - Production deployment with Vercel and Render --- ## πŸ”„ Application Flow ```text User ↓ React Frontend ↓ Axios / Socket.IO Client ↓ Node.js + Express ↓ Authentication / API / Socket Events ↓ MongoDB + Mongoose ↓ Cloudinary for media ↓ Response / Real-Time Update ↓ React UI ``` --- ## ⚑ Challenges Faced ### CORS Configuration Configured communication between the separately deployed frontend and backend. ### Real-Time Connections Handled Socket.IO connections across local and production environments. ### Cookie-Based Authentication Configured JWT-based authentication using cookies between the frontend and backend. ### Media Uploads Integrated Cloudinary for profile picture uploads and stored the resulting image URL in MongoDB. ### Production Deployment Configured separate deployments using Vercel and Render for the frontend and backend. --- ## 🧩 Common Issues ### CORS Errors Make sure the backend `CLIENT_URL` exactly matches the deployed frontend URL. ### Socket.IO Not Connecting Verify: ```env VITE_SOCKET_URL=https://chatify-backend-4qij.onrender.com ``` ### API Requests Failing Verify: ```env VITE_API_BASE_URL=https://chatify-backend-4qij.onrender.com/api ``` ### Cloudinary Upload Errors Check all Cloudinary credentials in the backend environment variables. --- ## πŸ‘¨β€πŸ’» Author **Avinash Kumar** GitHub: https://github.com/Avinash-sdbegin ---

⭐ If you found Chatify useful, consider giving the repository a star.

About

πŸš€ Chatify – A Real-Time MERN Chat App with Live Messaging, Auth & Profile Uploads

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages