YASHCHAT is a full-stack real-time chat application featuring secure user authentication, a modern UI, and real-time messaging using Socket.io. The project is split into two subfolders: a frontend built with Next.js, and a backend built with Express.js.
- Frontend: https://yashchat-two.vercel.app
- Backend (API): https://chat-backend-3e4y.onrender.com
Chat-App/
│
├── backend/ → Express.js backend
│ ├── controllers/ → Route logic (auth, user, chat, message)
│ ├── middleware/ → Auth middleware
│ ├── models/ → Mongoose models
│ ├── routes/ → API route files
│ ├── socket/ → Socket.io logic
│ ├── .env → Environment variables
│ └── server.js → App entry point
│
└── frontend/ → Next.js frontend
├── app/ → App router pages
├── components/ → UI components (e.g., MessageCard, ThemeToggle)
├── lib/ → API utilities & helpers
├── public/ → Static assets
├── .env.local → Environment variables
└── tailwind.config.js → TailwindCSS config
- Framework: Next.js
- Styling: Tailwind CSS
- UI Components: shadcn/ui
- Real-time: Socket.io Client
- Server: Express.js
- Database: MongoDB Atlas
- ORM: Mongoose
- Auth: JWT (JSON Web Token)
- Real-time: Socket.io
- Password Hashing: bcryptjs
- JWT-based authentication.
- Passwords are securely hashed using bcryptjs.
- Protected routes using middleware (
/api/messages,/api/chats).
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/auth/register |
Register new user |
| POST | /api/auth/login |
Login user & get token |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/users |
Get all users |
| GET | /api/users/:id |
Get user by ID |
| PATCH | /api/users/:id |
Update user |
| DELETE | /api/users/:id |
Delete user |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/chats/user/:id |
Get all user chats |
| GET | /api/chats/:id |
Get single chat |
| POST | /api/chats |
Create new chat |
| POST | /api/chats/add-message |
Add message to chat |
| PATCH | /api/chats/update |
Update chat info |
| DELETE | /api/chats/:id |
Delete chat |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/messages/:chatId |
Get messages by chat ID |
| POST | /api/messages |
Send new message |
- ✅ User registration & login
- ✅ Real-time one-on-one messaging
- ✅ Theme toggling (light/dark mode)
- ✅ Secure backend with JWT
- 🔜 Group chats (coming soon!)
- 🔐 Protected chat/message endpoints
PORT=5000
MONGO_URI=your_mongo_uri
JWT_SECRET=your_jwt_secretNEXT_PUBLIC_API_BASE=https://chat-backend-3e4y.onrender.comRun these from the respective directories:
npm install
npm run devnpm install
npm run dev-
Frontend: Vercel
-
Backend: Render
- Socket.io is hosted on Render since Vercel doesn't support WebSockets.
Made by YASHDEV42