Skip to content

Ashmit-Aryan/WebSocket-Chat-Application

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

68 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ’¬ Real-Time Chat Application (Socket.IO)

A full-stack real-time chat application built using Node.js, Express, and Socket.IO.
This project enables instant messaging with support for private chats, group conversations, user presence, and media sharing.


πŸš€ Features

  • ⚑ Real-time bi-directional communication using WebSockets
  • πŸ‘€ User authentication (JWT / session-based β€” configurable)
  • πŸ’¬ Private one-to-one messaging
  • πŸ‘₯ Group chat support
  • 🟒 Online / Offline presence indicators
  • ⌨️ Typing indicators
  • πŸ–ΌοΈ Image sharing (optional via cloud storage)
  • πŸ“œ Chat history persistence (MongoDB / NoSQL)
  • πŸ”’ Secure socket connections
  • πŸ“± Responsive UI (if frontend included)

πŸ—οΈ Tech Stack

Backend

  • Node.js
  • Express.js
  • Socket.IO
  • MongoDB / Firebase / Supabase (configurable)
  • JWT Authentication

Frontend (if applicable)

  • React.js
  • Material UI / Custom CSS
  • Axios

πŸ“‚ Project Structure


chat-app/
β”‚
β”œβ”€β”€ server/
β”‚   β”œβ”€β”€ controllers/
β”‚   β”œβ”€β”€ models/
β”‚   β”œβ”€β”€ routes/
β”‚   β”œβ”€β”€ lib/
β”‚   β”œβ”€β”€ middleware/
β”‚   └── server.js
β”‚
β”œβ”€β”€ client/                # React frontend (optional)
β”‚   β”œβ”€β”€ src/
β”‚   └── public/
β”‚
β”œβ”€β”€ .env
β”œβ”€β”€ package.json
└── README.md


βš™οΈ Installation & Setup

1️⃣ Clone the Repository

git clone https://github.com/your-username/chat-app.git
cd chat-app

2️⃣ Install Dependencies

Backend

cd server
npm install

Frontend (if included)

cd client
npm install

3️⃣ Environment Variables

Create a .env file inside the server directory:

MONGO_URI=
JWT_SECRET=
PORT=3000
CLOUDINARY_CLOUD_NAME=
CLOUDINARY_API_KEY=
CLOUDINARY_API_SECRET=
ARCJET_KEY=
ARCJET_ENV="development"

4️⃣ Run the Application

Start Backend Server

npm run dev

Start Frontend

npm start

πŸ”Œ Socket Events

Client β†’ Server

Event Name Description
join Join chat room / user session
privateMessage Send private message
groupMessage Send message to group
typing User typing indicator
stopTyping Stop typing indicator

Server β†’ Client

Event Name Description
message Receive message
userOnline User comes online
userOffline User goes offline
typing Show typing indicator
notification New message notification

🧠 How It Works

  1. Client connects to server via Socket.IO
  2. User authentication is verified
  3. User joins personal and group rooms
  4. Messages are emitted in real-time
  5. Server broadcasts to relevant recipients
  6. Messages are optionally stored in database

πŸ›‘οΈ Security Considerations

  • JWT authentication for socket connections
  • CORS configuration
  • Input validation
  • Rate limiting (recommended for production)
  • HTTPS deployment advised

πŸš€ Deployment

Backend

  • Render / Railway / AWS / DigitalOcean

Frontend

  • Vercel / Netlify / Firebase Hosting

🧩 Future Improvements

  • Voice & video calling (WebRTC)
  • Message reactions & replies
  • Read receipts
  • Push notifications
  • End-to-end encryption
  • File sharing

🀝 Contributing

Contributions are welcome!

  1. Fork the repository
  2. Create a new branch
  3. Commit your changes
  4. Push to your branch
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License.


πŸ‘¨β€πŸ’» Author

Ashmit Aryan


⭐ Support

If you like this project, please consider giving it a ⭐ on GitHub!

About

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages