A full-stack chat application with real-time messaging capabilities using Socket.IO, React, and Node.js.
- Real-time messaging
- User authentication
- User profiles with avatars
- Online status indicators
- Responsive design
- Light/dark theme support
- React
- React Router
- Zustand (State Management)
- Socket.IO Client
- Tailwind CSS
- Vite
- Node.js
- Express
- MongoDB
- Socket.IO
- JWT Authentication
- Cloudinary (Media Storage)
├── backend/ # Backend Node.js application
│ ├── src/
│ │ ├── controllers/ # Request handlers
│ │ ├── models/ # Database models
│ │ ├── routes/ # API routes
│ │ ├── middleware/ # Custom middleware
│ │ ├── lib/ # Utility functions and services
│ │ └── index.js # Entry point
│ ├── .env # Environment variables
│ └── package.json # Dependencies
│
└── frontend/ # Frontend React application
├── src/
│ ├── components/ # Reusable React components
│ ├── pages/ # Page components
│ ├── store/ # Zustand state stores
│ ├── lib/ # Utility functions
│ ├── constants/ # Constants and configuration
│ └── App.jsx # Main application component
├── public/ # Static assets
└── package.json # Dependencies
- Node.js (v14 or later)
- MongoDB database
- Cloudinary account (for media storage)
-
Clone the repository:
git clone <repository-url> cd chat-application -
Setup backend:
cd backend npm install -
Configure environment variables: Create a
.envfile in the backend directory with the following variables:MONGODB_URI=<your-mongodb-connection-string> PORT=5001 JWT_SECRET=<your-secret-key> NODE_ENV=development CLOUDINARY_CLOUD_NAME=<your-cloudinary-cloud-name> CLOUDINARY_API_KEY=<your-cloudinary-api-key> CLOUDINARY_API_SECRET=<your-cloudinary-api-secret> -
Setup frontend:
cd ../frontend npm install -
Start the development servers:
In the backend directory:
npm run devIn the frontend directory:
npm run dev -
Open your browser and navigate to
http://localhost:5173
-
Set environment variables in your hosting platform:
MONGODB_URI=<your-mongodb-connection-string> PORT=5001 (or as provided by your hosting platform) JWT_SECRET=<your-secret-key> NODE_ENV=production CLOUDINARY_CLOUD_NAME=<your-cloudinary-cloud-name> CLOUDINARY_API_KEY=<your-cloudinary-api-key> CLOUDINARY_API_SECRET=<your-cloudinary-api-secret> PRODUCTION_URL=<your-production-domain> -
Build the frontend:
cd frontend npm run build -
Start the server in production mode:
cd ../backend npm start
The application can be deployed to various platforms:
- Create a Procfile in the root directory:
web: cd backend && npm start - Set environment variables in Heroku dashboard
- Deploy using Heroku CLI or GitHub integration
- Configure the build settings to:
- Build command:
cd frontend && npm install && npm run build - Output directory:
frontend/dist
- Build command:
- Set environment variables in the platform dashboard
- Configure the server start command:
cd backend && npm install && npm start
- Never commit
.envfiles with real credentials - Use environment variables for all sensitive data
- Set appropriate CORS policies for production
- Use HTTPS in production
MIT