A fast and clean real-time messenger built with Bun, Express + Socket.io, MongoDB + Memcached, and a Vite + React + ShadCN frontend.
Make sure you’ve got Bun, MongoDB, and Memcached running locally.
# clone your project
git clone <https://github.com/nodiry/chat-demo.git >
cd chat-demoProject structure:
messenger/
├── server/ # Express + Socket.io backend
└── client/ # React (Vite) frontend with ShadCN UI
Inside the root directory (where this README is), you’ll find a script called run.sh.
It installs dependencies for both client and server, and runs them together.
chmod +x run.sh # make it executable
./run.sh # launch both backend and frontendThis script will:
- 🔧
bun installdependencies in both/serverand/client - ⚙️ start both with
bun run dev - 🧩 keep both processes alive and show their logs
Once both are running:
👉 Frontend: http://localhost:5173 👉 Backend (Socket.io + API): http://localhost:3005
- Open http://localhost:5173 in your browser.
- Enter your username and your receiver’s name.
- Open another browser tab or different account and swap the names.
- You’ll be greeted with the chat interface — messages will sync in real time! ⚡
- Notifications will appear regardless of the page you’re on, thanks to the global notification context wrapper. 🧩
| Layer | Tech | Description |
|---|---|---|
| 🧠 Backend | Express + Socket.io | Real-time communication and API server |
| 💾 Database | MongoDB | Message and user data storage |
| ⚡ Cache | Memcached | Fast caching layer for user sessions or frequent lookups |
| 🧩 Frontend | Vite + React + ShadCN/UI | Fast modern frontend with clean components |
| 🚀 Runtime | Bun | Super-fast JS runtime replacing Node.js |
| 🖥️ Host | Your own VPS (Ubuntu/Debian) | Self-maintained for full control |
| Component | Host | Port |
|---|---|---|
| Server | localhost | 3005 |
| MongoDB | localhost | 27017 (default) |
| Memcached | localhost | 11211 |
| Frontend (Vite) | localhost | 5173 |
| Action | Command |
|---|---|
| Install deps manually | bun install inside each folder |
| Run backend only | cd server && bun run dev |
| Run frontend only | cd client && bun run dev |
| Stop all | CTRL + C |
messenger/
│
├── server/
│ ├── src/
│ │ ├── index.ts # Express + Socket.io entry
│ │ ├── db/ # Mongo connection + Memcached logic
│ │ ├── routes/ # API endpoints
│ │ └── utils/ # Helpers, validation, etc.
│ └── package.json
│
├── client/
│ ├── src/
│ │ ├── App.tsx # Wrapped in Notification Context
│ │ ├── components/ # ShadCN UI parts
│ │ └── pages/ # Chat UI & forms
│ └── package.json
│
└── run.sh # Runs everything automatically
| Problem | Fix | |
|---|---|---|
| Mongo not connecting | Make sure MongoDB is running: sudo systemctl start mongod |
|
| Memcached not running | sudo systemctl start memcached |
|
| Port already in use | Kill the process using it: sudo lsof -i :3005 then kill -9 <pid> |
|
| Bun not found | Install it: `curl -fsSL https://bun.sh/install | bash` |
You can easily extend this:
- Add file uploads through Socket.io streams
- Integrate message history pagination
- Implement authentication with JWT or sessions
- Add online/offline status indicators
Once everything’s running, open multiple browsers and start chatting! Enjoy your fast, lightweight, real-time Bun-powered messenger 🧡
⚡ “Fast servers, clean UI, zero nonsense — just chat.”
---