Skip to content

A messaging app that allows users to send messages to each other.

Notifications You must be signed in to change notification settings

kiptalam1/Chattr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

75 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Chattr

A messaging app that allows users to send messages to each other.

πŸ› οΈ Tech Stack

Frontend: React (with Context API)

Backend: Node.js, Express.js

Database: MongoDB + Mongoose

Realtime: Socket.IO (WebSocket-based)

Auth: JWT (JSON Web Tokens)

Styling: CSS Modules + CSS Variables (Dark/Light Mode)

Uploads: Multer (local or Cloudinary)

πŸš€ Development Roadmap (Testable Per Step) βœ… Step 1: Project Setup

Create monorepo: client/ + server/

Enable ESM ("type": "module")

Setup .env files for sensitive config

Setup basic dev script (nodemon, concurrently)

πŸ”Ž Test: Console logs run from both client and server βœ… Step 2: Express Server + MongoDB

Install core backend deps: express, mongoose, cors, dotenv

Connect to MongoDB using Mongoose

Create User model schema

πŸ”Ž Test: Server runs β†’ DB connects β†’ sample user saved βœ… Step 3: Authentication System (JWT)

Install: bcrypt, jsonwebtoken

Create /auth/register and /auth/login routes

Hash passwords with bcrypt

Issue JWT tokens on login

Protect routes with verifyToken middleware

πŸ”Ž Test: Register & login via Postman β†’ secure /profile route βœ… Step 4: React Frontend + Auth Context

Setup React app with axios, react-router-dom

Build AuthContext to manage JWT & user state

Forms for Register & Login

πŸ”Ž Test: Register/login from frontend β†’ store token β†’ redirect on success βœ… Step 5: Setup Socket.IO

Backend: Attach Socket.IO to HTTP server

Frontend: Connect using socket.io-client

Store socket connection in context

πŸ”Ž Test: Open console β†’ see unique socket ID on connect βœ… Step 6: Global Chat (One Room)

Emit/receive send_message + receive_message events

Display real-time message flow across tabs

πŸ”Ž Test: Two tabs exchange messages instantly βœ… Step 7: Private 1-to-1 Chat (DMs)

On login, map userId β†’ socket.id

Add send_private_message handler (Socket.IO)

Check friendship or auth

Chat UI opens per user

πŸ”Ž Test: Direct message goes only to the target user βœ… Step 8: Group Chat / Room System

Create/join/leave named rooms

Use socket.join(room) and io.to(room).emit(...)

Chat messages scoped to room

πŸ”Ž Test: Room messages are isolated between members βœ… Step 9: Friends System

Create FriendRequest model

Routes: send request, accept, list friends

UI to search, add, and display friends

πŸ”Ž Test: Only accepted friends can initiate private chats βœ… Step 10: Image Messaging

Install multer

Backend: Accept image uploads

Store locally or with Cloudinary

Send image URLs via Socket.IO

Frontend: File input + preview

πŸ”Ž Test: Upload and display image in chat bubble βœ… Step 11: Online Users Indicator

Track online users in memory (userId ↔ socket.id)

Broadcast presence on connect/disconnect

Frontend: Show real-time online list

πŸ”Ž Test: Users appear/disappear in live sidebar as they connect βœ… Step 12: Deploy (Final Step)

Backend: Render, Railway, or Fly.io

Frontend: Netlify or Vercel

Use CORS and environment configs

Confirm Socket.IO works cross-origin

πŸ”Ž Test: All features work on live URLs across browsers πŸ”₯ Extra Features (Implemented for Credit)

πŸŒ™ Dark/Light mode via [data-theme] and CSS variables

πŸ“Έ Image uploads and real-time rendering

🎯 Scheduled messages (optional enhancement)

πŸ§ͺ Ephemeral threads (optional enhancement)

πŸ›‘οΈ Invisible mode / ghost reads (optional enhancement)

DiceBear for avatars: https://api.dicebear.com/7.x/adventurer/svg?seed=JohnDoe&radius=50&backgroundColor=ffd5ec

Releases

No releases published

Packages

No packages published