A modern, privacy-focused, real-time messaging web application built with React, Node.js, Express, TypeScript, MongoDB, and Socket.io.
- ⚡ Real-Time Messaging: Instant bidirectional communication powered by Socket.io for low-latency messaging.
- 🔐 Secure Authentication: JWT-based session authentication with HTTP-only cookies and bcrypt-hashed passwords.
- 👥 Direct Conversations: 1-on-1 private chat rooms with automated conversation management, conversation list previews, and timestamp tracking.
- 🔍 Instant User Search: Debounced search to quickly discover registered users and start conversations.
- 🎨 Modern & Responsive UI: Clean interface built using Tailwind CSS, Radix UI components, Lucide icons, and responsive layouts.
- 📦 Reliable State Management: Client-side state managed with Zustand and session persistence.
- 🛡️ Full-Stack Type Safety: End-to-end type safety across both frontend and backend using TypeScript and schema validation with Zod.
- Framework: React 19 + TypeScript + Vite
- Styling: Tailwind CSS & Radix UI primitives
- State Management: Zustand
- Data Fetching & Networking: Axios & TanStack React Query
- Form Handling: React Hook Form & Zod
- Real-Time Client: Socket.io Client
- Icons & Notifications: Lucide React & Sonner
- Runtime: Node.js (ES Modules)
- Framework: Express 5 with TypeScript
- Database & ODM: MongoDB with Mongoose
- WebSockets: Socket.io
- Security & Utilities:
jsonwebtoken,cookie-parser,bcryptjs,cors,zod
sect/
├── backend/ # Express & Socket.io backend service
│ ├── src/
│ │ ├── config/ # Environment and app configuration (Zod parsed)
│ │ ├── controllers/ # Route controllers (Auth, Conversations, Messages)
│ │ ├── lib/ # Database connection (Mongoose) & Socket instance
│ │ ├── middlewares/ # Route protection & JWT verification
│ │ ├── models/ # Mongoose data models (User, Conversation, Message)
│ │ ├── routes/ # Express API endpoints
│ │ ├── utils/ # JWT token generation, async error handlers
│ │ ├── app.ts # Express application setup
│ │ └── server.ts # Server entrypoint and listener
│ ├── package.json
│ └── tsconfig.json
│
├── frontend/ # React + Vite frontend client
│ ├── src/
│ │ ├── components/ # UI components (ChatArea, MessageArea, Sidebar, SearchModal)
│ │ ├── hooks/ # Custom hooks (e.g., useDebounce)
│ │ ├── lib/ # Axios instance, socket client, validation schemas
│ │ ├── pages/ # Page views (LandingPage, AuthPage, Chats, NotFound)
│ │ ├── store/ # Zustand state stores (useAuthStore, useChatStore)
│ │ ├── App.tsx # Application routing and theme provider
│ │ └── main.tsx # Client entrypoint
│ ├── package.json
│ └── vite.config.ts
-
Navigate to the backend directory:
cd backend -
Install dependencies:
npm install
-
Configure environment variables by creating a
.envfile in thebackend/directory:PORT=3000 DB_URL=mongodb+srv://<username>:<password>@<cluster>.mongodb.net/sect NODE_ENV=DEVELOPMENT JWT_SECRET=your_jwt_secret_key
-
Start the backend development server:
npm run dev
The backend server will run on
http://localhost:3000.
-
Navigate to the frontend directory:
cd frontend -
Install dependencies:
npm install
-
Configure environment variables by creating a
.envfile in thefrontend/directory:VITE_API_BASE_URL="http://localhost:3000/api"
-
Start the Vite development server:
npm run dev
The frontend application will run locally (typically at
http://localhost:5173).
POST /api/auth/signup- Register a new accountPOST /api/auth/login- Authenticate user & set JWT cookiePOST /api/auth/logout- Clear authentication cookieGET /api/auth/check- Validate existing session token
GET /api/conversations- Retrieve all user conversationsGET /api/conversations/search- Search users by username queryGET /api/conversations/messages/:receiverId- Fetch message history with a userPOST /api/conversations/send/:receiverId- Send a message to a user
This project is licensed under the ISC License.