A full-stack real-time messaging app with authenticated users, persistent conversations, and instant delivery via WebSockets.
- Backend: Node.js + Express + Socket.io + MongoDB
- Frontend: React + Vite + Tailwind CSS
- Auth: JWT tokens (httpOnly cookies) + bcrypt password hashing
- Real-time: WebSocket (Socket.io) for instant message delivery
- Storage: MongoDB with Mongoose ODM
- UI: Component library (primitives, layouts, chat components)
- ✅ User authentication (signup, login, logout)
- ✅ Real-time messaging with online/offline status
- ✅ Persistent conversation history
- ✅ Responsive UI (mobile-first, works on all devices)
- ✅ Clean component architecture
- ✅ Secure routes (JWT validation)
- ✅ Automatic conversation creation on first message
Backend (port 5500):
cd backend
npm install
npm run devFrontend (port 5173):
cd frontend
npm install
npm run devThen open http://localhost:5173 in your browser.
Create backend/.env:
MONGO_URI=mongodb://localhost:27017/syncspace
JWT_SECRET=your_secret_key_here
PORT=5500
ALLOWED_ORIGINS=http://localhost:5173
For MongoDB, use local instance or MongoDB Atlas.
| Method | Endpoint | Auth | Purpose |
|---|---|---|---|
| POST | /api/auth/register |
❌ | Create account |
| POST | /api/auth/login |
❌ | Login, get JWT |
| POST | /api/auth/logout |
✅ | Logout |
| POST | /api/message/send/:id |
✅ | Send message (real-time) |
| GET | /api/message/getMessages/:id |
✅ | Get chat history |
| GET | /api/users |
✅ | Get user list |
- Express.js (HTTP server)
- Socket.io (WebSocket)
- MongoDB + Mongoose (database)
- JWT + bcrypt (auth)
- Node.js 16+ (runtime)
- React 18 (UI)
- Vite (build tool)
- Tailwind CSS (styling)
- Socket.io-client (WebSocket)
- Zustand (state management)
- Axios (HTTP)
backend/
├─ server.js (Express + Socket.io entry)
├─ controllers/ (auth, messages, users logic)
├─ models/ (User, Message, Conversation schemas)
├─ routes/ (API endpoints)
├─ middleware/ (JWT validation)
└─ db/ (MongoDB connection)
frontend/
├─ src/
│ ├─ pages/ (Login, Signup, Home, Settings)
│ ├─ components/ (Primitives, Layout, Chat UI)
│ ├─ context/ (Auth, Socket, Theme state)
│ ├─ hooks/ (Custom API hooks)
│ └─ zustand/ (Conversation state)
- User signs up → password hashed (bcrypt)
- Login → JWT generated, stored in httpOnly cookie
- Protected routes validate JWT via
secureRoutemiddleware
- User sends message →
POST /api/message/send/:receiverId - Message saved to MongoDB
- If receiver is online: emit via Socket.io instantly
- If offline: stored, delivered on next login
connect– User joins, updates online user listdisconnect– User leaves, updates online statusnewMessage– Real-time message delivery to receiver
Current State: Core features working, needs hardening for production.
What's Missing:
- Automated tests (unit, integration, E2E)
- CI/CD pipeline
- Rate limiting
- Input validation/sanitization
- Error logging/monitoring
- HTTPS + secure cookies
- Database backups
- Socket.io clustering (Redis adapter)
- API documentation (Swagger/OpenAPI)
For detailed info:
START_HERE.md— Quick 5-min local setupdocs/architecture.md— System design & data flowDELIVERABLES.md— Project summarybackend/README.md— Backend-specific detailsfrontend/README.md— Frontend-specific details
- Run both servers locally (see Quick Start)
- Sign up and test real-time messaging
- Open DevTools to see Socket.io events
- Check architecture docs for deeper understanding
- Extend features or deploy
Status: Working prototype
License: MIT (if applicable)