Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 Aman Kumar

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
289 changes: 289 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,289 @@
# πŸ’¬ ChatApp

> A full-stack real-time messaging platform with secure auth, image sharing, push notifications, and Redis-powered online status β€” built MERN-style with TypeScript end to end.

[![Live Demo](https://img.shields.io/badge/Live%20Demo-Vercel-brightgreen?style=for-the-badge&logo=vercel)](https://chat-app-psi-teal.vercel.app)
![TypeScript](https://img.shields.io/badge/TypeScript-68.4%25-3178C6?style=flat&logo=typescript)
![JavaScript](https://img.shields.io/badge/JavaScript-28.1%25-F7DF1E?style=flat&logo=javascript)
![Socket.IO](https://img.shields.io/badge/Socket.IO-Realtime-010101?style=flat&logo=socket.io)
![License](https://img.shields.io/badge/License-MIT-yellow?style=flat)

---

## πŸ“Œ About This Project

ChatApp is a modern real-time messaging platform built on a MERN-style stack with TypeScript across both frontend and backend. It goes well beyond a typical chat tutorial β€” featuring JWT authentication, Redis-backed online status, image/file sharing via Cloudinary, web push notifications, and a Bloom filter optimisation for fast signup checks.

πŸ”— **Live Demo:** [chat-app-psi-teal.vercel.app](https://chat-app-psi-teal.vercel.app)

---

## πŸ“Έ Screenshots

| Sign In | Create Account | Chat Interface |
|---------|-----------------|----------------|
| <img src="Screenshots/signin.png" width="250" /> | <img src="Screenshots/create.png" width="250" /> | <img src="Screenshots/chat.jpg" width="250" /> |

---

## πŸš€ Features

### Core
- πŸ” **Secure Authentication** β€” JWT-based signup and login with password hashing
- ⚑ **Real-Time Messaging** β€” Instant delivery via Socket.IO
- πŸ’¬ **Persistent Conversations** β€” Threaded chat history between users
- πŸ” **User Search** β€” Find users by name or phone number
- πŸ–ΌοΈ **Image & File Sharing** β€” Cloudinary-powered uploads, rendered inline in chat
- ↩️ **Reply to Messages** β€” Quote and reply within a thread
- πŸ“© **Invitations** β€” Send and accept chat invites

### Advanced
- πŸ”” **Push Notifications** β€” Web Push API (VAPID) for new messages and invites
- 🟒 **Online Status** β€” Real-time presence tracking via Redis
- πŸ›‘οΈ **Rate Limiting** β€” Redis-backed protection against message spam/abuse
- 🌸 **Bloom Filter** β€” Probabilistic check for username/email availability β€” fast, low DB load
- πŸ—„οΈ **Session Management** β€” Redis-managed sessions for scalable state
- 🎨 **Modern UI** β€” Custom-styled theme, mobile responsive, recently overhauled

---

## 🧠 How It Works

```
User signs up β†’ Bloom filter checks availability β†’ JWT issued
↓
User searches/invites another user β†’ Invitation sent
↓
Invitation accepted β†’ Conversation created
↓
Message sent β†’ Socket.IO broadcasts in real-time
↓
Redis tracks online status + rate limits + session state
↓
Image attached? β†’ Uploaded to Cloudinary β†’ URL stored in message
↓
Recipient offline? β†’ Web Push notification fires
```

---

## πŸ› οΈ Tech Stack

| Layer | Technology |
|-------|------------|
| Frontend Framework | React + TypeScript |
| Build Tool | Vite |
| Styling | Custom CSS theme |
| State Management | React Context API |
| HTTP Client | Axios |
| Real-time Client | Socket.IO Client |
| Backend Runtime | Node.js + Express.js |
| Database | MongoDB (Mongoose ODM) |
| Cache / Sessions | Redis |
| Real-time Server | Socket.IO |
| Auth | JWT + bcrypt |
| File Storage | Cloudinary |
| Push Notifications | Web Push API (VAPID) |
| Uploads | Multer |
| CORS | cors middleware |

---

## πŸ§ͺ Key Features in Detail

| Feature | Description |
|---------|--------------|
| Real-time Messaging | Instant message delivery with Socket.IO |
| User Authentication | Secure signup/login with JWT and password hashing |
| Image Sharing | Upload images via Cloudinary, rendered inline in chat |
| Push Notifications | Web Push API with VAPID for browser notifications |
| Online Status | Real-time user presence via Redis |
| Chat Invitations | Send and accept conversation requests |
| Reply to Messages | Quote and reply to specific messages |
| Rate Limiting | Prevents abuse of sensitive API endpoints |
| Bloom Filter | Optimised username/email availability checks |
| Modern UI | Custom-styled theme with mobile responsiveness |

---

## 🧱 Backend Architecture

**MVC-style structure, fully modular:**

| Folder | Responsibility |
|--------|----------------|
| `server.js` | Entry point β€” Express init, DB connect, middleware, server start |
| `config/` | Redis client setup |
| `models/` | Mongoose schemas β€” User, Conversation, Messages, Invitation, PushSubscription |
| `controllers/` | Business logic β€” auth, user, conversation, message, invitation |
| `routes/` | REST endpoints mapped to controllers |
| `middleware/` | JWT auth guard, HTTP + Redis-backed rate limiters |
| `utils/` | Push notification dispatch logic |

**API Routes:**

| Endpoint | Purpose |
|----------|---------|
| `/api/auth` | Signup, login |
| `/api/users` | Search, profile updates |
| `/api/conversations` | Create, fetch conversations |
| `/api/messages` | Send, retrieve messages |
| `/api/invitations` | Create, accept invitations |
| `/api/push` | Push subscription management |

---

## 🎨 Frontend Architecture

```
src/
β”œβ”€β”€ pages/ # Login, Signup, ChatLayout β€” top-level routes
β”œβ”€β”€ components/ # Chat bubbles, message input, user lists
β”œβ”€β”€ context/ # Auth state, theme β€” global providers
β”œβ”€β”€ hooks/ # Custom reusable stateful logic
β”œβ”€β”€ services/ # API communication layer
β”œβ”€β”€ utils/ # Date formatting, string helpers
β”œβ”€β”€ App.tsx # Root component β€” routing + providers
└── main.tsx # Entry point β€” renders to DOM
```

---

## πŸ“‚ Project Structure

```
ChatApp/
β”œβ”€β”€ Backend/
β”‚ β”œβ”€β”€ server.js
β”‚ β”œβ”€β”€ package.json
β”‚ β”œβ”€β”€ config/
β”‚ β”‚ └── redis.js
β”‚ β”œβ”€β”€ models/
β”‚ β”‚ β”œβ”€β”€ User.js
β”‚ β”‚ β”œβ”€β”€ Conversation.js
β”‚ β”‚ β”œβ”€β”€ Messages.js
β”‚ β”‚ β”œβ”€β”€ Invitation.js
β”‚ β”‚ └── PushSubscription.js
β”‚ β”œβ”€β”€ controllers/
β”‚ β”‚ β”œβ”€β”€ auth.controller.js
β”‚ β”‚ β”œβ”€β”€ user.controller.js
β”‚ β”‚ β”œβ”€β”€ conversation.controller.js
β”‚ β”‚ β”œβ”€β”€ message.controller.js
β”‚ β”‚ └── invitation.controller.js
β”‚ β”œβ”€β”€ routes/
β”‚ β”‚ β”œβ”€β”€ auth.routes.js
β”‚ β”‚ β”œβ”€β”€ user.routes.js
β”‚ β”‚ β”œβ”€β”€ conversation.routes.js
β”‚ β”‚ β”œβ”€β”€ message.routes.js
β”‚ β”‚ β”œβ”€β”€ invitation.routes.js
β”‚ β”‚ └── push.routes.js
β”‚ β”œβ”€β”€ middleware/
β”‚ β”‚ β”œβ”€β”€ auth.middleware.js
β”‚ β”‚ β”œβ”€β”€ httpRateLimiter.js
β”‚ β”‚ └── rateLimiter.js
β”‚ └── utils/
β”‚ └── sendPushNotification.js
β”œβ”€β”€ frontend/
β”‚ β”œβ”€β”€ index.html
β”‚ β”œβ”€β”€ package.json
β”‚ β”œβ”€β”€ vite.config.ts
β”‚ └── src/
β”‚ β”œβ”€β”€ App.tsx
β”‚ β”œβ”€β”€ main.tsx
β”‚ β”œβ”€β”€ pages/
β”‚ β”œβ”€β”€ components/
β”‚ β”œβ”€β”€ context/
β”‚ β”œβ”€β”€ hooks/
β”‚ β”œβ”€β”€ services/
β”‚ └── utils/
β”œβ”€β”€ .gitignore
β”œβ”€β”€ LICENSE
└── README.md
```

---

## ⚑ Getting Started

### Prerequisites
- Node.js v16+
- MongoDB (local or Atlas URI)
- Redis (local or cloud)
- Cloudinary account (for image uploads)
- VAPID keys (for push notifications)

### 1. Clone the repository

```bash
git clone https://github.com/AMANkumar0004/ChatApp.git
cd ChatApp
```

### 2. Backend setup

```bash
cd Backend
npm install
```

Create a `.env` file inside `Backend/`:

```
PORT=5000
MONGODB_URI=mongodb://localhost:27017/chatapp
JWT_SECRET=your_jwt_secret
REDIS_URL=redis://localhost:6379
CLOUDINARY_CLOUD_NAME=your_cloud_name
CLOUDINARY_API_KEY=your_api_key
CLOUDINARY_API_SECRET=your_api_secret
VAPID_PUBLIC_KEY=your_vapid_public_key
VAPID_PRIVATE_KEY=your_vapid_private_key
```

Start the backend:

```bash
npm start
```

### 3. Frontend setup

```bash
cd frontend
npm install
npm run dev
```

App runs at **http://localhost:5173**

> Make sure both backend and frontend are running simultaneously for real-time functionality to work.

---

## 🎯 Future Improvements

- [ ] End-to-end encryption for messages
- [ ] Voice and video calls integration
- [ ] Message reactions (emojis, likes)
- [ ] Read receipts and typing indicators
- [ ] Group chats with admin controls
- [ ] Message search and filtering
- [ ] Dark/light theme toggle

---

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

**Aman Kumar** β€” `AMANkumar0004`

[![GitHub](https://img.shields.io/badge/GitHub-AMANkumar0004-black?style=flat&logo=github)](https://github.com/AMANkumar0004)

---

## πŸ“„ License

MIT β€” free to use, modify, and distribute with attribution.

---

> *This README documents the architecture as of the latest commit (June 18, 2026). Implementation details may evolve as the project grows.*
Binary file added Screenshots/chat.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Screenshots/create.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Screenshots/signin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.