This is a real-time chat application built using Django (backend), React (frontend), and WebSockets powered by Django Channels. Users can join a chat room, send messages, and delete their own messages instantly.
- β Join rooms and chat in real-time
- β Message broadcast using WebSocket
- β Delete messages (own messages only)
- β Scroll-to-latest message
- β Responsive UI with Tailwind CSS
| Layer | Tech |
|---|---|
| Frontend | React, TypeScript, Tailwind CSS |
| Backend | Django, Django REST Framework |
| Realtime | Django Channels + WebSocket |
| Database | SQLite (or PostgreSQL in production) |
This project uses WebSockets for real-time messaging.
-
WebSocket connections are established at: ws://localhost:8000/ws/chat/<room_name>/
-
When a message is sent:
-
It is first saved in the backend DB.
-
Then it's broadcast to all connected clients in that room using Django Channels.
-
Backend:
-
Uses
AsyncWebsocketConsumerin Django Channels. -
Messages are sent and received in JSON format.
-
Frontend:
-
Uses
react-use-websocketto manage WebSocket connections easily. -
Auto reconnects on disconnection.