Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ’¬ Chatly

Real-Time Full-Stack Chat Application

A modern MVP for private messaging, contact discovery, and media sharing β€” built on a React frontend, an Express.js REST API, MongoDB for persistence, and Socket.IO for real-time messaging and presence.

License: MIT React Vite Node.js Express MongoDB Socket.IO

Report Bug Β· Request Feature


πŸ“– Overview

Chatly is a full-stack real-time chat application designed as a modern MVP for private messaging. It combines a polished React client with a Node.js/Express API and a Socket.IO layer that powers instant messaging, typing indicators, and online presence. User data and messages are persisted in MongoDB, and media (profile pictures, shared images) is handled via Cloudinary.

The project demonstrates how a production-style chat product can be structured end-to-end: authentication, real-time transport, media handling, and a responsive UI, all working together as one cohesive application.

✨ Features

Feature Description
πŸ” Authentication Secure JWT-based registration and login with cookie-backed sessions
⚑ Real-Time Messaging Instant one-to-one delivery to online users via Socket.IO
✍️ Typing Indicators Live "user is typing…" feedback in active conversations
🟒 Online Presence Real-time online/offline status for every contact
πŸ–ΌοΈ Image Sharing Send images in chat, stored and delivered via Cloudinary
πŸ‘οΈ Seen Status Messages marked as seen, with unread-count tracking per conversation
πŸ”Ž Contact Search Search contacts and filter to show online-only users
πŸ™ Profile Management Edit name/bio, upload a profile picture, and change password
🎨 Theme Toggle Light/dark theme switch across the app
πŸ“± Responsive UI Mobile-friendly sidebar + chat layout

πŸ“Έ Screenshots

Create Account

Sign Up

Welcome Back β€” Sign In

Sign In

Chat Window Chat Window

Profile Settings Profile Settings

Screenshots live in the /screenshots folder. Update or add new ones there and reference them the same way, e.g. ![Chat Window](screenshots/chat.png).

πŸ—οΈ Architecture

Chatly follows a two-tier architecture with a real-time transport layer running alongside the REST API:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   React Client    β”‚ ─────▢ β”‚      Express.js API        β”‚
β”‚ (UI / Routing /   β”‚ ◀───── β”‚ (Auth, Users, Messages,     β”‚
β”‚  Context state)   β”‚        β”‚  Socket.IO server)          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        β–²   β–²                             β”‚
        β”‚   β”‚  Socket.IO (live events)    β”‚
        β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        β”‚                                 β–Ό
        β”‚                          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚                          β”‚  MongoDB     β”‚
        β”‚                          β”‚ (Mongoose)   β”‚
        β”‚                          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        β”‚
        β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Cloudinary       β”‚
β”‚ (image storage)    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
  • Frontend Layer β€” React SPA handling auth flows, contact browsing, and the chat UI, with Context API providers for auth, chat, and socket state.
  • Backend Layer β€” Node.js/Express REST API for auth, users, and messages, plus an embedded Socket.IO server broadcasting real-time events (messages, typing, presence).
  • Data & Media Layer β€” MongoDB/Mongoose for persistent storage; Cloudinary for profile pictures and shared images.

πŸ› οΈ Tech Stack

Frontend: React, Vite, React Router, Tailwind CSS, Axios, Socket.IO Client, date-fns, emoji-picker-react, lucide-react Backend: Express.js, MongoDB, Mongoose, Socket.IO, JWT, bcryptjs, Multer, Cookie Parser Media: Cloudinary

πŸ“‚ Project Structure

Chatly/
β”œβ”€β”€ frontend/                 # React + Vite client
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ context/           # Auth, Chat, and Socket context providers
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   └── App.jsx
β”‚   └── ...
β”œβ”€β”€ backend/                   # Express + Socket.IO server
β”‚   β”œβ”€β”€ routes/                 # auth, users, messages
β”‚   β”œβ”€β”€ controllers/
β”‚   β”œβ”€β”€ models/                 # Mongoose schemas
β”‚   β”œβ”€β”€ middleware/
β”‚   β”œβ”€β”€ lib/                    # socket, cloudinary, db config
β”‚   └── server.js
└── README.md

Folder names above reflect the intended clean structure β€” see Roadmap for known cleanup items in the current repo layout.

πŸš€ Getting Started

Prerequisites

  • Node.js β‰₯ 18
  • MongoDB (local or Atlas)
  • A Cloudinary account (for image uploads)
  • npm or yarn

Installation

  1. Clone the repository

    git clone https://github.com/wasay-khanzada/Chatly.git
    cd Chatly
  2. Set up the backend

    cd backend
    npm install

    Create a .env file in backend/:

    PORT=5001
    MONGODB_URI=your_mongodb_connection_string
    JWT_SECRET=your_jwt_secret
    NODE_ENV=development
    
    CLOUDINARY_CLOUD_NAME=your_cloudinary_cloud_name
    CLOUDINARY_API_KEY=your_cloudinary_api_key
    CLOUDINARY_API_SECRET=your_cloudinary_api_secret
    npm run dev
  3. Set up the frontend

    cd ../frontend
    npm install
    npm run dev
  4. Open http://localhost:5173 in your browser.

πŸ”Œ API Overview

Auth

Method Endpoint Description
POST /api/auth/register Register a new user
POST /api/auth/login Authenticate and receive a JWT
POST /api/auth/logout End the current session
GET /api/auth/check Validate the current session

Users

Method Endpoint Description
GET /api/users Get contacts / searchable user list
PUT /api/users/profile Update profile info and/or avatar
PUT /api/users/password Change password

Messages

Method Endpoint Description
GET /api/messages/:userId Get message history with a specific user
POST /api/messages/send/:userId Send a text or image message
PUT /api/messages/seen/:id Mark a message (or conversation) as seen

Full request/response schemas can be documented separately (e.g. via Postman collection or OpenAPI spec).

⚑ Real-Time Events (Socket.IO)

Event Direction Description
getOnlineUsers Server β†’ Client Broadcasts the current list of online user IDs
newMessage Server β†’ Client Pushes a newly sent message to the recipient
typing Client ↔ Client Notifies the recipient that a user is typing
stopTyping Client ↔ Client Clears the typing indicator
messageSeen Client ↔ Client Updates seen status in real time

πŸ—ΊοΈ Roadmap

  • Standardize user field naming across frontend and backend
  • Fix the typing flow to fully align the hook and UI behavior
  • Add stronger input validation and security middleware
  • Improve socket/presence scalability for multi-instance deployment (move off in-memory maps)
  • Add automated tests (unit & integration)
  • Add CI/CD and production deployment configuration

See open issues for a full list of proposed features and known issues.

🀝 Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines on how to get started.

πŸ“ License

Distributed under the MIT License. See LICENSE for more information.

πŸ™ Acknowledgements


Made with πŸ’š by wasay-khanzada

About

Chatly - a full-stack real-time chat app built with React, Express.js, Socket.IO, and MongoDB. Features JWT authentication, live one-to-one messaging, typing indicators, online/offline presence, image sharing via Cloudinary, message seen status, and profile management, all wrapped in a clean, responsive UI.

Topics

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages