Bind is a production-ready, full-stack real-time chat application. It features a robust decoupled architecture using a RESTful API for persistent data storage and a Socket.io WebSocket server for instantaneous message broadcasting.
- JWT Token Rotation: Dual-token system (15-min Access, 10-day Refresh) securely stored in HTTP-Only cookies to prevent XSS attacks.
- Silent Refresh Pipeline: Automatic session renewal via Axios interceptors.
- Hybrid Login: Support for both secure email/password (Bcrypt hashing) and Google OAuth 2.0.
- Cloudinary Integration: Direct avatar uploads using Multer with automatic stale-file cleanup.
- Dynamic Profiles: Update display names, bios, and securely change passwords.
- Bi-directional WebSockets: Live message broadcasting using Socket.io.
- In-Memory Phonebook: Custom Socket ID mapping to ensure messages are instantly routed to the correct active user.
- Cursor-Based Pagination: Highly optimized "infinite scroll" for the conversation sidebar, preventing database overload at scale.
- Offline Delivery: Messages sent to offline users are securely stored in MongoDB and served upon their next login.
The repository is strictly separated into decoupled Frontend and Backend environments.
- Runtime: Node.js
- Framework: Express.js
- Database: MongoDB (with Mongoose ODM)
- Real-time: Socket.io
- Security: JSON Web Tokens (jsonwebtoken), Bcrypt, Cookie-Parser
- Storage: Cloudinary & Multer
- Framework: React / Next.js
- Network: Axios (with interceptors for token refresh)
- Real-time: Socket.io-client
- State Management: Zustand
- Node.js (v18+)
- MongoDB Atlas URI (or local MongoDB instance)
- Cloudinary Account (for image hosting)
- Google Cloud Console (for OAuth Client ID)
git clone https://github.com/your-username/Talk_8iv.git
cd Talk_8iv/backendnpm installCreate a .env file in the backend directory:
PORT=5000
MONGO_URI=your_mongodb_connection_string
CORS_ORIGIN=http://localhost:3000
ACCESS_TOKEN_SECRET=your_access_token_secret
ACCESS_TOKEN_EXPIRY=15m
REFRESH_TOKEN_SECRET=your_refresh_token_secret
REFRESH_TOKEN_EXPIRY=10d
CLOUDINARY_CLOUD_NAME=your_cloud_name
CLOUDINARY_API_KEY=your_cloudinary_api_key
CLOUDINARY_API_SECRET=your_cloudinary_api_secretnpm run devThe server should now be running at:
http://localhost:5000
- Express.js
- MongoDB & Mongoose
- JSON Web Token (JWT)
- Bcrypt
- Cookie Parser
- Cloudinary
- Multer
- CORS
- Dotenv
- Socket.io
cd Talk_8iv/frontendnpm installCreate a .env.local file in the frontend directory:
NEXT_PUBLIC_API_URL=http://localhost:5000/api
NEXT_PUBLIC_SOCKET_URL=http://localhost:5000npm run devThe frontend should now be running at:
http://localhost:3000
Talk_8iv/
β
βββ backend/
β βββ src/
β β βββ controllers/
β β βββ models/
β β βββ routes/
β β βββ middlewares/
β β βββ utils/
β β βββ db/
β β βββ app.js
β β βββ index.js
β β
β βββ public/
β βββ .env
β βββ package.json
β βββ README.md
β
βββ frontend/
βββ app/
βββ components/
βββ lib/
βββ public/
βββ store/
βββ .env.local
βββ package.json
βββ README.md