A Python-based peer-to-peer (P2P) chat system with centralized registration and local GUI-based messaging. The system allows clients to register with a central server, connect to other clients directly, and maintain persistent message logs using SQLite.
- Peer-to-peer messaging with direct socket connections
- Central server for client discovery and registration
- Local SQLite database for message history
- Tkinter-based GUI for sending and receiving messages
- Modular code with separate handlers for client, database, and UI
p2p-main/
│
├── server/
│ └── server.py # Handles client registration and user list management
│
├── client/
│ ├── client_chat_handler.py # Client-side P2P communication logic
│ ├── database_handler.py # Handles SQLite database storage of chat history
│ └── gui.py # Tkinter GUI frontend
- Python 3.8+
- No external libraries required (uses built-in
socket,sqlite3,tkinter,threading)
In a terminal:
cd server
uvicorn server:app --host 0.0.0.0 --port 8000Open two more terminals for separate clients:
cd client
python gui.py
(Db files would be autogenerated)- No unit tests yet. But, plan to implement:
- Client registration and reconnection
- Message sending and persistence
- SQLite message retrieval
- Add encryption (e.g., RSA for key exchange, AES for message encryption)
- Include chat history viewer in GUI
- Add WebSocket support for better scalability
- Group chat or file-sharing support