- Home Page:
- Display two buttons:
- Create Room: Opens a modal or form to enter a username. Generates a unique
roomId
and navigates to/room/xxxx
. - Join Room: Opens a modal or form to enter a username and
roomId
. ValidatesroomId
and navigates to/room/xxxx
.
- Create Room: Opens a modal or form to enter a username. Generates a unique
- Display two buttons:
- Chatroom Page (
/room/:roomId
):- Show a real-time chat interface:
- List of messages.
- Input field for new messages.
- Display the username and
roomId
.
- Show a real-time chat interface:
- Routing:
/
→ Home Page/room/:roomId
→ Chatroom Page
- Endpoints:
- POST /api/rooms/create
- Generates a unique
roomId
and stores it in the database. - Returns the
roomId
.
- Generates a unique
- POST /api/rooms/join
- Validates the
roomId
against the database. - Returns success or failure.
- Validates the
- POST /api/rooms/create
- WebSocket Communication (Socket.IO):
- Handle real-time communication for:
- Broadcasting messages to all users in a room.
- Notifying users when someone joins or leaves the room.
- Handle real-time communication for:
- Database Models:
-
Room:
{ roomId: String, // Unique identifier users: [String], // List of usernames messages: [{ username: String, message: String, timestamp: Date }] // Chat history }
-
- Store chat history and room information.
- Collections:
rooms
: StoresroomId
, active users, and chat messages.
- Room Creation:
- On the "Create Room" button click:
- Generate a random
roomId
usinguuid
or similar libraries. - Save the room details to the database.
- Redirect to
/room/:roomId
.
- Generate a random
- On the "Create Room" button click:
- Room Joining:
- On the "Join Room" button click:
- Validate
roomId
from the backend. - If valid, redirect to
/room/:roomId
.
- Validate
- On the "Join Room" button click:
- Real-time Messaging:
- Use
Socket.IO
to establish WebSocket communication. - Events:
join-room
: Notify other users when someone joins.send-message
: Broadcast messages to all users in the room.leave-room
: Notify users when someone leaves.
- Use
- Chatroom Persistence:
- Store messages in the
rooms
collection for persistence.
- Store messages in the
- Frontend: React.js, React Router, Axios.
- Backend: Node.js, Express.js, Socket.IO.
- Database: MongoDB.
- Utilities:
uuid
for generating unique room IDs.
Description:
The Anonymous Private Chat Application allows users to create or join private chat rooms effortlessly—no login, no accounts, just instant messaging! This app is designed for fast, secure, and real-time communication with an emphasis on simplicity and user privacy.
Key Features:
-
Anonymous Chat:
- No account or sign-up required.
- Users can enter a chatroom with just a username, keeping the experience completely anonymous.
-
Private Rooms:
- Create a unique chatroom with a randomly generated
roomId
. - Share the
roomId
with friends to join the conversation.
- Create a unique chatroom with a randomly generated
-
Real-Time Messaging:
- Powered by Socket.IO for seamless, instant communication.
- Messages are broadcast to all users in the room with zero delay.
-
Chat History Persistence:
- Chat history is saved in the database, ensuring that no message is lost if a user refreshes the page.
-
User-Friendly Interface:
- Clean and responsive design using Tailwind CSS and shadcn/ui for a modern look.
- Simple navigation with two core pages: Home and Chatroom.
How It Works:
-
Home Page:
- Click Create Room to generate a new private chatroom and navigate to it.
- Click Join Room to enter an existing chatroom using the
roomId
.
-
Chatroom:
- Start chatting in real time! See all messages, the
roomId
, and the usernames of participants.
- Start chatting in real time! See all messages, the
Why Anonymous Chat?
In today’s world, not everyone wants to go through the hassle of creating accounts or logging in just to chat. This app focuses on providing a fast and frictionless experience, making it perfect for casual, temporary conversations without compromising user privacy.
#AnonymousChat #RealTimeMessaging #ReactJS #ExpressJS #SocketIO #WeekendProject #WebDevelopment