A modern, real-time chat application built with React, TypeScript, Node.js, Express, and Socket.IO. This application provides a seamless messaging experience with a clean, responsive UI.
- 🔐 User Authentication: Secure login and registration with JWT
- 💬 Real-time Messaging: Instant message delivery using Socket.IO
- 👥 User Presence: See when users are online/offline
- 🎨 Modern UI: Built with Shadcn UI and Tailwind CSS
- 📱 Responsive Design: Works on desktop and mobile devices
- 🚀 Type Safety: Full TypeScript support
- 🔄 State Management: React Query for efficient data fetching and caching
- React 19
- TypeScript
- Vite
- Tailwind CSS
- Shadcn UI Components
- React Router DOM
- Socket.IO Client
- React Query
- Node.js with Express
- TypeScript
- MongoDB with Mongoose
- Socket.IO
- JWT for Authentication
- Zod for Schema Validation
- Node.js (v18 or higher)
- npm or yarn
- MongoDB (local or MongoDB Atlas)
-
Navigate to the backend directory:
cd backend -
Install dependencies:
npm install
-
Create a
.envfile in the backend directory with the following variables:PORT=8000 FRONTEND_URL=http://localhost:5173 MONGO_URI=mongodb://localhost:27017/chat-app ACCESS_TOKEN_SECRET=supersecret SUPABASE_URL=https://<your-project>.supabase.co SUPABASE_SERVICE_ROLE_KEY=<your-service-role-key> -
Start the development server:
npm run dev
-
Navigate to the frontend directory:
cd frontend -
Install dependencies:
npm install
-
Create a
.envfile in the frontend directory with the following variable:VITE_API_URL=https://localhost:8000 -
Start the development server:
npm run dev
-
Trust the Development Certificate:
- First, visit the backend URL directly in your browser:
https://localhost:8000 - You'll see a security warning (this is normal for self-signed certificates in development)
- Click "Advanced" and then "Proceed to localhost (unsafe)" or similar option to accept the certificate
- You should see a message indicating the backend is running
- First, visit the backend URL directly in your browser:
-
Open your browser and navigate to the frontend at
https://localhost:5173
chat-app/
├── backend/ # Backend server
│ ├── src/
│ │ ├── controllers/ # Request handlers
│ │ ├── models/ # Database models
│ │ ├── routes/ # API routes
│ │ ├── socket/ # Socket.IO handlers
│ │ ├── utils/ # Utility functions
│ │ └── server.ts # Server entry point
│ └── ...
│
└── frontend/ # Frontend React app
├── public/ # Static files
└── src/
├── components/ # Reusable UI components
├── pages/ # Page components
├── hooks/ # Custom React hooks
├── lib/ # Utility functions
├── types/ # TypeScript type definitions
└── ...
PORT: Server port (default: 3001)MONGODB_URI: MongoDB connection stringJWT_SECRET: Secret key for JWTNODE_ENV: Environment (development/production)
VITE_API_URL: Backend API URL
This project uses HTTPS locally to support secure cookies and cross-origin authentication.
Run the following command in the project root to generate local development certs:
mkdir cert
openssl req -x509 -out cert/localhost.pem -keyout cert/localhost-key.pem \
-newkey rsa:2048 -nodes -sha256 \
-subj "/CN=localhost" \
-addext "subjectAltName=DNS:localhost" \
-days 365📁 This will create a
cert/folder containing:
localhost-key.pemlocalhost.pem
Set your frontend .env like this:
VITE_API_URL=https://localhost:3001Make sure you access the frontend at https://localhost:5173 (not http://) so secure cookies are accepted by the browser.
On first use, your browser may show a warning about the self-signed certificate. You can safely bypass this warning in development, or add the certificate to your trusted store based on your OS.
- Fork the repository
- Create a new branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0).
You are free to use, modify, and distribute this software under the terms of the AGPL-3.0 license.
If you deploy this software as a network service, or use it in a SaaS product, you must also make the complete source code available to users of the service.
See the LICENSE for full details.
If you are interested in using this project in a closed-source or proprietary setting, or if you require a custom license, please contact me at badraanmo@gmail.com.
Built with ❤️ by Badraan