A real-time terminal-based chat application built with Rust. Features a beautiful TUI (Terminal User Interface) client powered by Cursive and an async TCP server using Tokio.
- Real-time messaging - Instant message delivery using TCP sockets
- Beautiful TUI client - Clean terminal interface with colors and panels
- Multi-user support - Multiple clients can connect and chat simultaneously
- Server notifications - Join/leave messages when users connect or disconnect
- Timestamps - Every message shows when it was sent
- Easy launcher - Interactive menu to start server and clients
chat-app/
├── src/
│ ├── main.rs # Launcher menu
│ └── bin/
│ ├── server.rs # Chat server
│ └── client.rs # Chat client (TUI)
├── Cargo.toml
├── .env # Optional: HOST and PORT config
└── README.md
- Rust (1.75 or later recommended)
- Cargo (comes with Rust)
The easiest way to run the app is using the built-in launcher:
cargo runThis will show an interactive menu:
╔════════════════════════════════╗
║ 🚀 CHAT APP LAUNCHER ║
╠════════════════════════════════╣
║ 1. Start Server (new window) ║
║ 2. Start Client (new window) ║
║ 3. Exit ║
╚════════════════════════════════╝
- Press
1to start the server (opens in a new terminal window) - Press
2to start a client (enter your username, opens in a new window) - Repeat step 2 to add more chat participants!
You can also run the server and client directly:
Start the server:
cargo run --bin serverStart a client (in a separate terminal):
cargo run --bin client <username>Example:
cargo run --bin client Alice
cargo run --bin client BobCreate a .env file in the project root to customize the host and port:
HOST=127.0.0.1
PORT=8082Default values if .env is not provided:
- HOST:
127.0.0.1 - PORT:
8082
| Key | Action |
|---|---|
Enter |
Send message |
Esc |
Quit client |
/help |
Show available commands |
/quit |
Exit the chat |
| Crate | Purpose |
|---|---|
tokio |
Async runtime for networking |
cursive |
Terminal UI framework |
serde / serde_json |
Message serialization |
chrono |
Timestamps |
dotenv |
Environment configuration |
┌─────────────┐ TCP ┌─────────────┐
│ Client │◄────────────►│ Server │
│ (TUI) │ │ (Tokio) │
└─────────────┘ └─────────────┘
│
┌─────────────┐ TCP │
│ Client │◄───────────────────┤
│ (TUI) │ │
└─────────────┘ │
│
┌─────────────┐ TCP │
│ Client │◄───────────────────┘
│ (TUI) │
└─────────────┘
- Server: Accepts connections, broadcasts messages to all connected clients
- Client: Connects to server, displays messages in a beautiful TUI
This project is open source and available under the MIT License.
Made with ❤️ and Rust 🦀