Quick-Chat is a full‑stack, real‑time chat application built with React on the frontend and Node.js/Express on the backend, using Socket.io for live messaging.
It allows users to create an account, log in, see who is online, chat one‑to‑one in real time, send images, and manage a simple profile (name, bio, avatar).
The goal of this project is to demonstrate a production‑style messaging flow end‑to‑end: authentication with JWT, global state management with the React Context API, real‑time communication via WebSockets, persistence with MongoDB, and a responsive, modern UI.
-
Frontend
- React 19 (SPA, components, hooks)
- Vite (bundler/dev server)
- React Router DOM (routing, protected routes)
- React Context API (
AuthContext,ChatContextfor global state) - Socket.io Client (real‑time messaging)
- Axios (HTTP client)
- Tailwind CSS (utility‑first styling)
- React Hot Toast (notifications)
-
Backend
- Node.js + Express 5
- MongoDB + Mongoose (data models for
UserandMessage) - Socket.io Server (WebSocket connections, online users, real‑time events)
- JWT (jsonwebtoken) (authentication & route protection)
- bcryptjs (password hashing)
- Cloudinary (image upload & hosting for chat images and profile pictures)
- dotenv (environment configuration)
- cors (CORS configuration)
- nodemon (development server reload)
-
Root
client/– React + Vite frontendserver/– Node.js + Express backendREADME.md– Project documentation (this file)
-
Client (frontend)
src/App.jsx– Routes and layout (Home, Login, Profile)src/main.jsx– App entry; wraps app withBrowserRouter,AuthProvider,ChatProvidercontext/AuthContext.jsx– Auth state, axios setup, socket connection, login/logout, profile updatecontext/ChatContext.jsx– Chat state, users list, selected user, messages, unseen counts, socket listenerssrc/pages/*–HomePage,LoginPage,ProfilePagesrc/components/*–Sidebar,ChatContainer,RightSidebar
-
Server (backend)
server.js– Express app + HTTP server + Socket.io setuproutes/userRoutes.js–/api/authroutes (signup, login, check, update profile)routes/messageRoutes.js–/api/messagesroutes (users for sidebar, messages, send, mark seen)controllers/userController.js– auth logic, profile updatecontrollers/messageController.js– messaging logic, unseen counts, Cloudinary uploadmiddleware/auth.js–protectRoutemiddleware using JWTmodels/User.js,models/message.js– Mongoose modelslib/db.js– MongoDB connectionlib/cloudinary.js– Cloudinary configlib/utils.js– helper functions (e.g., JWT token generation)
- Node.js (LTS recommended)
- npm or yarn
- MongoDB instance (local or cloud, e.g. MongoDB Atlas)
- Cloudinary account (for image uploads)
You will also need to create environment variable files for client and server.
- Install dependencies
cd server
npm install- Create
.envfile inserver/
cd server
copy NUL .env # Windows (or: type NUL > .env)Fill it with your configuration:
PORT=5000
MONGO_URI=your_mongodb_connection_string
JWT_SECRET=your_jwt_secret_key
CLOUDINARY_CLOUD_NAME=your_cloudinary_cloud_name
CLOUDINARY_API_KEY=your_cloudinary_api_key
CLOUDINARY_API_SECRET=your_cloudinary_api_secret
NODE_ENV=development- Run the backend in development
cd server
npm run server # uses nodemonThe API and Socket.io server will start (by default on http://localhost:5000 if PORT is 5000).
- Install dependencies
cd client
npm install- Create
.envfile inclient/
cd client
copy NUL .env # Windows (or: type NUL > .env)Add the backend URL (must match the backend you started):
VITE_BACKEND_URL=http://localhost:5000- Run the frontend
cd client
npm run devVite will show a local URL (usually http://localhost:5173).
Open that in your browser to access the Quick‑Chat UI.
-
Sign up / Log in
- Create a new account or log in with existing credentials.
- On success, the backend returns a JWT token, which is stored in
localStorageand attached to every axios request.
-
Socket connection
- After authentication, the frontend opens a Socket.io connection, passing the
userIdin the handshake query. - The server tracks online users and broadcasts them to all clients.
- After authentication, the frontend opens a Socket.io connection, passing the
-
Chatting
- The sidebar loads other users and their unseen message counts.
- Selecting a user:
- Fetches the conversation from the backend.
- Marks all messages from that user as seen.
- Sending a message calls the REST API to persist it in MongoDB and notifies the receiver through Socket.io.
- Image messages are uploaded to Cloudinary, and only the secure URL is stored in the database.
- Add unit/integration tests for controllers and critical components.
- Add typing support (TypeScript) for better DX and safety.
- Improve error handling and validation on both client and server (e.g., form validation, rate limiting).
- Enhance UI themes (dark mode, accessibility improvements).