npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

cli-chatapplication

v1.0.2

Published

A real-time CLI Chat Application built with TypeScript and Firebase Realtime Database.

Readme

💬 CLI Chat Application

A real-time command-line chat application built with TypeScript, Node.js, and Firebase Realtime Database.

This project allows multiple users to communicate through a terminal using a shared group chat or private direct messages. It demonstrates real-time communication, user authentication, online presence tracking, and terminal-based interaction without relying on any graphical interface.


✨ Features

  • 🔐 Simple User Authentication

    • Login using User ID and Password
    • Credentials stored in Firebase Realtime Database
  • 🌐 Real-Time Group Chat

    • Multiple users can communicate simultaneously
    • Messages are delivered instantly using Firebase listeners
  • 💬 Direct Messaging

    • One-to-one conversations between registered users
    • Dedicated conversation channel for every pair of users
  • 🟢 Online / Offline Presence

    • Users automatically become online after login
    • Status changes back to offline when the application exits
  • ⚡ Real-Time Synchronization

    • Uses Firebase Realtime Database
    • No polling or manual refresh required
  • 💻 Terminal Based Interface

    • Lightweight CLI experience
    • Built using Node.js readline module

📦 Installation

Install Globally

npm install -g cli-chatapplication

or run it directly without installing

npx cli-chatapplication

Verify Installation

cli-chat

If installed correctly, you'll see:

CLI Chat Application

Enter User ID:
>

🚀 Usage

Start the application

cli-chat

Login

Enter your credentials

CLI Chat Application

Enter User ID:
> om-macbook

Enter Password:
> 123456

After successful authentication you'll see

Logged in as Om's MacBook

1. Group Chat
2. Direct Message

>

Group Chat

Select

1

Type your message

> Hello everyone!

Every connected user will instantly receive the message.


Direct Message

Select

2

Choose a user

Available Users

1. Om's iPad
2. Om's iPhone

Select User:
> 1

Now every message you type will be sent only to the selected user.


Exit

Press

Ctrl + C

The application automatically:

  • Marks you offline
  • Closes the connection
  • Exits gracefully

🛠 Tech Stack

| Technology | Purpose | |------------|---------| | TypeScript | Programming Language | | Node.js | Runtime | | Firebase Realtime Database | Real-time backend | | Firebase SDK | Database Communication | | Readline | Terminal Input | | npm | Package Management |


📂 Project Structure

src/
│
├── firebase.ts
│   Firebase configuration and database operations
│
├── index.ts
│   Application entry point
│   Handles authentication and application flow
│
├── groupChat.ts
│   Group chat functionality
│
└── directChat.ts
    Direct messaging functionality

🔐 User Authentication

Users are stored inside Firebase Realtime Database.

Example

users
│
├── om-macbook
│     username
│     password
│     online
│
├── om-ipad
│     username
│     password
│     online
│
└── om-iphone
      username
      password
      online

When the application starts

CLI Chat Application

Enter User ID:
>

Enter Password:
>

If the credentials are valid

  • User is marked online
  • Chat session starts

If invalid

Invalid User ID or Password

🌍 Group Chat

Messages are stored under

groupMessages/

Each message contains

{
  "senderId": "om-macbook",
  "text": "Hello World",
  "timestamp": 1751972382
}

Messages are synchronized in real time across all connected terminals.


💬 Direct Messaging

Private conversations are stored separately.

Conversation IDs are generated by sorting user IDs alphabetically.

Example

messages/

om-ipad_om-macbook/

om-ipad_om-iphone/

om-macbook_om-iphone/

This ensures only one conversation exists between two users.


🟢 Presence System

Each user maintains an online status.

{
    "online": true
}

Status is updated

  • On successful login
  • When the application exits

🔥 Firebase Database Structure

users
│
├── userId
│     username
│     password
│     online
│
├── ...
│

groupMessages
│
├── messageId
│     senderId
│     text
│     timestamp
│
└── ...

messages
│
├── conversationId
│      messageId
│          senderId
│          receiverId
│          text
│          timestamp

🚀 How It Works

User Login
      │
      ▼
Firebase Authentication Check
      │
      ▼
Mark User Online
      │
      ▼
Select Chat Mode
      │
      ├───────────────┐
      ▼               ▼
 Group Chat      Direct Chat
      │               │
      ▼               ▼
Realtime Firebase Listeners
      │
      ▼
Instant Message Delivery

📸 Terminal Preview

CLI Chat Application

Enter User ID:
> om-macbook

Enter Password:
> ******

Logged in as Om's MacBook

1. Group Chat
2. Direct Message

> 1

--------------------------------

om-ipad:
Hello

om-macbook:
Hi!

>

🎯 Learning Outcomes

This project demonstrates

  • Firebase Realtime Database
  • Real-time communication
  • CLI application development
  • TypeScript
  • Node.js
  • Authentication flow
  • Presence management
  • Event-driven programming
  • npm package development

🚧 Future Improvements

  • End-to-end encryption
  • Gemini AI integration
  • File sharing
  • Typing indicators
  • Message reactions
  • Chat history search
  • Custom Firebase project initialization
  • Better terminal UI using Ink or Blessed
  • User registration from CLI
  • Configuration file support

🤝 Contributing

Contributions, ideas and feature requests are always welcome.

Feel free to fork the repository and create a pull request.


📄 License

This project is licensed under the ISC License.


👨‍💻 Author

Om Sharma

GitHub

https://github.com/Sharma-Ji-21

If you found this project helpful, consider giving it a ⭐ on GitHub.