Skip to content

Raxku2/CLI-Chat-App

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

3 Commits
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ—จ๏ธ Async CLI Chat App

Python MongoDB Asyncio Motor Rich dotenv Built with AI

A realtime command-line chat application built with Python (asyncio) and MongoDB. Messages appear live across all connected clients using MongoDB Change Streams, and old messages auto-expire after 30 minutes using a TTL index.


๐Ÿš€ Features

  • ๐Ÿ”„ Realtime chat powered by MongoDB Change Streams.
  • ๐Ÿง‘โ€๐Ÿคโ€๐Ÿง‘ Public chatroom (all) with support for DMs (extendable).
  • ๐Ÿ•’ Auto-delete messages after 30 minutes (TTL index).
  • โฑ Shows recent chat history when joining.
  • โœจ Beautiful CLI output with rich.
  • โšก Async + non-blocking input (smooth typing + live updates).
  • ๐Ÿค– Assisted & scaffolded with AI during development.

๐Ÿ› ๏ธ Tech Stack

  • Python (3.9+)
  • asyncio โ€“ concurrency
  • Motor โ€“ async MongoDB driver
  • MongoDB โ€“ database + change streams + TTL
  • Rich โ€“ styled CLI output
  • python-dotenv โ€“ load .env config
  • AI Assistance โ€“ design & development scaffolding

๐Ÿ“ฆ Installation

  1. Clone this repo:
git clone https://github.com/yourusername/cli-chat-app.git
cd cli-chat-app
  1. Install dependencies:
pip install motor rich python-dotenv
  1. Set up environment variables in a .env file:
MONGODB_URI=mongodb://localhost:27017
CHAT_DB=chat_app
  1. Start MongoDB (local or Atlas).

โ–ถ๏ธ Usage

Run the app in multiple terminals (one per user):

python chat_async.py
  • Choose a username when prompted.
  • Type messages to chat in realtime.
  • Use /quit or Ctrl+C to exit.

โš™๏ธ Configuration

  • TTL_SECONDS โ†’ how long messages live (default: 1800 = 30min)
  • RECENT_LIMIT โ†’ how many past messages to show when joining

About

A **realtime command-line chat application** built with **Python (asyncio)** and **MongoDB**

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages