Skip to content

About

No description, website, or topics provided.

Resources

Stars

6 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

9 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ’¬ Chat Pro

A modern full-stack real-time chat application built with React, Node.js, Express, MongoDB, and Socket.IO.

Chat Pro is a scalable real-time messaging platform that demonstrates modern full-stack development practices. It includes authentication, real-time communication, chat rooms, private messaging, file sharing, and a responsive user interface.

Whether you're learning how real-time applications work or looking for a solid project architecture, Chat Pro provides a practical and production-oriented foundation.


✨ Features

πŸ‘€ Authentication & User Management

  • Secure user registration and login
  • JWT-based authentication
  • Password hashing with Bcrypt
  • User profile management
  • Online user presence

πŸ’¬ Real-Time Messaging

  • Instant messaging powered by Socket.IO
  • Live message updates without page refresh
  • Chat history persistence
  • Typing indicators
  • Online/offline status

🏠 Chat Rooms

  • Create and join chat rooms
  • Leave rooms
  • Group conversations
  • View room members

πŸ”’ Private Conversations

  • Direct messaging
  • Private chat history
  • Secure communication between users

πŸ“Ž File Sharing

  • Image uploads
  • File uploads
  • Image preview inside chat
  • File downloads

🎨 Modern UI

  • Responsive design
  • Mobile-friendly
  • Desktop optimized
  • Built with React
  • Styled using Tailwind CSS

πŸ›  Tech Stack

Frontend

  • React
  • React Router
  • Axios
  • Socket.IO Client
  • Tailwind CSS

Backend

  • Node.js
  • Express.js
  • MongoDB
  • Mongoose
  • Socket.IO
  • JWT
  • Bcrypt
  • Multer

DevOps

  • Docker
  • Docker Compose
  • Nginx

πŸ“ Project Structure

chat-pro/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ config/
β”‚   β”‚   β”œβ”€β”€ controllers/
β”‚   β”‚   β”œβ”€β”€ middleware/
β”‚   β”‚   β”œβ”€β”€ models/
β”‚   β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   β”œβ”€β”€ socket/
β”‚   β”‚   └── server.js
β”‚   β”œβ”€β”€ uploads/
β”‚   β”œβ”€β”€ .env
β”‚   └── package.json
β”‚
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”œβ”€β”€ App.jsx
β”‚   β”‚   └── main.jsx
β”‚   β”œβ”€β”€ .env
β”‚   └── package.json
β”‚
β”œβ”€β”€ docker-compose.yml
β”œβ”€β”€ .env.example
β”œβ”€β”€ .gitignore
└── README.md

πŸš€ Getting Started

Prerequisites

Make sure you have installed:

  • Node.js
  • npm
  • MongoDB
  • Git

Or simply use Docker.


Clone the Repository

git clone https://github.com/khodemadi/chat-pro2.git

cd chat-pro

πŸ”§ Backend Setup

cd backend
npm install

Create a .env file.

PORT=5000

MONGODB_URI=mongodb://localhost:27017/chat-pro

JWT_SECRET=your-super-secret-key

JWT_EXPIRES_IN=15m

REFRESH_TOKEN_SECRET=your-refresh-secret-key

CLIENT_URL=http://localhost:5173

Start the backend server.

npm run dev

Backend runs on:

http://localhost:5000

🎨 Frontend Setup

Open another terminal.

cd frontend

npm install

npm run dev

Frontend runs on:

http://localhost:5173

🐳 Run with Docker

Build and start all services:

docker compose up --build

Run in detached mode:

docker compose up -d --build

Stop services:

docker compose down

πŸ” Authentication Flow

The application uses JWT for secure authentication.

User
 β”‚
 β–Ό
Login
 β”‚
 β–Ό
Backend
 β”‚
 β–Ό
Validate Credentials
 β”‚
 β–Ό
Generate JWT
 β”‚
 β–Ό
Return Token
 β”‚
 β–Ό
Frontend

Authentication Endpoints

POST /api/auth/register
POST /api/auth/login
POST /api/auth/refresh
POST /api/auth/logout

⚑ Real-Time Communication

Socket.IO enables low-latency communication between connected users.

User A
   β”‚
   β”‚ Send Message
   β–Ό
Socket.IO Server
   β”‚
   β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Ί MongoDB
   β”‚
   β–Ό
User B

Socket Events

join-room
leave-room
send-message
receive-message
typing
stop-typing
user-online
user-offline

πŸ—„ Database Models

User

username
email
password
avatar
status
createdAt

Room

name
description
owner
members
createdAt

Message

sender
receiver
room
text
file
createdAt

πŸ“Ž File Upload

Uploads are handled with Multer.

Supported file types include:

.jpg
.png
.gif
.pdf
.zip
.docx

For production deployments, cloud storage solutions such as AWS S3 or Cloudinary are recommended.


πŸ›‘ Security Best Practices

For production environments, consider implementing:

  • HTTPS
  • Secure environment variables
  • Input validation
  • Password hashing
  • Rate limiting
  • Proper CORS configuration
  • Helmet middleware
  • Upload size limits
  • File type validation
  • Secure Refresh Tokens

πŸ“± Responsive Design

Optimized for:

  • πŸ“± Mobile
  • πŸ“Ÿ Tablet
  • πŸ’» Laptop
  • πŸ–₯ Desktop

πŸš€ Roadmap

Future improvements include:

  • Voice calls
  • Video calls (WebRTC)
  • Voice messages
  • Message reactions
  • Reply to messages
  • Edit messages
  • Delete messages
  • Search messages
  • Push notifications
  • Dark mode
  • End-to-End Encryption
  • User blocking and reporting
  • Admin dashboard
  • Roles & permissions

🀝 Contributing

Contributions are welcome!

  1. Fork the repository.

  2. Create a feature branch.

git checkout -b feature/amazing-feature
  1. Commit your changes.
git commit -m "Add amazing feature"
  1. Push your branch.
git push origin feature/amazing-feature
  1. Open a Pull Request.

πŸ“„ License

This project is licensed under the MIT License.

See the LICENSE file for more information.


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

Developed with ❀️ using modern JavaScript technologies to explore scalable real-time application architecture.


⭐ Support

If you found this project useful:

  • ⭐ Star the repository
  • 🍴 Fork it
  • πŸ›  Contribute improvements
  • πŸ“’ Share it with others

Your support helps the project grow.

About

No description, website, or topics provided.

Resources

Stars

6 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages