A lightweight, modular terminal chat platform powered by WebSockets, featuring a rich TUI, user authentication, room management, and persistent message history.
Rooms • Direct Messages • Authentication • Chat History • Live Presence
A modular, handler-based WebSocket server with a rich blessed terminal interface on the client.
Low-latency bi-directional communication over WebSockets. Messages are broadcast instantly to all users in a room.
User registration and login backed by argon2 password hashing. Sessions are tracked in-memory on the server.
Create, list, and join chat rooms. A general room is pre-created on startup. Rooms persist until the server restarts.
Send private messages directly to any online user with the /dm command, bypassing the current room channel.
Messages are stored in a local SQLite database via the built-in node:sqlite module. Fetch history with /history [n].
A rich, interactive client built with blessed — featuring a scrollable chat log, live status bar, and a focused input box.
A clean, handler-based server with in-memory state and SQLite-backed persistence.
┌─────────────────┐
Client A (TUI) │ Wire Server │
──────────────► │ WebSocket :5051│◄── Client B (TUI)
│ │
│ ┌───────────┐ │
│ │ Router │ │
│ └─────┬─────┘ │
│ handleAuth │
│ handleMessage │
│ handleCmd │
│ ┌───────────┐ │
│ │ SQLite │ │
│ │ chat.db │ │
│ └───────────┘ │
└─────────────────┘
wire-chat/
├── client/
│ ├── client.js # TUI client (blessed + WebSocket)
│ └── modules/
│ └── cmdAction.js
├── server/
│ ├── server.js # WebSocket server, routing
│ └── modules/
│ ├── handlers/
│ │ ├── handleAuth.js # register / login
│ │ ├── handleMessage.js # broadcast messages
│ │ └── handleCmd.js # /join, /dm, /rooms ...
│ └── services/
│ ├── broadcast.js # room broadcasting
│ └── database.js # SQLite operations
└── shared/
├── protocol.js # packet factory functions
├── validator.js # packet schema validation
└── commands.js # command constants
Get WireChat running locally in under a minute.
# Clone from GitHub
git clone https://github.com/lokeshkrio/wire-chat.git
cd wire-chat
# Install server packages
cd server && npm install
# Install client packages
cd ../client && npm install
cd server
node server.js
# → Connected to the SQLite database.
# → Wire server running
# In a new terminal window
cd client
node client.js
# Then register and login:
/register alice mysecretpass
/login alice mysecretpass
All commands are entered in the client's input box, prefixed with /.
| Command | Description |
|---|---|
/register <user> <pass> | Create a new account |
/login <user> <pass> | Authenticate and join the server |
/join <room> | Join or switch to a room |
/create-room <name> [desc] | Create a new room with an optional description |
/rooms | List all available rooms and their user count |
/dm <user> <message> | Send a private direct message |
/history [limit] | Fetch recent messages from the current room (default: 50) |
/online | List all currently connected users |
/quit | Quit the application |
/help | Display the available command list |
WireChat uses a simple JSON packet protocol over WebSockets.
{
"type": "message",
"content": "Hello everyone"
}
{
"type": "command",
"command": "dm",
"target": "Alice",
"content": "Hi!"
}
{
"type": "command",
"command": "join",
"target": "general"
}
{
"type": "system",
"content": "Alice joined general"
}