Skip to content

Latest commit

 

History

History

README.md

💬 Chat Application

A Python-based client-server chat application that demonstrates real-time messaging using TCP sockets. The project implements user authentication, multithreaded communication, and a desktop graphical interface, making it a practical introduction to network programming and distributed systems.


✨ Features

  • 👤 User registration and login
  • 🔐 Password hashing using SHA-256
  • 💬 Real-time messaging between connected clients
  • 🖥️ Desktop GUI built with Tkinter
  • 🔄 Multithreaded server for handling multiple clients
  • 📡 TCP socket communication
  • 🗄️ SQLite database for user authentication
  • ⚠️ Graceful handling of client disconnections

🛠️ Tech Stack

  • Python
  • Socket Programming (TCP)
  • Tkinter
  • SQLite
  • Threading
  • hashlib

📂 Project Structure

ChatApp/
│
├── server.py          # Multi-client chat server
├── client.py          # Desktop chat client
├── database.py        # Database initialization
├── register.py        # User registration
├── login.py           # User authentication
├── chat.db            # SQLite database (generated)
├── README.md
└── requirements.txt

⚙️ Installation

Clone the repository:

git clone https://github.com/shriyatallapragada/OIBSIP-Python-Programming.git

Navigate to the project folder:

cd OIBSIP-Python-Programming/ChatApp

No external packages are required as the project uses Python's standard library.


▶️ Running the Application

Step 1 — Initialize the database

python database.py

Step 2 — Register a user

python register.py

Create a username and password.


Step 3 — Start the server

python server.py

Expected output:

Server running...

Step 4 — Launch one or more clients

Open another terminal for each client.

python client.py

Enter your registered username and password.

Once authenticated, users can exchange messages in real time.


⚙️ System Architecture

          SQLite Database
                 ▲
                 │
        Authentication
                 │
                 ▼
      ┌──────────────────┐
      │    TCP Server    │
      └──────────────────┘
          ▲          ▲
          │          │
     Client 1    Client 2
          │          │
      Tkinter GUI Tkinter GUI

🔄 Application Workflow

  1. The server starts and listens for incoming client connections.
  2. A client connects using TCP sockets.
  3. Login credentials are sent to the server.
  4. The server validates the credentials against the SQLite database.
  5. If authentication succeeds:
    • The client joins the chat.
    • Other connected users receive a notification.
  6. Messages are broadcast to every connected client.
  7. If a client disconnects, the server removes the connection and notifies the remaining users.

🔐 Authentication

Passwords are never stored as plain text.

During registration:

  • The password is hashed using SHA-256
  • Only the hashed value is stored inside the SQLite database

During login:

  • The entered password is hashed again
  • The server compares the hash against the stored value before granting access

📚 Learning Outcomes

This project helped strengthen my understanding of:

  • Client-server architecture
  • TCP socket programming
  • Multithreading in Python
  • GUI development with Tkinter
  • Database integration using SQLite
  • Password hashing and authentication
  • Network communication

🚀 Future Improvements

  • Private messaging
  • Chat rooms
  • End-to-end encryption
  • File sharing
  • Image sharing
  • Typing indicators
  • Online/offline user status
  • Message history
  • Better error handling
  • Cross-platform packaging

📸 Demo

Add screenshots or a GIF demonstrating the application here.

Login

<p align="center">
  <img src="assets/login.png" width="750">
</p>

Chat Window

<p align="center">
  <img src="assets/chat.png" width="750">
</p>

📄 Notes

This project was developed as part of my Python programming portfolio to explore networking concepts and desktop application development. It serves as a practical implementation of socket programming, user authentication, and concurrent client communication.


📜 License

Developed for educational purposes as part of my Python programming portfolio.