A full-stack real-time chat application with authentication, messaging, and media sharing capabilities
- Overview
- Architecture
- Features
- Socket.IO Functionality
- Tech Stack
- Project Structure
- Getting Started
- API Documentation
- Deployment
- Contributing
- License
Chatify is a modern real-time chat application built with a React frontend and Node.js/Express backend. It features secure authentication, real-time messaging using Socket.IO, media sharing via Cloudinary, and email notifications through Resend.
| Benefit | Description |
|---|---|
| π Security | JWT-based authentication with rate limiting via Arcjet |
| β‘ Performance | Real-time messaging with Socket.IO |
| π± Responsive | Mobile-first design with Tailwind CSS |
| βοΈ Cloud Storage | Media handling with Cloudinary |
| π§ Email Service | Transactional emails with Resend |
graph TB
A[Client - React/Vite] --> B[API Gateway]
B --> C[Auth Service]
B --> D[Message Service]
C --> E[(MongoDB)]
D --> E
D --> F[Socket.IO Server]
F --> G[Real-time Clients]
C --> H[Resend Email]
D --> I[Cloudinary CDN]
style A fill:#4FC08D
style B fill:#42b883
style C fill:#34495e
style D fill:#34495e
style E fill:#43b581
style F fill:#8B4513
style H fill:#5600E8
style I fill:#00BEE0
- Frontend - React application with Vite bundler
- Backend - Node.js/Express REST API with WebSocket support
- Database - MongoDB with Mongoose ODM
- Authentication - JWT tokens with cookie-based sessions
- Real-time - Socket.IO for instant messaging
- Storage - Cloudinary for media files
- Email - Resend for transactional emails
- Security - Arcjet for rate limiting and protection
graph LR
A[Frontend] --- B[API Gateway]
B --- C[Auth Service]
B --- D[Message Service]
C --- E[(User DB)]
D --- F[(Message DB)]
D --- G[Socket Service]
C --- H[Email Service]
D --- I[Media Service]
style A fill:#4FC08D
style B fill:#42b883
style C fill:#34495e
style D fill:#2c3e50
style E fill:#43b581
style F fill:#3498db
style G fill:#8B4513
style H fill:#9b59b6
style I fill:#00BEE0
- β Secure signup/login with password hashing
- β JWT token authentication
- β Session management with cookies
- β Profile picture upload
- β Real-time messaging with Socket.IO
- β Message history
- β Image sharing
- β Online/offline user status
- β Responsive design for all devices
- β Dark mode interface
- β Animated UI components
- β Loading skeletons
- β Toast notifications
flowchart LR
A[User] --> B[Frontend UI]
B --> C[API Request]
C --> D[Backend Server]
D --> E[Database]
E --> D
D --> F[Response]
F --> B
D --> G[Email Service]
G --> H[Email Notification]
H --> A
D --> I[WebSocket]
I --> J[Real-time Update]
J --> A
style A fill:#4FC08D
style B fill:#42b883
style C fill:#34495e
style D fill:#2c3e50
style E fill:#43b581
style F fill:#3498db
style G fill:#9b59b6
style H fill:#e67e22
style I fill:#8B4513
style J fill:#e74c3c
sequenceDiagram
participant U as User
participant F as Frontend
participant B as Backend
participant D as Database
U->>F: Enter credentials
F->>B: POST /api/auth/login
B->>D: Validate user
D-->>B: User data
B->>B: Generate JWT
B-->>F: JWT in cookie
F->>F: Store user state
F-->>U: Redirect to chat
sequenceDiagram
participant U1 as User 1
participant U2 as User 2
participant F1 as Frontend 1
participant F2 as Frontend 2
participant B as Backend
participant S as Socket.IO
participant D as Database
U1->>F1: Type message
F1->>B: POST /api/messages/send/{id}
B->>D: Save message
D-->>B: Confirmation
B->>S: Emit message event
S->>F2: Real-time message
F2->>F2: Update UI
F2-->>U2: Display message
Chatify uses Socket.IO for real-time communication between clients and the server. This enables instant message delivery, online status updates, and other real-time features.
graph TD
A[Frontend Client] --> B{Socket.IO Client}
C[Frontend Client] --> D{Socket.IO Client}
B --> E[Socket.IO Server]
D --> E
E --> F[Backend Logic]
F --> G[(MongoDB)]
E --> B
E --> D
style A fill:#61DAFB
style B fill:#8B4513
style C fill:#61DAFB
style D fill:#8B4513
style E fill:#42b883
style F fill:#34495e
style G fill:#43b581
| Feature | Description |
|---|---|
| π¬ Real-time Messaging | Instant message delivery between users |
| π€ Online Status | Real-time presence indicators |
| π Notifications | Instant alerts for new messages |
| π Bidirectional Communication | Server can push updates to clients |
- Socket.IO server is initialized in socket.js
- Authentication middleware ensures only authenticated users can connect
- Online user tracking with
userSocketMapto maintain user presence - Event emission for new messages and online user updates
- Socket.IO client connection established in useAuthStore.js
- Real-time message subscription in useChatStore.js
- Online user status tracking
- Notification sounds for incoming messages
sequenceDiagram
participant C1 as Client 1
participant S as Socket.IO Server
participant C2 as Client 2
participant DB as Database
C1->>S: Connect with auth token
S->>S: Validate authentication
S-->>C1: Connection established
S->>C2: Emit online users list
C1->>S: Send message event
S->>DB: Save message
DB-->>S: Confirmation
S->>C2: Emit new message
C2->>C2: Display notification
| Technology | Purpose |
|---|---|
| React 19 | UI Library |
| Vite 7 | Build Tool |
| Tailwind CSS | Styling |
| Zustand | State Management |
| Socket.IO Client | Real-time Communication |
| Axios | HTTP Client |
| Technology | Purpose |
|---|---|
| Node.js 20+ | Runtime Environment |
| Express | Web Framework |
| MongoDB | Database |
| Mongoose | ODM |
| Socket.IO | Real-time Communication |
| JWT | Authentication |
| Arcjet | Rate Limiting & Security |
| Service | Purpose |
|---|---|
| Cloudinary | Media Storage |
| Resend | Email Service |
| MongoDB Atlas | Database Hosting |
.
βββ backend/
β βββ src/
β β βββ controllers/ β Request handlers
β β βββ emails/ β Email logic and templates
β β βββ lib/ β Utility and service clients
β β βββ middleware/ β Auth and protection layers
β β βββ models/ β MongoDB schemas
β β βββ routes/ β API route definitions
β β βββ server.js β Entry point
βββ frontend/
β βββ src/
β β βββ components/ β Reusable UI elements
β β βββ hooks/ β Custom React hooks
β β βββ lib/ β Configured clients
β β βββ pages/ β Route-level components
β β βββ store/ β State management
β β βββ App.jsx β Root component
β β βββ main.jsx β Entry point
βββ package.json β Monorepo orchestration
- Node.js >= 20.0.0
- MongoDB instance (local or cloud)
- Cloudinary account
- Resend account
- Clone the repository:
git clone https://github.com/Mausam5055/chatify.git
cd chatify- Install dependencies:
npm run build-
Set up environment variables (see backend/.env.example and frontend/.env.example)
-
Start the development servers:
# Terminal 1 - Backend
npm run start
# Terminal 2 - Frontend
npm run dev --prefix frontendRefer to the individual README files in each directory for detailed environment variable setup.
Detailed API documentation can be found in:
npm run build-
Deploy backend to platforms like:
- Render
- Heroku
- DigitalOcean App Platform
- Sevalla
-
Deploy frontend to:
- Netlify
- Vercel
- GitHub Pages
- Sevalla
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
Hosted on Sevalla | Made with β€οΈ by Mausam Kar
