Skip to content

maxron84/Terminal-Chat-Program

Repository files navigation

🎨 Terminal Chat

Python 3.6+ License: MIT Tests GitHub release GitHub stars AI Generated

A simple, secure, and feature-rich terminal-based chat application with end-to-end encryption, private file sharing, and multi-client support.


⚠️ Important Disclaimers

πŸ€– AI-Generated Project

This entire project was created by AI using VS Codium with the Roo Code extension, powered by Anthropic Claude Sonnet 4.5.

  • ✨ 100% AI-coded - Every line of code, documentation, tests, and configuration
  • 🎯 Prompt-driven development - The author only wrote prompts, no actual code
  • πŸ€– AI architecture - Designed, implemented, and tested by AI
  • πŸ“ AI documentation - All README files, guides, and comments generated by AI

This project demonstrates the current capabilities of AI-assisted development and serves as an example of what can be achieved through careful prompting and iterative refinement.

πŸ”’ Network Usage Warning

⚠️ PRIVATE NETWORKS ONLY - DO NOT USE ON PUBLIC INTERNET ⚠️

This application is designed for private, trusted networks only (home LANs, office networks, VPNs). It is NOT intended for public internet deployment without significant additional security measures.

Why private networks only?

  • 🚫 No TLS/SSL transport encryption (data encrypted but no secure channel)
  • 🚫 No authentication system (password-only, no user accounts)
  • 🚫 No rate limiting (vulnerable to spam/DoS)
  • 🚫 No input validation hardening for internet threats
  • 🚫 No protection against sophisticated attacks

If you must deploy publicly:

  1. Use a VPN (WireGuard, OpenVPN) to create a private network
  2. Add a reverse proxy with TLS (nginx, traefik)
  3. Implement rate limiting and fail2ban
  4. Use strong, unique passwords
  5. Monitor logs actively
  6. See Security Assessment

Recommended use cases:

  • βœ… Home networks
  • βœ… Office LANs
  • βœ… VPN-connected users
  • βœ… Development/testing
  • βœ… Educational purposes
  • ❌ Public internet (without additional security)

✨ Features

  • πŸ” End-to-End Encryption - AES-256-CBC encryption for all messages and files
  • πŸ‘₯ Multi-Client Support - Real-time chat with multiple users simultaneously
  • πŸ“ Smart File Sharing - Share files publicly or privately with specific users
  • 🎯 Permission System - Granular access control for file sharing
  • 🌈 Color-Coded Messages - Easy-to-follow conversations with unique colors per user
  • πŸ”’ Unique Usernames - No duplicate names allowed for secure identification
  • πŸ“Š Complete Logging - Server-side audit trail for all operations
  • 🌍 Multi-Language - English and German documentation
  • πŸ§ͺ Fully Tested - 27 unit and integration tests (100% pass rate)

πŸš€ Quick Start

Installation

# Clone the repository
git clone https://github.com/maxron84/Terminal-Chat-Program.git
cd Terminal-Chat-Program

# No dependencies needed! Pure Python 3.6+

Running the Chat

Interactive Mode (Easiest - Cross-Platform):

python3 bin/terminal-chat.py

Docker Mode (Production-Ready):

# Configure
cp .env.example .env
nano .env  # Set strong password

# Deploy
docker-compose up -d

# Connect from any machine
python3 bin/terminal-chat.py

Troubleshooting Docker:

# If containers restart or encounter errors:
./docker-rebuild.sh

See Docker Deployment Guide for complete guide.

Command Line Mode:

# Start server
python3 src/main.py listen 4444 mypassword Admin

# Connect as client
python3 src/main.py connect localhost 4444 mypassword Alice

πŸ“– Usage

Basic Chat

Once connected, simply type messages and press Enter:

[Alice] > Hello everyone!
[Bob] > Hi Alice! How are you?
[Alice] > Great! Let me share a file with you...

Commands

Command Description Example Available To
/upload <file> Upload file (public) /upload report.pdf All users
/upload <file> @user Upload file privately /upload contract.pdf @Bob All users
/download <file> Download file from shared /download report.pdf All users
/list List shared files /list All users
/inbox List received private files /inbox All users
/outbox List files ready to upload /outbox All users
/help Show available commands /help All users
/quit Exit chat /quit All users

Note: The server (admin) can also receive private files from clients in its inbox folder!

File Sharing Examples

Public File (Everyone can access):

# 1. Put file in data/outbox/
cp myfile.pdf data/outbox/

# 2. Upload in chat
[Alice] > /upload myfile.pdf
βœ“ File uploaded

# 3. Anyone can download
[Bob] > /download myfile.pdf
βœ“ Downloaded to data/inbox/myfile.pdf

Private File (Only for specific user):

# 1. Put file in data/outbox/
cp confidential.pdf data/outbox/

# 2. Upload privately
[Alice] > /upload confidential.pdf @Bob
βœ“ File uploaded privately for Bob

# 3. Only Bob can download
[Bob] > /download confidential.pdf
βœ“ Downloaded

[Charlie] > /download confidential.pdf
βœ— Error: Private file (from Alice for Bob)

πŸ—οΈ Project Structure

Terminal-Chat-Program/
β”œβ”€β”€ bin/
β”‚   β”œβ”€β”€ terminal-chat.py        # Interactive launcher (cross-platform) ⭐
β”‚   β”œβ”€β”€ instructions.txt    # Quick reference (EN)
β”‚   └── anleitung.txt       # Quick reference (DE)
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ main.py             # Main entry point ⭐
β”‚   └── lib/                # Core library modules
β”‚       β”œβ”€β”€ __init__.py
β”‚       β”œβ”€β”€ utils.py        # Utilities & colors
β”‚       β”œβ”€β”€ encryption.py   # AES-256-CBC encryption
β”‚       β”œβ”€β”€ server.py       # Multi-client server
β”‚       β”œβ”€β”€ client.py       # Chat client
β”‚       └── file_permissions.py  # Access control
β”œβ”€β”€ tests/
β”‚   └── test_chat.py        # 27 unit & integration tests
β”œβ”€β”€ docs/
β”‚   β”œβ”€β”€ CONTRIBUTING.md     # Contribution guidelines
β”‚   β”œβ”€β”€ SECURITY.md         # Security policy
β”‚   β”œβ”€β”€ CHANGELOG.md        # Version history
β”‚   β”œβ”€β”€ DOCKER_DEPLOYMENT.md # Docker guide
β”‚   β”œβ”€β”€ MODULAR_STRUCTURE.md # Architecture
β”‚   β”œβ”€β”€ TEST_DOCUMENTATION.md # Testing
β”‚   β”œβ”€β”€ USER_MANUAL.txt     # User manual (EN)
β”‚   β”œβ”€β”€ BENUTZER_HANDBUCH.txt # User manual (DE)
β”‚   └── security/           # Security docs
β”‚       β”œβ”€β”€ SECURITY_ASSESSMENT.md
β”‚       └── SECURITY_ENHANCEMENT_CONCEPT.md
β”œβ”€β”€ data/                   # User data (auto-created)
β”‚   β”œβ”€β”€ inbox/             # Downloaded files
β”‚   β”œβ”€β”€ outbox/            # Files to upload
β”‚   β”œβ”€β”€ shared/            # Shared folder on server
β”‚   └── file_permissions.json  # Access metadata
└── logs/                   # Server logs (auto-created)
    └── chat_server_*.log

πŸ”§ Requirements

Native Installation

  • Python 3.6+ (usually pre-installed on Linux/Mac)
  • OpenSSL (for encryption - usually pre-installed)

No external Python packages required!

Docker Installation (Alternative)

  • Docker 20.10+
  • Docker Compose 1.29+ (optional but recommended)

Perfect for production deployments!

πŸ§ͺ Testing

Run the comprehensive test suite:

cd tests
python3 test_chat.py

Expected output:

Ran 27 tests in 0.330s

OK βœ…

Tests run: 27
Successes: 27
Failures: 0
Errors: 0

πŸ“š Documentation

User Guides

Technical Details

Quick Reference

πŸ”’ Security Features

Encryption

  • Algorithm: AES-256-CBC with PBKDF2 key derivation
  • Transport: Encrypted payload over TCP
  • Files: Base64-encoded and encrypted during transfer

Access Control

  • Username Uniqueness: No duplicate names allowed
  • File Permissions: Granular control over who can access what
  • Audit Trail: Complete server-side logging
  • Private Sharing: One-to-one file transfers

What's Logged

  • User connections/disconnections
  • File uploads/downloads
  • Permission checks
  • Failed authentication attempts
  • All server operations

🌐 Multi-Language Support

Documentation Languages

  • πŸ‡¬πŸ‡§ English
  • πŸ‡©πŸ‡ͺ Deutsch (German)

Add Your Language

Contributions for additional languages welcome! See bin/instructions.txt as template.

πŸ› οΈ Development

Running from Source

# As library
python3 -c "from src.lib import ChatServer, ChatClient"

# Direct execution
python3 src/main.py listen 4444 pass Admin

Docker Development

# Build image
docker build -t terminal-chat:dev .

# Run with live code mounting
docker run -it --rm \
  -v $(pwd)/src:/app/src \
  -p 4444:4444 \
  terminal-chat:dev listen 4444 pass Admin

# Run tests in container
docker run --rm terminal-chat:dev python3 tests/test_chat.py

Running Tests

# All tests
python3 tests/test_chat.py

# Specific test class
python3 -m unittest tests.test_chat.TestEncryption

# With pytest (if installed)
pytest tests/test_chat.py -v

Code Style

The project follows PEP 8 guidelines with:

  • 4-space indentation
  • Max line length: 100 characters
  • Docstrings for all functions/classes

πŸ“Š Test Coverage

Component          Tests   Status
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Encryption         8       βœ… Pass
Client             5       βœ… Pass
Server             2       βœ… Pass
File Ops           2       βœ… Pass
Permissions        7       βœ… Pass
Integration        2       βœ… Pass
Utilities          2       βœ… Pass
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Total              27      βœ… All Pass

🎯 Use Cases

Family & Friends

  • Private messaging without corporate platforms
  • Share family photos securely
  • Coordinate events with file sharing

Small Teams

  • Quick team communication
  • Share project files
  • Development team coordination

Education

  • Class discussions
  • Assignment submission
  • Study group collaboration

Self-Hosting

  • Complete control over your data
  • No external dependencies
  • Run on any Linux/Mac/Windows machine

⚠️ Security Considerations

For Local Networks

  • βœ… Perfect for home/office LANs
  • βœ… Encrypted message content
  • βœ… No external dependencies

For Internet Deployment

  • ⚠️ Consider adding TLS transport layer
  • ⚠️ Implement rate limiting
  • ⚠️ Use VPN for additional security
  • πŸ“– See Security Assessment

🎨 Screenshots

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Terminal Chat                          β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ [10:30:15] Alice: Hello everyone!       β”‚
β”‚ [10:30:20] Bob: Hi Alice!               β”‚
β”‚ [10:30:25] Alice: Check out report.pdf  β”‚
β”‚ [10:30:30] *** Alice uploaded file:     β”‚
β”‚            report.pdf ***               β”‚
β”‚ [10:30:35] Bob: /download report.pdf    β”‚
β”‚ [10:30:36] βœ“ Downloaded to inbox/       β”‚
β”‚                                         β”‚
β”‚ [Alice] > _                             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Built with Python's standard library
  • Uses OpenSSL for encryption
  • Inspired by the need for simple, secure communication

πŸ“§ Contact

πŸ—ΊοΈ Roadmap

Version 2.0 (Planned)

  • TLS/SSL transport encryption
  • User authentication system
  • Session management
  • Rate limiting
  • Web-based GUI

Version 3.0 (Future)

  • Voice chat support
  • Video sharing
  • Mobile apps
  • Plugin system

🀝 Contributing

Contributions welcome! Please:

  • Fork the repo and create a feature branch
  • Run tests before submitting PR
  • Follow PEP 8 style guidelines
  • Update documentation as needed

See CONTRIBUTING.md for detailed guidelines.

πŸ”’ Security

Report vulnerabilities via GitHub Security Advisories (not public issues).

This project is for private networks only. It lacks:

  • TLS/SSL transport encryption
  • Rate limiting
  • Enterprise-grade security features

See SECURITY.md for full security policy.

πŸ“‹ Changelog

v1.0.0 (2025-11-02)

  • Initial release
  • Multi-client encrypted chat
  • Private file sharing
  • Docker deployment
  • 27 passing tests

See CHANGELOG.md for detailed version history.


⭐ Star This Project

If you find this project useful, please consider giving it a star!


Made with ❀️ by AI (Claude Sonnet 4.5) + Human prompts

Happy Chatting! πŸŽ‰

Releases

No releases published

Packages

No packages published