This is a modern, real-time messaging system built with React and Node.js. It enables users to engage in instant messaging with a rich set of features, such as media upload, online/offline status, etc for a seamless communication experience.
Experience the application live at: realtime-chat-application
- Real-time Messaging: Instant message delivery between users using Socket.IO.
- Online/Offline Status: Real-time updates of user status (online/offline).
- Typing Indicator: "Typing..." indicator displayed while a user is composing a message.
- Read/Unread Message Sorting: Messages are sorted based on read/unread status for easy tracking.
- Media Sharing: Support for image and video uploads in conversations.
- Infinite Scrolling: Load older messages seamlessly as users scroll up in a conversation.
- User authentication with Clerk
- Responsive design for both desktop and mobile
- Conversation management
- React
- TypeScript
- Vite
- TanStack Router (for routing)
- Socket.IO Client (for real-time communication)
- Tailwind CSS (for styling)
- Clerk (for authentication)
- Shadcn UI (for UI components)
- Firebase (for storage of media)
- Node.js
- Express.js
- Socket.IO (for real-time communication)
- TypeScript
- Drizzle ORM (for database operations)
- PostgreSQL
This realtime messaging application follows a modern, scalable architecture designed for real-time communication. Here's an overview of the system's architecture:
-
Node.js Server:
- Express.js framework handles HTTP requests and serves as the foundation for the API.
-
WebSocket Server:
- Socket.IO server manages real-time bidirectional event-based communication.
-
Database Layer:
- PostgreSQL serves as the primary database.
- Drizzle ORM handles database operations, providing a type-safe query builder and migration system.
-
API Structure:
- RESTful endpoints for non-real-time operations.
- Socket event handlers for real-time features like messaging and status updates.
-
User Authentication:
- Frontend uses Clerk for authentication.
- Upon successful auth, the backend receives user information and manages sessions.
-
Real-time Messaging:
- Messages sent from the frontend via Socket.IO events.
- Backend processes messages, stores in the database, and broadcasts to relevant clients.
- Receiving clients update their UI in real-time.
-
Status Updates:
- Online/offline status and typing indicators use Socket.IO for instant updates.
- Backend tracks user status and propagates changes to relevant clients.
-
Media Handling:
- Images and videos are uploaded to a file storage system (firebase storage).
- Media URLs are then generated and stored in database, and rendered on the UI.
-
Message History:
- Frontend requests paginated message history.
- Backend queries the database and returns messages in batches, supporting infinite scrolling.
This architecture provides a solid foundation for a responsive, real-time messaging application.