A full-stack chat application built with React, Vite, Node.js, Express, MongoDB, and Socket.io.
- User authentication with signup, login, and logout
- JWT authentication stored in HTTP-only cookies
- Real-time messaging with Socket.io
- Direct user-to-user chat conversations
- Message image upload support
- Profile picture upload via Cloudinary
- Protected routes for authenticated users
- Client-side theme handling and responsive chat UI
- Frontend: React, Vite, Tailwind CSS, Zustand, React Router
- Backend: Node.js, Express, MongoDB, Mongoose, Socket.io
- Authentication: JWT cookies
- Image storage: Cloudinary
backend/— Express API, authentication, message routes, Cloudinary helpers, socket serverfrontend/— React application with pages, components, and state management
- Node.js and npm installed
- MongoDB database available
- Cloudinary account for image uploads
Create a .env file inside the backend/ folder with the following variables:
PORT=5002
MONGO_URI=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_secretFrom the project root, install backend and frontend dependencies:
npm install --prefix backend
npm install --prefix frontendStart the backend in development mode:
npm run dev --prefix backendStart the frontend development server:
npm run dev --prefix frontendThen open the frontend at http://localhost:5173.
Build the frontend and run the backend server:
npm run build
npm startThis will install dependencies for both sides, build the frontend, and run the backend server.
POST /api/auth/signup— Create a new userPOST /api/auth/login— Log in an existing userPOST /api/auth/logout— Log out the userPUT /api/auth/update-profile— Update profile picture (protected)GET /api/auth/check— Validate current auth session (protected)
GET /api/messages/users— Get other users for chat sidebar (protected)GET /api/messages/:id— Get chat history with a user (protected)POST /api/messages/send/:id— Send a message to a user (protected)
- The backend serves the built React app when
NODE_ENV=production. - Messages can include text and optional image uploads.
- Authentication is validated through cookies and protected route middleware.
This project is available under the ISC license.