Skip to content

Repository files navigation

⚡ Asynchronous Chat Client

A simple Python chat client featuring a Tkinter GUI. The program utilizes asynchronous processing to simultaneously read network messages, send user input, save history to a file, and monitor connection stability - all within a single window.

Asynchronous Chat Client

📌 Table of Contents

⚙️ Tech Stack

  • Operating System: Linux, macOS, or Windows
  • Language: Python 3.11+
  • Asynchronous Framework: asyncio & anyio
  • Asynchronous File Handling: aiofiles
  • Configuration: pydantic-settings & pydantic
  • Graphical Interface: tkinter

📁 Project Structure

.
├── logs/              # Dynamically generated application logs folder
├── .env.example       # Example environment configuration
├── chat.history       # Dynamically generated persistent chat history log
├── token.json         # Dynamically generated JSON file storing user credentials
├── config.py          # Unified Pydantic application configuration & validators
├── logging_config.py  # Non-blocking async queue logger
├── gui.py             # Tkinter layout definition and async UI update loops
├── reader.py          # Network stream consumer and storage workers
├── registration.py    # Standalone graphical user registration wizard
├── sender.py          # Network stream authorization and keep-alive workers
├── main.py            # Central network orchestrator and application entry point
└── requirements.txt   # Python dependencies

🛠️ Installation and Setup

Basic Setup:

1. Clone the repository:

git clone https://github.com/...
cd project-directory

2. Set up a virtual environment:

python -m venv venv
venv\Scripts\activate # on Windows
source venv/bin/activate # on Linux / macOS

3. Install Python dependencies:

pip install -r requirements.txt

4. Configure environment variables:

Create a .env file in the root directory based on .env.example:

# Server
SERVER_HOST=127.0.0.1
READ_PORT=5000
SEND_PORT=5050

# Logging
LOG_LEVEL=INFO

# Chat Client
HISTORY_FILE=chat.history
TOKEN_FILE=token.json
ACCOUNT_HASH="your_account_hash"

🚀 Quick Start Guide

Development Server Launch

1. New user registration.

Before chatting, new users must obtain a secure authorization token from the server. Run the standalone graphical registration wizard:

python registration.py
2. Main chat client launch.

Once your token is generated, start the main application:

python main.py

CLI Configuration

The client supports dynamic configuration override via command-line arguments using the integrated Pydantic CLI engine. Arguments provided via the terminal have the highest priority and will automatically override values defined in the .env file.

You can view the help menu and available options by running:

python registration.py --help
# or
python main.py --help

Usage examples:

# Override token resolution paths directly from the shell
python registration.py --token custom_file.json
python main.py --token custom_file.json

# Run the client and save the chat history to a custom file named "chat.txt"
python main.py --history chat.txt

# Connect to a specific remote server at "host.com" using custom ports
python main.py --host host.com --r-port 5000 --s-port 5050

# Login with an existing token using the --hash flag
python main.py --hash your_account_hash

About

An asynchronous Python chat client featuring a tkinter GUI, token-based authorization, and automatic message history saving.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages