Skip to content

Siddharth-732/Bind

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

195 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Node.js Express.js MongoDB Socket.io React Next.js

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.

Features

Enterprise-Grade Authentication

  • 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.

Profile Management

  • Cloudinary Integration: Direct avatar uploads using Multer with automatic stale-file cleanup.
  • Dynamic Profiles: Update display names, bios, and securely change passwords.

Real-Time Messaging Engine

  • 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.

Architecture & Tech Stack

The repository is strictly separated into decoupled Frontend and Backend environments.

Backend (/backend)

  • 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

Frontend (/frontend)

  • Framework: React / Next.js
  • Network: Axios (with interceptors for token refresh)
  • Real-time: Socket.io-client
  • State Management: Zustand

Getting Started

Prerequisites

  • Node.js (v18+)
  • MongoDB Atlas URI (or local MongoDB instance)
  • Cloudinary Account (for image hosting)
  • Google Cloud Console (for OAuth Client ID)

πŸš€ Backend Setup

1. Clone the Repository

git clone https://github.com/your-username/Talk_8iv.git
cd Talk_8iv/backend

2. Install Dependencies

npm install

3. Configure Environment Variables

Create 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_secret

4. Run the Development Server

npm run dev

The server should now be running at:

http://localhost:5000

πŸ“¦ Key Dependencies

  • Express.js
  • MongoDB & Mongoose
  • JSON Web Token (JWT)
  • Bcrypt
  • Cookie Parser
  • Cloudinary
  • Multer
  • CORS
  • Dotenv
  • Socket.io

🎨 Frontend Setup

1. Navigate to the Frontend Directory

cd Talk_8iv/frontend

2. Install Dependencies

npm install

3. Configure Environment Variables

Create a .env.local file in the frontend directory:

NEXT_PUBLIC_API_URL=http://localhost:5000/api
NEXT_PUBLIC_SOCKET_URL=http://localhost:5000

4. Run the Development Server

npm run dev

The frontend should now be running at:

http://localhost:3000

πŸ“‚ Project Structure

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

About

Bind is a modern communication hub for teams and communities.

Resources

License

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors