A feature-rich terminal-based chat application with support for one-to-one messaging, group chats, chat history, and continuous chat mode.
β¨ Authentication
- User registration and login
- Secure password hashing (SHA-256)
- Session-based authentication with tokens
π¬ Private Messaging
- Send direct messages to users
- Continuous chat mode for seamless conversations
- Real-time message delivery
- Chat history saved automatically
π₯ Group Chat
- Create and manage groups
- Join/leave groups
- Send messages to all group members
- Group chat history
π Chat History
- Automatic saving of all conversations
- History stored in text files
- Organized by conversation
π¨ Interactive CLI
- Colorful terminal interface
- Real-time message notifications
- Multiple chat modes
- Help system
- Clone or download the repository
- Navigate to the project directory:
cd chat-app - Create a virtual environment (optional but recommended):
python -m venv .venv source .venv/bin/activate # On Linux/Mac # or .venv\Scripts\activate # On Windows
cd /home/tej/chat-app
PYTHONPATH=/home/tej/chat-app python server/server.pyThe server will start listening on port 5000.
In a new terminal:
cd /home/tej/chat-app
PYTHONPATH=/home/tej/chat-app python client/client.pyYou can run multiple clients to simulate different users.
Register a new account:
> register
Username: alice
Password: mypassword
Login:
> login
Username: alice
Password: mypassword
Send a single message:
> send bob Hello Bob!
Enter continuous chat mode with a user:
> chat bob
@bob > Hello!
@bob > How are you?
@bob > /exit
In continuous chat mode:
- Just type your message and press Enter
- Type
/exitto leave continuous chat mode - The prompt shows
@username >to indicate you're chatting with that user
Create a new group:
> create developers
Join an existing group:
> join developers
Send a message to a group:
> gsend developers Hello everyone!
Enter continuous group chat:
> gchat developers
#developers > Good morning team!
#developers > Anyone available?
#developers > /exit
List your groups:
> groups
View group members:
> members developers
Leave a group:
> leave developers
Show help:
> help
Exit the application:
> quit
or
> exit
All conversations are automatically saved to text files in the chat_history/ directory:
- One-to-one chats:
chat_history/user1:user2.txt - Group chats:
chat_history/group_groupname.txt
Example history file content:
Chat History: alice and bob
============================================================
[2026-01-28 14:30:15] alice -> bob
Hello Bob!
[2026-01-28 14:30:22] bob -> alice
Hi Alice!
chat-app/
βββ client/
β βββ client.py # Client application
βββ server/
β βββ server.py # Main server
β βββ auth.py # Authentication logic
β βββ session.py # Session management
β βββ router.py # Message routing
β βββ groups.py # Group management
β βββ history.py # Chat history storage
βββ shared/
β βββ protocol.py # Communication protocol
βββ chat_history/ # Saved chat logs (auto-created)
βββ requirements.txt # Python dependencies
βββ DATA_STRUCTURES.md # Data structures documentation
βββ README.md # This file
- Server: Handles multiple clients, routes messages, manages authentication
- Client: Terminal UI for user interaction
- Protocol: JSON-based message format
- History: Persistent storage of all conversations
- Groups: Multi-user chat rooms
For detailed documentation of all data structures used in the application, see DATA_STRUCTURES.md.
$ python client/client.py
βββββββββββββββββββββββββββββββββββββββββ
β Chat Application v2.0 β
β Now with Groups & Continuous Chat! β
βββββββββββββββββββββββββββββββββββββββββ
β Connected to server
Guest > register
Username: alice
Password: ***
β Registration successful! You can now login.
Guest > login
Username: alice
Password: ***
β Logged in successfully!
alice > create developers
β Group 'developers' created successfully!
alice > chat bob
Entered chat with bob. Type /exit to leave.
@bob > Hey Bob, want to join the developers group?
[14:35:10] You: Hey Bob, want to join the developers group?
[14:35:23] bob: Sure! How do I join?
@bob > Just type: join developers
[14:35:30] You: Just type: join developers
@bob > /exit
Exited continuous chat mode
alice > gchat developers
Entered group chat: developers. Type /exit to leave.
#developers > Welcome to the team!
[14:36:15] You: Welcome to the team!
[14:36:20] [developers] bob: Thanks! Happy to be here.
#developers > /exit$ python client/client.py
β Connected to server
Guest > register
Username: bob
Password: ***
Guest > login
Username: bob
Password: ***
β Logged in successfully!
[14:35:10] alice: Hey Bob, want to join the developers group?
bob > send alice Sure! How do I join?
[14:35:30] alice: Just type: join developers
bob > join developers
β Joined group 'developers'!
[14:36:15] [developers] alice: Welcome to the team!
bob > gsend developers Thanks! Happy to be here.The application uses a JSON-based protocol over TCP sockets. Messages are newline-delimited JSON objects.
- AUTH: Authentication (register, login)
- CHAT: Private messages
- GROUP: Group operations and messages
- SYSTEM: Server responses and notifications
For complete protocol documentation, see DATA_STRUCTURES.md.
- Uses SHA-256 for password hashing (single hash, no salt)
- Transmits messages in plaintext
- Stores passwords in memory
For production use, you should:
- Use proper password hashing (bcrypt, argon2)
- Implement TLS/SSL for encrypted communication
- Use a proper database for persistence
- Add input validation and sanitization
- Implement rate limiting
- Add proper error handling
- File transfer support
- End-to-end encryption
- Message read receipts
- User presence indicators
- Database persistence (SQLite/PostgreSQL)
- Web-based client
- Voice/video chat
- Message search functionality
- User profiles and avatars
This project is for educational purposes.
Feel free to fork and enhance the project!