Skip to content

js-lover/PulseChat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

19 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

React Chat App πŸ’¬

A real-time chat application built with React, Vite, TailwindCSS, Socket.IO, Express.js, and MongoDB. The project is structured with separate frontend and backend folders for clean development and deployment.


πŸš€ Features

  • πŸ” Authentication (JWT, bcrypt)
  • πŸ‘€ User registration & login
  • πŸ’¬ Real-time messaging (Socket.IO)
  • πŸ—‚οΈ MongoDB database integration (via Mongoose)
  • 🎨 Modern UI with TailwindCSS & Radix UI
  • πŸ“± Responsive design
  • ⚑ Fast development with Vite & React 19
  • πŸ›‘οΈ CORS & secure API endpoints
  • πŸ§ͺ API testing with Postman

πŸ› οΈ Tech Stack

Frontend

  • React 19, Vite, TypeScript
  • TailwindCSS, Radix UI, Lucide Icons
  • React Router v7
  • Socket.IO Client
  • Axios
  • Lottie React
  • Utility: clsx, class-variance-authority, tailwind-merge

Backend

  • Node.js, Express.js
  • MongoDB with Mongoose
  • Socket.IO (WebSocket)
  • JWT (jsonwebtoken), bcrypt
  • dotenv, CORS, body-parser
  • Dev: nodemon

πŸ“‚ Project Structure

react-chat-app/
β”œβ”€ frontend/                # React + Vite + TailwindCSS client
β”‚  β”œβ”€ src/
β”‚  β”œβ”€ index.html
β”‚  β”œβ”€ package.json
β”‚  └─ ...
└─ backend/                 # Express + MongoDB + Socket.IO server
   β”œβ”€ index.js              # Your server entry (example)
   β”œβ”€ package.json
   β”œβ”€ .env                  # Environment variables (see below)
   └─ ...

βœ… Prerequisites

  • Node.js (LTS recommended)

  • MongoDB:

    • Local MongoDB instance or
    • MongoDB Atlas connection string
  • Postman (optional, for API testing)


βš™οΈ Installation

1) Clone the repository

git clone https://github.com/serhatbarisaydin/react-chat-app.git
cd react-chat-app

2) Install dependencies

Frontend

cd frontend
npm install

Backend

cd ../backend
npm install

πŸ” Environment Variables (Backend)

Create a .env file inside the backend folder:

MONGO_URI= "mongodb://localhost:27017/<yourProjectName>"
JWT_SECRET=your_jwt_secret
PORT=8000
  • MONGO_URI: Your MongoDB connection string (local or Atlas)
  • JWT_SECRET: Any strong secret string
  • PORT: Backend port (defaults to 5000 in examples)

▢️ Running the Project

Start Backend (API + WebSocket)

cd backend
npm start

Ensure your start script runs your server entry (e.g., nodemon index.js).

Start Frontend (Vite dev server)

cd frontend
npm run dev
  • Frontend: http://localhost:5173
  • Backend (example): http://localhost:5000

πŸ—„οΈ Database

  • User data is stored in MongoDB using Mongoose ODM.
  • Auth flows (register/login) interact with MongoDB collections.
  • Configure your MongoDB connection in the backend via .env.

πŸ§ͺ API Testing (Postman)

The backend endpoints were tested with Postman.

API Endpoints

  • POST /api/auth/register β†’ Register a new user

  • POST /api/auth/login β†’ Login & receive JWT

  • POST /api/users/create β†’ Create a new user (protected)

  • GET /api/users/getAllUsers β†’ Fetch all users (protected)

  • DELETE /api/users/delete/:id β†’ Delete user by ID (protected)

  • PUT /api/users/update/:id β†’ Update user by ID (protected)

Include Authorization: Bearer <token> header for all protected routes.


πŸ”Œ Real-time (Socket.IO)

Client (example):

import { io } from "socket.io-client";

const socket = io("http://localhost:5000", {
  withCredentials: true,
  transports: ["websocket"],
});

socket.on("connect", () => {
  console.log("connected", socket.id);
});

socket.on("message", (msg) => {
  // handle incoming chat message
});

Server (example idea):

io.on("connection", (socket) => {
  socket.on("message", (payload) => {
    // persist to DB, then emit to room/users
    io.emit("message", payload);
  });
});

🧰 Scripts

Frontend

  • npm run dev β†’ Start Vite dev server
  • npm run build β†’ Build for production
  • npm run preview β†’ Preview production build
  • npm run lint β†’ Run ESLint

Backend

  • npm start β†’ Start backend (e.g., nodemon index.js)

πŸ–ΌοΈ Screenshots

Ekran Resmi 2025-08-28 16 17 05 Ekran Resmi 2025-08-28 16 17 19 Ekran Resmi 2025-08-28 16 17 35 Ekran Resmi 2025-08-28 16 17 45 Ekran Resmi 2025-08-28 16 18 50

🀝 Contributing

  1. Fork the repo
  2. Create a feature branch: git checkout -b feature/awesome
  3. Commit changes: git commit -m "feat: add awesome feature"
  4. Push branch: git push origin feature/awesome
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors